简体   繁体   English

PL / SQL-连接时始终收到此错误:PLS-00306:调用'||'时参数或参数类型错误

[英]PL/SQL - I keep getting this error when concatenating: PLS-00306: wrong number or types of arguments in call to '||'

I had another thread to get a different problem fixed and now I am stuck on another, seemingly simple, error. 我有另一个线程来解决其他问题,现在我陷入了另一个看似简单的错误。 My cod is as follows: 我的鳕鱼如下:

declare
    update_count integer := 0;
    prjt_name varchar2(100) not null := '01213264B';
    cursor my_cur is (select table_name from all_tab_columns@adhoc_pos15 where column_name = 'PROJECT_ID' and owner = 'SANDBOX');
    tableName  my_cur%rowtype;
begin
    for tableName in my_cur
    loop
        update_count := 0;
      Execute immediate
        'select count(t.project_id) as "CNT" from sandbox.'
        || tableName
        || '@adhoc_pos15 t'
        || 'where  t.project_id = (select project_id from sandbox.sb_project@adhoc_pos15 where project_name = upper('
        || prjt_name
        || '))'
      into update_count;
      if update_count = 0 then
       execute immediate
            'DELETE FROM my_cur where table_name = '
            || tableName;
      end if;
    end loop;
end;

My error message is 我的错误讯息是

ORA-06550: line 11, column 8:
PLS-00306: wrong number or types of arguments in call to '||'
ORA-06550: line 10, column 6:
PL/SQL: Statement ignored
ORA-06550: line 20, column 8:
PLS-00306: wrong number or types of arguments in call to '||'
ORA-06550: line 19, column 6:
PL/SQL: Statement ignored

If you are interested. 如果你感兴趣。 I will past a link to the previous error that I was getting below. 我将链接到下面的先前错误的链接。 You can see what the code originally looked like. 您可以看到代码的原始外观。

Encountered 'Loop' Error 遇到“循环”错误

Edit 1: Per Valli's suggestions. 编辑1:Per Valli的建议。 I have updated my coding and get the error missing expression at line 15. 我已经更新了代码,并在第15行得到了错误缺少表达式。

declare
    query varchar2(10000);
    update_count integer := 0;
    prjt_name varchar2(100) := '01213264B';
    cursor my_cur is (select table_name from all_tab_columns@db2where column_name = 'PROJECT_ID' and owner = 'SANDBOX');
    tableName  varchar2(100);
begin
  open my_cur;
    loop
    fetch my_cur into tableName;
    exit when my_cur%NOTFOUND;
        update_count := 0;
        execute immediate
        'select count(project_id) as "CNT" from sandbox.' || tableName || '@db2  '
        || ' where project_id = (select project_id from sandbox.sb_project@db2 where project_name = ''' || prjt_name || ''' ) '
        into update_count;
    if update_count > 0 then
     dbms_output.put_line (tableName);
    end if;
   end loop;
  close my_cur;
end;

I was missing an "=" symbol. 我缺少一个“ =”符号。 This now runs. 现在运行。 I get a few results than the error message 我得到的结果比错误消息还多

ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04040: file ext_qsp_benefit.dat in DATA_DIR not found
ORA-02063: preceding 3 lines from ADHOC_POS15
ORA-06512: at line 13

Final Edit: Success! 最终编辑:成功! Apparently I cannot query certain tables. 显然我无法查询某些表。 So I just took those tables out. 所以我只是把那些桌子拿出来了。

Final coding is: 最终编码为:

declare
  query varchar2(10000);
  update_count integer := 0;
  prjt_name varchar2(100) := '01213264B';
  cursor my_cur is (select table_name from all_tab_columns@db2 where column_name = 'PROJECT_ID' and owner = 'SANDBOX' and table_name in ('X') );
  tableName  varchar2(100);
begin
  open my_cur;
    loop
    fetch my_cur into tableName;
    exit when my_cur%NOTFOUND;
        update_count := 0;
        execute immediate
        'select count(project_id) as "CNT" from sandbox.' || tableName || '@db2  '
        || ' where project_id = (select project_id from sandbox.sb_project@db2 where project_name = ''' || prjt_name || ''' ) '
        into update_count;
    if update_count > 0 then
      dbms_output.put_line (tableName);
    end if;
  end loop;
  close my_cur;
end;

This doesn't do exactly what I wanted. 这并不能完全满足我的要求。 It sends the results to dbms_output. 它将结果发送到dbms_output。 But It is a start! 但这是一个开始! Thanks everyone for you help! 谢谢大家的帮助!

    declare
        update_count integer := 0;
        prjt_name varchar2(100) := '01213264B';
         tablename  varchar2(100);

        cursor my_cur is 
             select table_name 
                from all_tab_columns@adhoc_pos15 
               where column_name = 'PROJECT_ID' and owner = 'SANDBOX';
    begin
        OPEN my_cur;
        LOOP
         FETCH  my_cur into tableName;
           EXIT WHEN my_cur%NOTFOUND;
            update_count := 0;
             Execute immediate
                 'select count(t.project_id) as "CNT" from sandbox.' 
                || tableName
                || '@adhoc_pos15 t'
                || ' where  t.project_id in (select project_id from sandbox.sb_project@adhoc_pos15 where project_name = upper('
                || prjt_name
                || '))' 
                INTO update_count;
          if update_count = 0 then
           execute immediate
                'DELETE FROM my_cur where table_name = '
                || tablename;
          end if;
        end loop;
   CLOSE my_cur;
    end;

You have missed a concatenation at last. 您最后错过了串联。 Some syntax errors too 也有一些语法错误

Note:- 注意:-

Why do you need a subquery here? 为什么在这里需要子查询?

where  t.project_id in (select project_id from sandbox.sb_project@adhoc_pos15 where project_name = upper('
            || prjt_name

You can replace by 您可以替换为

where t.project_name = prjt_name

One thing that looks wrong is that prjt_name is a string, but you pass it as a number in your query. 看起来不对的一件事是prjt_name是字符串,但是您在查询中将其作为数字传递。 So here is what I would change: 因此,这就是我要更改的内容:

    || 'where  t.project_id = (select project_id from sandbox.sb_project@adhoc_pos15 where project_name = upper('''
    || prjt_name
    || '''))'

This basically adds ' ' around the string value. 这基本上在字符串值' '周围添加了' '

Then, since you get 2 errors from your execution, there must be an issue with the tableName. 然后,由于执行过程中出现2个错误,因此tableName必须存在问题。 I rather use implicit cursor, but you should try to access the content of the cursor, like below: 我宁愿使用隐式游标,但您应该尝试访问游标的内容,如下所示:

    'select count(t.project_id) as "CNT" from sandbox.'
    || tableName.table_name
    || '@adhoc_pos15 t'
    || 'where  t.project_id = (select project_id from sandbox.sb_project@adhoc_pos15 where project_name = upper('''
    || prjt_name
    || '''))'

And you must remove that delete you do from your cursor... this looks completely wrong. 而且您必须从光标中删除该delete操作……这看起来是完全错误的。 The loop simply moves to the next records 循环仅移至下一条记录

Hope this helps. 希望这可以帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误 PLS-00306:在调用“P_CHECKAVGRATE”PL/SQL 时 arguments 的数量或类型错误:语句被忽略 - Error PLS-00306: wrong number or types of arguments in call to 'P_CHECKAVGRATE' PL/SQL: Statement ignored 如何更正 '' PLS-00306:在调用 '' 时 arguments 的错误编号或类型 - How to correct '' PLS-00306: wrong number or types of arguments in call to '' Oracle过程调用导致“ PLS-00306:调用中参数的数量或类型错误” - Oracle procedure call results in “PLS-00306: wrong number or types of arguments in call” PLS-00306:调用现有存储过程时参数的数量或类型错误 - PLS-00306: wrong number or types of arguments in call to existing stored procedure 功能:PLS-00306:调用'WORK_DAYS'时参数的数量或类型错误 - Function : PLS-00306: wrong number or types of arguments in call to 'WORK_DAYS' PLS-00306:错误的参数数量或类型提示具有“可变”参数数量的函数的提示 - PLS-00306: wrong number or types of arguments tips on function with “variable” number of arguments 将PHP数组传递给Oracle存储过程(PLS-00306:错误数量或参数类型) - passing PHP array to Oracle Stored Proc (PLS-00306: wrong number or types of arguments) PLS-00306:从PL / SQL块调用函数时 - PLS-00306: when calling a function from a PL/SQL block 对过程的调用中参数的数量或类型错误(PLS00306) - wrong number or types of arguments in call to procedure (PLS00306) 如何修复 PLS-00306 错误 inpl/sql? - How can i fix a PLS-00306 ERROR inpl/sql?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM