我在PL SQL过程中使用以下代码:
execute immediate 'select count(distinct item_type) into counter_variable
from items where ' || field_name || ' is not null'
Run Code Online (Sandbox Code Playgroud)
这里,
counter_variable在过程的声明部分声明field_name是PL SQL过程的IN参数,传递的值将是'items'表中的列名
我得到的错误是"无效的SQL语句",我无法弄清楚原因.有任何想法吗?
谢谢
Kla*_*äck 10
该into子句是PL/SQL,在SQL语句中无效.试试这个:
execute immediate 'select count(distinct item_type)
from items where ' || field_name || ' is not null' into counter_variable
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3131 次 |
| 最近记录: |