0

これはバッチファイルを生成するための私のSQLコードです

SELECT    'CANCEL_TRANS trans WITH serial = "'
   || serial
   || '" , short_name = "'
   || short_name
   || '";'
FROM trans
WHERE ( (trans.status = 0))
   AND TO_TIMESTAMP (time_created, 'YYYY/MM/DD-HH24:MI:SS.FF') <
          SYSDATE - 1 / 24
   AND platform_name LIKE '%test%';

出力

(常に異なる行数)

CANCEL_TRANS trans WITH serial = "507760" , short_name = "BD";
CANCEL_TRANS trans WITH serial = "507761" , short_name = "BD";
CANCEL_TRANS trans WITH serial = "507781" , short_name = "BD";
CANCEL_TRANS trans WITH serial = "507782" , short_name = "BD";
CANCEL_TRANS trans WITH serial = "507785" , short_name = "BD";
CANCEL_TRANS trans WITH serial = "507786" , short_name = "BD";
CANCEL_TRANS trans WITH serial = "507880" , short_name = "BD";
CANCEL_TRANS trans WITH serial = "507883" , short_name = "BD";
CANCEL_TRANS trans WITH serial = "507884" , short_name = "BD";
CANCEL_TRANS trans WITH serial = "507886" , short_name = "BD";
CANCEL_TRANS trans WITH serial = "507976" , short_name = "BD";
CANCEL_TRANS trans WITH serial = "507964" , short_name = "BD";
CANCEL_TRANS trans WITH serial = "507967" , short_name = "BD";
CANCEL_TRANS trans WITH serial = "507971" , short_name = "BD";
CANCEL_TRANS trans WITH serial = "507762" , short_name = "BD";
CANCEL_TRANS trans WITH serial = "508096" , short_name = "BD";

この文字列/リテラル​​を最後の行に出力したいと思います。SQL(シェルスクリプトではない)でそれをしたい:

execute;
4

2 に答える 2

2

使用UNION ALL

SELECT ...
UNION ALL
SELECT 'execute;' from dual
于 2012-11-09T13:01:48.703 に答える
0

次のコードを使用します。

SELECT top 1 'CANCEL_TRANS trans WITH serial = "' || serial 
              || '" , short_name = "' || short_name || '";' 
  FROM trans 
 WHERE trans.status = 0
   AND TO_TIMESTAMP(time_created, 'YYYY/MM/DD-HH24:MI:SS.FF') < SYSDATE - 1 / 24 
   AND platform_name LIKE '%test%' order by serial desc;
于 2012-11-09T13:11:41.607 に答える