Kai*_*ran 6 sql oracle variables select declare
您好我试图声明一个变量在Oracle SQL select查询中使用如下:
DECLARE
myDate DATE;
BEGIN
SELECT Source as "Source", DT as "Date", Status as "Status", COALESCE("Count", 0) as "Count"
FROM (Huge SubQuery that includes many WHERE date between x and y);
END;
Run Code Online (Sandbox Code Playgroud)
我需要使用myDate进行查询,所以每次运行查询时我都不必在10个位置更新它.基本上它只是声明一个可以在where日期使用的变量是在几个地方的子句之间.
尝试这个:
variable var DATE
exec :var := '15-OCT-13'
Run Code Online (Sandbox Code Playgroud)
然后使用 :var 进行选择