>>-EXEC SQL--.------------.---> +-AT db_name-+ >--PERSIST cursor_name TO xml_destination---> >-----END-EXEC-----<>
AT db_name | DECLARE DATABASE を使用して宣言されたデータベースの名前。この句は必須ではありません。省略すると、DECLARE CURSOR 文に関連付けられている接続に自動的に切り替わります (その接続が現在の接続とは異なる場合。DECLARE CURSOR 文の実行中のみ有効)。 |
cursor_name | すでに宣言済みの、開いたカーソル。 |
xml_destination | 一重または二重の引用符で囲んだ、識別子、ホスト変数、またはリテラル |
Data Direct Connect ODBC ドライバーを使用する場合は、バージョン 3.70 以降を使用する必要があります。
01 hv pic x(50). procedure-division. *> set whenever clause to handle sql errors exec sql whenever sqlerror goto sql-error end-exec exec sql whenever sqlwarning perform sql-warning end-exec *> connect to data source exec sql connect to "data source" end-exec *> declare static cursor with column info you want to save to xml file exec sql declare c static cursor for select * from emp end-exec *> open cursor exec sql open c end-exec *> save data to xml file using double quoted literal exec sql persist c to "c:\XML Files\xmltest1.xml" end-exec *> save data to xml file using single quoted literal exec sql persist c to 'c:\XML Files\xmltest2.xml' end-exec *> save data to xml file using a host variable move "c:\XML Files\xmltest3.xml" to hv exec sql persist c to :hv end-exec *> close the cursor exec sql close c end-exec *> disconnect from datasource exec sql disconnect current end-exec goback.