【问题标题】:Query from a function从函数查询
【发布时间】:2017-11-29 21:37:48
【问题描述】:

我有这个问题

Select distinct a.name,
p1.ref as book,
p2.ref as text,
p3.ref as note
from library a
left join room p1 on a.id=p1.id 
left join room p2 on a.id=p2.id 
left join room p3 on a.id=p3.id 

我开始创建如下函数。函数的输出需要是上面的查询。 p1、p2、p3是动态生成的

rlsql varchar2(12000) := 'select distinct ';
rlsql := rlsql||'ref as '||c_var.name||',';
rlsql := rlsql||chr(13)||chr(10);
rlsql := rlsql||' from library';

rlsql := rlsql||' left join room on a.id='||c_var.id||' 

当我执行上述部分函数时,它会返回如下示例

Select distinct 
ref as book from library,
ref as text from library,
ref as note from library

如何删除每一行的“从库中”以及如何获取 p1. ,p2。 ,p3。动态

非常感谢您对此的任何帮助

【问题讨论】:

  • 您可以通过将列部分放入循环中并在循环中取出from library 来执行此操作。请通过与我们分享完整的 pl/sql 代码来详细说明您的问题。
  • 发布完整的函数以及他的输入、实际输出和预期输出。

标签: oracle plsql oracle10g


【解决方案1】:

删除连接' from library'的这一行

rlsql := rlsql||' from library';

【讨论】:

    猜你喜欢
    • 2016-01-18
    • 1970-01-01
    • 2013-05-03
    • 1970-01-01
    • 2017-01-09
    • 2019-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多