在代码块下面抛出错误..
DECLARE
TYPE dbadaptor IS VARRAY (9) OF VARCHAR2(20);
min_date DATE;
max_date DATE;
db dbadaptor := dbadaptor('wsf_ds_11765_c', 'wsf_ds_11750_c',
'wsf_ds_11756_c', 'wsf_ds_11759_c',
'wsf_ds_11706_c', 'wsf_ds_11709_c',
'wsf_ds_11751_c', 'wsf_ds_11708_c',
'wsf_ds_11762_c');
BEGIN
FOR i IN 1..9 LOOP
SELECT
from_sf_date(max(start_time)),
from_sf_date(min(start_time))
INTO max_date, min_date
FROM db(i);
END LOOP;
END;
我在第8行“PL / SQL:ORA-00933:SQL命令未正确结束”时收到错误,这是因为db(i).... 你能帮帮我吗
答案 0 :(得分:2)
您的代码存在各种问题:
table
函数。 start_time
,但您没有定义此类列。您拥有的唯一列是具有未定义名称的字符串(将引用为column_value
)。下面是一个示例,演示问题1和2中引用的技术(我缺乏足够的信息来提供问题3的解决方案)。
CREATE TYPE dbadaptor AS VARRAY(9) OF VARCHAR2(20);
DECLARE
min_date DATE;
max_date DATE;
db dbadaptor
:= dbadaptor('wsf_ds_11765_c',
'wsf_ds_11750_c',
'wsf_ds_11756_c',
'wsf_ds_11759_c',
'wsf_ds_11706_c',
'wsf_ds_11709_c',
'wsf_ds_11751_c',
'wsf_ds_11708_c',
'wsf_ds_11762_c');
BEGIN
FOR db_value IN (SELECT COLUMN_VALUE AS CV FROM TABLE(db)) LOOP
DBMS_OUTPUT.put_line(db_value.CV);
END LOOP;
END;
/
然而,这是循环数组的低效方法。如果这就是你所做的一切,你最好只使用一个循环:
DECLARE
type dbadaptor is VARRAY(9) OF VARCHAR2(20);
min_date DATE;
max_date DATE;
db dbadaptor
:= dbadaptor('wsf_ds_11765_c',
'wsf_ds_11750_c',
'wsf_ds_11756_c',
'wsf_ds_11759_c',
'wsf_ds_11706_c',
'wsf_ds_11709_c',
'wsf_ds_11751_c',
'wsf_ds_11708_c',
'wsf_ds_11762_c');
i number;
BEGIN
FOR i IN 1..9 LOOP
DBMS_OUTPUT.put_line(db(i));
END LOOP;
END;
/