我遇到了施工动态查询问题。
Error report -
ORA-06550: line 10, column 25:
PLS-00306: wrong number or types of arguments in call to '||'
ORA-06550: line 10, column 1:
PL/SQL: Statement ignored
ORA-06550: line 16, column 17:
PLS-00306: wrong number or types of arguments in call to '||'
ORA-06550: line 16, column 1:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
declare
v_column_order View_Columns.Column_order%TYPE;
column_order_sql_qry VARCHAR2 (150);
insert_query Varchar2(300);
CURSOR view_ids IS select view_id from Views where template_name in ('mydhli_containers', 'demo_mydhli_containers', 'mydhli_shipments', 'demo_mydhli_shipments', 'mydhli_shipments_gogreen', 'demo_mydhli_shipments_gogreen');
begin
FOR v_view_id IN view_ids LOOP
column_order_sql_qry := 'select max(column_order) from view_columns vc inner join views vi on vc.view_id = vi.view_id where vc.view_id = ' || v_view_id;
EXECUTE IMMEDIATE column_order_sql_qry into v_column_order;
v_column_order := v_column_order + 1;
insert_query := 'insert into VIEW_COLUMNS(ID, COLUMN_ORDER, NAME, VIEW_ID) VALUES (view_column_id_seq.nextval, ' || v_column_order || ',''commercialInvoiceNumbers'',' || v_view_id || ')';
EXECUTE IMMEDIATE insert_query;
END LOOP;
end;
字符串
我不知道我是否应该将数字参数转换为char或该怎么做。看来,nocmal concatination与||不起作用,谢谢你的帮助
2条答案
按热度按时间1cosmwyk1#
v_view_id
是行变量。您需要指定要使用光标返回的字段中的哪个字段。所以就像字符串
omtl5h9j2#
我没有你的表,所以我创建了虚拟的,只是为了使代码编译。
字符串
光标
FOR
循环:型
测试结果:
型