0

APEX 3.2 オラクル 11

私の要件は、ユーザーが .CSV ファイルをロードできるようにする GUI プロセスを作成することです。このファイルには 4 つの列しかなく、複数の行がある場合があります。次に、データベースのデータ テーブルを .CVS ファイルの対応するデータで更新します。

CSV file:
ID Number:  Field Name:  Channel:   Analyst:
123456      Title         Retail    John Smith
123456      City          Retail    John Smith


Current DB:
ID Number:  Field Name:  Channel:   Analyst:
123456      Title         Retail    (null)
123456      City          (null)    (null)


After Update DB
ID Number:  Field Name:  Channel:   Analyst:
123456      Title         Retail    John Smith
123456      City          Retail    John Smith

アイデアやリンクは大歓迎です。

4

1 に答える 1

0

ファイル参照アイテムを提供し、ファイルをwwv_flow_filesにアップロードします。

次に、BLOBコンテンツを解析します。次のリンクを参照してください。

http://christopherbeck.wordpress.com/2012/04/03/parsing-a-csv-file-in-plsql/

コメントも読む価値があります。たとえば、AlexendriaPLSQLユーティリティライブラリが言及されています。このライブラリには、plsqlベースのツールがたくさん含まれており、一見の価値があります。

http://code.google.com/p/plsql-utils/

(ブログのMortenのコメントから引用)

クリス、

私が指摘したように、csv_util_pkgパッケージの最新バージョンはAlexandriaライブラリにあり、これは実際にオプションで囲まれた値をサポートしています。

サンプルデータでテストしました。

 select * from table(csv_util_pkg.clob_to_csv(‘normal,”commas,,,in the
 field”,”"”enclosed”"”,”random “” double “” quotes”,”commas,,, “” and
 double “”"” quotes”‘))

そして、これはデータを5つの列に分割します。

 c001 = normal c002 = commas,,,in the field c003 = “enclosed” c004 =
 random ” double ” quotes c005 = commas,,, ” and double “” quotes

(ブログ投稿から古いコードを削除し、最新のライブラリコードをダウンロードするように人々に指示する必要があると思います。)

  • モーテン

また、コメントのさらに、blobからclobに移動する方法が示されています(したがって、投稿された方法を使用できます。ChristopherBeckのクレジット):

  function blob_to_clob( p_lob in blob ) return clob is
     l_clob_result   clob := 'X';
     l_dest_offsset integer := 1;
     l_src_offsset  integer := 1;
     l_lang_context integer := dbms_lob.default_lang_ctx;
     l_warning      integer;
  begin
     if p_lob is not null and length(p_lob) > 0 then
        dbms_lob.converttoclob(dest_lob     => l_clob_Result,
                               src_blob     => p_lob,
                               amount       => dbms_lob.lobmaxsize,
                               dest_offset  => l_dest_offsset,
                               src_offset   => l_src_offsset,
                               blob_csid    => dbms_lob.default_csid,
                               lang_context => l_lang_context,
                               warning      => l_warning);
        if l_warning != 0 then
           dbms_output.put_line('Function blob_to_clob warning:' || l_warning);
           return null;
        end if;
        return l_clob_result;
     else
        return null;
     end if;
  exception
     when others then
        dbms_output.put_line('Function blob_to_clob error:' || SQLCODE);
        return null;
  end blob_to_clob;

列をグローバル一時テーブルまたはコレクションに出力してから、これに対してupdate-logicを実行できます。(ただし、GTTとapexには注意してください。同じセッションにいる限り問題ありませんが、たとえばこれを2番目のプロセスにする場合、同じセッションが使用される保証はありません!)

于 2012-07-26T07:10:37.873 に答える