如何将DEFINE变量设置为PL/SQL中另一个已定义表中的选择
如何使用DEFINE函数设置一个等于另一个SELECT语句结果的变量?结果仅为单列/单行选择 例如:如何将DEFINE变量设置为PL/SQL中另一个已定义表中的选择,sql,oracle,sqlplus,Sql,Oracle,Sqlplus,如何使用DEFINE函数设置一个等于另一个SELECT语句结果的变量?结果仅为单列/单行选择 例如: DEFINE source_table = mysourcetable DEFINE use_date = select distinct max(txn_date) from &source_table select asdf1, asdf2 from &source_table s where &use_date between s.eff_date and s.e
DEFINE source_table = mysourcetable
DEFINE use_date = select distinct max(txn_date) from &source_table
select asdf1, asdf2
from &source_table s
where &use_date between s.eff_date and s.end_date
我当前遇到的错误是WHERE子句中&usedate变量上的“缺少表达式”
希望这是有意义的。刚刚想好了。WHERE子句中的&use\u日期需要放在括号中
DEFINE source_table = mysourcetable
DEFINE use_date = select distinct max(txn_date) from &source_table
select asdf1, asdf2
from &source_table s
where (&use_date) between s.eff_date and s.end_date
或者将定义查询放在括号中:
DEFINE source_table = mysourcetable
DEFINE use_date = (select distinct max(txn_date) from &source_table)
select asdf1, asdf2
from &source_table s
where &use_date between s.eff_date and s.end_date
为了完整起见,这是使用列的另一种方式。。新值命令:
DEFINE source_table = mysourcetable
column the_col new_value use_date
select distinct max(txn_date) the_col from &source_table;
PROMPT The value is &use_date
select asdf1, asdf2
from &source_table s
where TO_DATE('&use_date') between s.eff_date and s.end_date;