[英]How can I declare and assign values to variables in Oracle SQL Developer for PostgreSQL
我一直在研究並嘗試了多種方法來使用 Oracle SQL Developer 為 PostgreSQL 數據庫聲明變量並為其賦值,但無濟於事。 這就是我想要做的:
DEFINE response = '0'
DEFINE startDate = TO_TIMESTAMP('2020/03/28 00:00:00', 'yyyy/mm/dd HH24:MI:SS');
DEFINE endDate = TO_TIMESTAMP('2020/03/30 19:00:00', 'yyyy/mm/dd HH24:MI:SS');
SELECT clog.ch_call_index
,clog.ch_response AS "Response"
,cdata.ch_final_disposition AS "Result"
,clog.ch_spoken
,cdata.ch_recorded_msg AS "Recorded Message"
,cdata.ch_menu_selections AS "Menu Selections"
,clog.ch_spoken_dt_tm
,clog.ch_response_dt_tm
FROM ch_call_log clog
INNER JOIN ch_call_data cdata ON clog.ch_call_index = cdata.ch_call_index
WHERE cdata.ch_start_dt_tm >= &startDate
AND cdata.ch_start_dt_tm <= &endDate
AND (SELECT ch_response
FROM ch_call_log
WHERE ch_call_index = clog.ch_call_index
ORDER BY ch_spoken_dt_tm DESC
LIMIT 1) = '&&response'
AND clog.ch_response = '&&response'
ORDER BY cdata.ch_final_disposition
以下工作很好,但我想弄清楚如何使用變量並在需要時輕松更新它們:
SELECT clog.ch_call_index
,clog.ch_response AS "Response"
,cdata.ch_final_disposition AS "Result"
,clog.ch_spoken
,cdata.ch_recorded_msg AS "Recorded Message"
,cdata.ch_menu_selections AS "Menu Selections"
,clog.ch_spoken_dt_tm
,clog.ch_response_dt_tm
FROM ch_call_log clog
INNER JOIN ch_call_data cdata ON clog.ch_call_index = cdata.ch_call_index
WHERE cdata.ch_start_dt_tm >= TO_TIMESTAMP('2020/03/28 00:00:00', 'yyyy/mm/dd HH24:MI:SS')
AND cdata.ch_start_dt_tm <= TO_TIMESTAMP('2020/03/30 19:00:00', 'yyyy/mm/dd HH24:MI:SS')
AND (SELECT ch_response
FROM ch_call_log
WHERE ch_call_index = clog.ch_call_index
ORDER BY ch_spoken_dt_tm DESC
LIMIT 1) = '0'
AND clog.ch_response = '0'
ORDER BY cdata.ch_final_disposition
試試這個!
DECLARE start_date AS TIMESTAMP
SET start_date = TO_TIMESTAMP('2020/03/28 00:00:00', 'yyyy/mm/dd HH24:MI:SS')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.