IF 中的多个 Select 语句
我可以使用一些帮助来编写报告的 prog./sql 构造。Sql
应该首先检查提示符 &然后决定哪些“select”语句应该运行
类似(伪代码)的内容,
Select ACCT,LOC FROM (
IF :loc = 'MN' THEN
Select acc as ACCT,location as LOC
ELSE IF :loc = 'MA' THEN
Select accid as ACCT,locid as LOC
ELSE IF :loc = 'PA' THEN
Select accountid as ACCT,location as LOC
END IF)
上面似乎不起作用。请帮忙!
I could use some help to write a prog./sql construct for a report..
The Sql should first check for the prompt & then decide which "select" statements should run
something like (pseudo-code)
Select ACCT,LOC FROM (
IF :loc = 'MN' THEN
Select acc as ACCT,location as LOC
ELSE IF :loc = 'MA' THEN
Select accid as ACCT,locid as LOC
ELSE IF :loc = 'PA' THEN
Select accountid as ACCT,location as LOC
END IF)
the above doesnt seem to work. Please help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你可以这样做:
You could do this:
怎么样...
或者...
这样做会更友好,因为它减少了唯一游标的数量。
How about ...
or ...
It would be more friendly to do that because it reduces the number of unique cursors.
如果您可以创建自定义 PL/SQL 函数,那么您可以从中返回结果集(所谓的记录表),然后只需从函数中进行选择。请参阅本文。
If you can create custom PL/SQL functions, then you can return result set from it (so called table of records) and then just select from function. See this article.