我提供的SQL会提示用户输入表名。此SQL将提供列名,数据类型,数据长度,数据精度的报告,并指示特定表是否允许空值。
这是我正在运行的查询:
SELECT employee_id, first_name, last_name
FROM employees
GROUP BY employee_id;
select department_id where employee_id = :table_name;
set echo
(select column_name, data_type, data_length,
data_precision, data_scale, nullable
from all_tab_columns
where table_name = 'employees'
order by column_name);
我得到一个窗口,用户应该输入表名,但第二个select语句无法运行。它出现了ORA-00933: sql command not properly ended
。
如果我单独运行第二个select语句,我会收到no data found
消息。
答案 0 :(得分:1)
首先,您在此查询中缺少表名:
select department_id where employee_id = :table_name;
应该是:
select department_id from employees where employee_id = :table_name;
第二
set echo
会给你一个错误:
SP2-0265:必须将echo设置为ON或OFF
您必须为该命令添加ON
或OFF
参数。
例如:
set echo ON;
更多:set echo
第三
select column_name, data_type, data_length,
data_precision, data_scale, nullable
from all_tab_columns
where table_name = 'employees'
order by column_name
也许where子句中的比较区分大小写。
试试这个:
select column_name, data_type, data_length,
data_precision, data_scale, nullable
from all_tab_columns
where lower(table_name) = 'employees'
order by column_name
答案 1 :(得分:0)
您的select department_id where employee_id = :table_name;
错了。
该表将在from
子句中指定。
由于