Exception error  in PL/SQL block

Hi,
do the following conditions in a PL/SQL block cause an exception error to occur ?
A- Select statement does not return a row.
B- Select statement returns more than one row.
Thank you.

If you're talking about SELECT INTO then yes:
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
Connected as cmza
SQL> set serveroutput on
SQL>
SQL> declare
  2    v_text varchar2(4000);
  3  begin
  4    -- question 1
  5    select banner
  6      into v_text
  7      from v$version;
  8  end;
  9  /
declare
  v_text varchar2(4000);
begin
  -- question 1
  select banner
    into v_text
    from v$version;
end;
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at line 6
SQL> declare
  2    v_text varchar2(4000);
  3  begin
  4    -- question 2
  5    select banner
  6      into v_text
  7      from v$version
  8     where 1 = 2;
  9  end;
10  /
declare
  v_text varchar2(4000);
begin
  -- question 2
  select banner
    into v_text
    from v$version
   where 1 = 2;
end;
ORA-01403: no data found
ORA-06512: at line 6
SQL>

Similar Messages

  • Error in PL/SQL Block of Trigger

    Hi all,
    I have written a trigger whose PL/SQL block contains a simple select statment among many other statements.
    Now I find that, if the select statement returns no rows the trigger does not continue its operation further and aborts there itself. And if the select statement returns some rows, then it works fine.
    I tried to execute a simplified PL/SQL block of the trigger in SQL*Plus and following were the results:
    declare
    tempdate date;
    begin
    select trdt into tempdate from inv_trans;
    if sql%notfound then
    null;
    end if;
    end;
    When no data is present in inv_trans table, the result was:
    declare
    ERROR at line 1:
    ORA-01403: no data found
    ORA-06512: at line 4
    And when the table inv_trans had data, the result was:
    PL/SQL procedure successfully completed.
    Why is the piece of code flashing an error when I have already given a treatment if no data is found.
    Why is it taking "No Data in table" as an abnormal condition and not normal?
    THanks in advance
    Warm Regards
    Manu

    In your case you have to use a cursor:
    declare
      cursor c_cur is
        select trdt from inv_trans;
      r_cur   c_cur%rowtype;
    begin
      open c_cur;
      fetch c_cur into r_cur;
      if c_cur%notfound then
    [pre]                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Error executing pl sql block

    Hii All,
    I'm facing the following error
    ERROR at line 66:
    ORA-06550: line 66, column 20:
    PLS-00306: wrong number or types of arguments in call to '||'
    ORA-06550: line 66, column 11:
    PL/SQL: Statement ignoredVersion Details
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE    11.1.0.7.0      Production
    TNS for Solaris: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - ProductionMy pl sql block
    Declare
        p_table_name  clob := 'CP_CA_DTLS' ;
        Type t_column_name_tab is table of varchar2(4000)
        index by binary_integer;
        l_table_tab      t_column_name_tab;
        l_file_name constant varchar2(5000) := 'column_counts';
        l_count      number;
        l_tab_count    number;
        l_str    varchar2(32000);
        l_tbl_str  varchar2(32000);
      Cursor c_table_columns(c_table_name user_tables.table_name%type)
      Is
        Select  column_name
        from  user_tab_cols
        where  table_name = upper(c_table_name);
      Type t_table_columns is table of c_table_columns%rowtype;
       l_column_name_tab  t_table_columns;
    Begin
        --Splitting comma seperated data
        Select  regexp_substr(p_table_name,'[^,]+{1}',1,level)
        bulk collect into  l_table_tab
        from  dual
        connect by level <= length(regexp_replace(p_table_name,'[^,]*'))+1;
        for k in 1..l_table_tab.count
        loop
         -- dbg_print(l_file_name,'***'||l_table_tab(k)||'***');   
          Begin
              l_tbl_str := 'Select count(*) from '||l_table_tab(k);
              execute immediate l_tbl_str into l_tab_count;
            --  dbg_print(l_file_name,'Overall Count of table '||l_table_tab(k)||' is '||l_tab_count);   
          End;
       -- dbg_print(l_file_name,'Column Name '||','||'Count'); 
        Open c_table_columns(l_table_tab(k));
        loop
          Fetch c_table_columns bulk collect into l_column_name_tab limit 50;
          exit when l_column_name_tab.count = 0;
          dbms_output.put_line('l_column_name_tab.count count is : '||l_column_name_tab.count);
            for i in 1..l_column_name_tab.count
            loop
            Begin
              l_str := 'Select count(*) ' ;
              l_str := l_str||' from  '||l_table_tab(k) ;
              l_str := l_str||' where '||l_column_name_tab(i);
              l_str := l_str||' is null'  ;
              Execute Immediate l_str into l_count;
            End;
            --dbg_print(l_file_name,l_column_name_tab(i)||','||l_count);
            end loop;
        end loop;
        Close c_table_columns;
      end loop;
          dbms_output.put_line('l_column_name_tab.count count is : '||l_column_name_tab.count);
    End;Even I'm not able to print l_column_name_tab(i) using dbms_output.
    (Later I came to know that this information can be achieved using user_tab_col_statistics table)
    But would like to know whats wrong with my code.???
    Plz help me .
    Edited by: 792353 on Dec 3, 2010 1:26 AM

    Hii RDB,
    when I comment this part of code
      --   l_str := l_str||' where '||l_column_name_tab(i);
           --   l_str := l_str||' is null'  ;
    SQL> Declare
      2 
      3 
      4      p_table_name  clob := 'CP_CA_DTLS' ;
      5 
      6      Type t_column_name_tab is table of varchar2(4000)
      7      index by binary_integer;
      8     
      9      l_table_tab      t_column_name_tab;
    10    
    11 
    12 
    13 
    14      l_file_name constant varchar2(5000) := 'column_counts';
    15      l_count      number;
    16      l_tab_count    number;
    17      l_str    varchar2(32000);
    18      l_tbl_str  varchar2(32000);
    19   
    20    Cursor c_table_columns(c_table_name user_tables.table_name%type)
    21    Is
    22      Select  column_name
    23      from  user_tab_cols
    24      where  table_name = upper(c_table_name);
    25     
    26     
    27    Type t_table_columns is table of c_table_columns%rowtype;
    28   
    29   
    30     l_column_name_tab  t_table_columns;
    31   
    32  Begin
    33      --Splitting comma seperated data
    34     
    35      Select  regexp_substr(p_table_name,'[^,]+{1}',1,level)
    36      bulk collect into  l_table_tab
    37      from  dual
    38      connect by level <= length(regexp_replace(p_table_name,'[^,]*'))+1;
    39     
    40      for k in 1..l_table_tab.count
    41      loop
    42       -- dbg_print(l_file_name,'***'||l_table_tab(k)||'***');   
    43       
    44        Begin
    45            l_tbl_str := 'Select count(*) from '||l_table_tab(k);
    46       
    47            execute immediate l_tbl_str into l_tab_count;
    48       
    49          --  dbg_print(l_file_name,'Overall Count of table '||l_table_tab(k)||' is '||l_tab_coun
    t);   
    50 
    51        End;
    52 
    53     -- dbg_print(l_file_name,'Column Name '||','||'Count'); 
    54 
    55      Open c_table_columns(l_table_tab(k));
    56      loop
    57        Fetch c_table_columns bulk collect into l_column_name_tab limit 50;
    58        exit when l_column_name_tab.count = 0;
    59        dbms_output.put_line('l_column_name_tab.count count is : '||l_column_name_tab.count);
    60          for i in 1..l_column_name_tab.count
    61          loop
    62          
    63          Begin
    64            l_str := 'Select count(*) ' ;
    65            l_str := l_str||' from  '||l_table_tab(k) ;
    66         --   l_str := l_str||' where '||l_column_name_tab(i);
    67         --   l_str := l_str||' is null'  ;
    68         
    69            Execute Immediate l_str into l_count;
    70 
    71          End;
    72         
    73          --dbg_print(l_file_name,l_column_name_tab(i)||','||l_count);
    74       
    75          end loop;
    76      end loop;
    77      Close c_table_columns;
    78    end loop;
    79 
    80        dbms_output.put_line('l_column_name_tab.count count is : '||l_column_name_tab.count);
    81  End;
    82  /
    PL/SQL procedure successfully completed.its running fine so the problem is l_column_name_tab(i) !!!!!!
    and there is nothing wrong with l_table_tab(k) and its declaration.
    Edited by: 792353 on Dec 3, 2010 2:17 AM

  • Error with PL/SQL block

    Hi
    If I run PL/SQL block
    DECLARE
    CURSOR C1 is SELECT CLM_CASE_NO FROM CLAIM_OBJECT.CLM_INVLVD_PRTY_T where CLM_CASE_NO=XXXX;
    BEGIN
    FOR X in C1 loop
    INSERT INTO POSTL_ADDRS_ARCHIVE P (SELECT A.* FROM CLAIM_OBJECT.POSTL_ADDRS A, CLAIM_OBJECT.CLM_INVLVD_PRTY_T C WHERE
    C.CLNT_NO = A.CLNT_NO AND C.CURR_ROW_IND='A' AND C.CLM_CASE_NO =X.CLM_CASE_NO );
    end loop;
    end;
    there is no error with the above block
    If I remove where clause in cursor and run block
    DECLARE
    CURSOR C1 is SELECT CLM_CASE_NO FROM CLAIM_OBJECT.CLM_INVLVD_PRTY_T;
    BEGIN
    FOR X in C1 loop
    INSERT INTO POSTL_ADDRS_ARCHIVE P (SELECT A.* FROM CLAIM_OBJECT.POSTL_ADDRS A, CLAIM_OBJECT.CLM_INVLVD_PRTY_T C WHERE
    C.CLNT_NO = A.CLNT_NO AND C.CURR_ROW_IND='A' AND C.CLM_CASE_NO =X.CLM_CASE_NO );
    end loop;
    end;
    ERROR at line 1:
    ORA-01013: user requested cancel of current operation
    ORA-06512: at line 12
    I searched for ORA-06512
    Cause:
         This error message indicates the line number in the PLSQL code that the error resulted.
    SELECT CLM_CASE_NO FROM CLAIM_OBJECT.CLM_INVLVD_PRTY_T has over 800,672 records.
    SELECT CLM_CASE_NO FROM CLAIM_OBJECT.CLM_INVLVD_PRTY_T where CLM_CASE_NO=XXXX; has 2 records.
    I am not not understanding why block 2 is throwing error (with no where clause in cursor)
    Any help will be greatly appreciated
    Thanks in advance

    As the error message indicates clearly the process was cancelled as you pressed CTRL+C. And yes you can’t see any data you insert in one session from other session until it gets committed. And as others have mentioned row by row operation is very expensive think about revising your approach.
    Instead of having a cursor why don’t you join it directly in you select in the insert statement and try?
    Thanks,
    Karthick.
    Message was edited by:
    karthick_arp

  • Error in pl/sql  block with parameters

    Hi,
    I have the following code which works in normal cursor forloops,
    Can some one please check how to achive the same functionality using bulk insert.( i want to use parameterised cursor)
    step 1 ---working
    declare
    CURSOR DEPT_inst
    is
    select d.deptno
    from dept d where d.dname='RESEARCH';
    CURSOR emp_inst (p_dept in number)
             IS
         SELECT e.empno ,
                e.ename  ,
                e.deptno
           from emp1 e
          where e.deptno = p_dept;
    begin
    for i in dept_inst loop
       delete from emp2 where deptno=i.deptno;
       for j in emp_inst(i.deptno) loop
          INSERT INTO emp2(empno,
                               ename,
                               deptno )
                       VALUES (j.empno,
                               j.ename,
                              j.deptno
    end loop;
    end loop;
    commit;
    exception
    when others then
    dbms_output.put_line( 'exception in err insert'||SQLERRM);
    ROLLBACK;
    end;
    step - 2  compilation error
    declare
    CURSOR DEPT_inst
    is
    select d.deptno
    from dept d where dname='RESEARCH';
    CURSOR emp_inst (p_dept in number)
             IS
         SELECT e.empno ,
                e.ename  ,
                e.deptno
           from emp1 e
          where e.dept = p_dept;
    TYPE id_tab_dep_1 IS TABLE OF dept_inst%ROWTYPE
                INDEX BY PLS_INTEGER;
         t_id_dep_1       id_tab_dep_1;
        TYPE id_tab_det_1 IS TABLE OF emp_inst(t_id_det_1(indxi).deptno)%ROWTYPE
                INDEX BY PLS_INTEGER;
         t_id_det_1       id_tab_det_1;
           BEGIN
             OPEN dept_inst;
               FETCH dept_inst
               LOOP
               BULK COLLECT into t_id_dep_1 LIMIT 100;
               EXIT WHEN t_id_dep_1.count <= 0;
             FOR indxi IN t_id_det_1.FIRST  .. t_id_det_1.LAST LOOP
                   delete from emp2 where deptno=t_id_det_1(indxi).deptno;
             OPEN emp_inst;
             LOOP
             FETCH emp_inst(t_id_det_1(indxi).deptno)
                 BULK COLLECT INTO t_id_det_1  limit 100;
                 EXIT WHEN t_id_det_1.count <= 0;
             FOR indxj IN t_id_det_1.FIRST  .. t_id_det_1.LAST LOOP
                     INSERT INTO emp2(empno,
                               ename,
                               deptno )
                       VALUES (t_id_det_1(indxj).empno,
                               t_id_det_1(indxj).ename,
                              t_id_det_1(indxj).deptno
              END LOOP;
              END LOOP;
              CLOSE emp_inst;
              END LOOP;
              END LOOP;
              CLOSE dept_inst;
            EXCEPTION
                   WHEN OTHERS
                   THEN
                      dbms_output.put_line( 'exception in err insert' || SQLCODE ||' ' ||SQLERRM);
                      ROLLBACK;
                      RETURN;
            END;
    I am getting below error
        TYPE id_tab_det_1 IS TABLE OF emp_inst(t_id_det_1(indxi).deptno)%ROWTYPE
    ERROR at line 16:
    ORA-06550: line 16, column 69:
    PLS-00103: Encountered the symbol "%" when expecting one of the following:
    ; not null alter index characterEdited by: user11289444 on Dec 26, 2010 3:58 AM

    hoek wrote:
    I was referring to OP's second Bulk DML, the insert part.
    You cannot reference individual columns there.Then you have to be even more specific. You cannot reference individual columns there unless you are on 11g:
    SQL> select * from v$version
      2  /
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL> declare
      2    cursor dept_inst
      3    is
      4    select d.deptno
      5    from   dept d
      6    where  d.dname = 'RESEARCH';
      7    --
      8    cursor emp_inst(b_deptno in number)
      9    is
    10    select e.empno
    11    ,      e.ename
    12    ,      e.deptno
    13    from   emp1 e
    14    where  e.deptno = b_deptno;
    15    --
    16    type depttype is table of number index by binary_integer;
    17    depttab depttype;
    18    type emptype is table of emp_inst%rowtype /*this will not work*/ index by binary_integer;
    19    emptab emptype;
    20    --
    21  begin
    22    --
    23    open dept_inst;
    24    loop
    25     
    26      fetch dept_inst bulk collect into depttab limit 100;
    27      forall i in depttab.first..depttab.last
    28        delete from emp2 where deptno = depttab(i);
    29         --
    30        dbms_output.put_line(sql%rowcount||' records were deleted from table emp2');
    31        --
    32  --      open emp_inst(depttab(i));
    33        open emp_inst(depttab(1));
    34        loop
    35          fetch emp_inst bulk collect into emptab limit 100;
    36          forall j in emptab.first..emptab.last
    37            insert into emp2 values(emptab(j).empno,emptab(j).ename,emptab(j).deptno);
    38          --
    39          exit when emp_inst%notfound;
    40          --
    41        end loop;
    42        exit when dept_inst%notfound;
    43        close dept_inst;         
    44      --
    45    end loop;
    46    close dept_inst;
    47  end;
    48  /
              insert into emp2 values(emptab(j).empno,emptab(j).ename,emptab(j).deptno);
    ERROR at line 37:
    ORA-06550: line 37, column 35:
    PLS-00436: implementation restriction: cannot reference fields of BULK In-BIND
    table of records
    ORA-06550: line 37, column 35:
    PLS-00382: expression is of wrong type
    ORA-06550: line 37, column 51:
    PLS-00436: implementation restriction: cannot reference fields of BULK In-BIND
    table of records
    ORA-06550: line 37, column 51:
    PLS-00382: expression is of wrong type
    ORA-06550: line 37, column 67:
    PLS-00436: implementation restriction: cannot reference fields of BULK In-BIND
    table of records
    ORA-06550: line 37, column 67:
    PLS-00382: expression is of wrong type
    ORA-06550: line 37, column 35:
    PL/SQL: ORA-22806: not an object or REF
    ORA-06550: line 37, column 11:
    PL/SQL: SQL Statement ignored
    SQL> select * from v$version
      2  /
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0      Production
    TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    SQL> declare
      2    cursor dept_inst
      3    is
      4    select d.deptno
      5    from   dept d
      6    where  d.dname = 'RESEARCH';
      7    --
      8    cursor emp_inst(b_deptno in number)
      9    is
    10    select e.empno
    11    ,      e.ename
    12    ,      e.deptno
    13    from   emp1 e
    14    where  e.deptno = b_deptno;
    15    --
    16    type depttype is table of number index by binary_integer;
    17    depttab depttype;
    18    type emptype is table of emp_inst%rowtype /*this will not work*/ index by binary_integer;
    19    emptab emptype;
    20    --
    21  begin
    22    --
    23    open dept_inst;
    24    loop
    25     
    26      fetch dept_inst bulk collect into depttab limit 100;
    27      forall i in depttab.first..depttab.last
    28        delete from emp2 where deptno = depttab(i);
    29         --
    30        dbms_output.put_line(sql%rowcount||' records were deleted from table emp2');
    31        --
    32  --      open emp_inst(depttab(i));
    33        open emp_inst(depttab(1));
    34        loop
    35          fetch emp_inst bulk collect into emptab limit 100;
    36          forall j in emptab.first..emptab.last
    37            insert into emp2 values(emptab(j).empno,emptab(j).ename,emptab(j).deptno);
    38          --
    39          exit when emp_inst%notfound;
    40          --
    41        end loop;
    42        exit when dept_inst%notfound;
    43        close dept_inst;         
    44      --
    45    end loop;
    46    close dept_inst;
    47  end;
    48  /
    PL/SQL procedure successfully completed.
    SQL> SY.

  • Error in PL/SQL block..

    Hi Im facing an error in the following code.. Cant trace it out.
    /* Formatted on 2009/10/21 22:09 (Formatter Plus v4.8.8) */
    DECLARE
       latest_task_id    NUMBER;
       task_name_em7      VARCHAR2 (50);
       select_flag_em7    NUMBER        := 1;
       ds_count_em7       NUMBER;
       stateid           NUMBER;
       ds_id_em7          NUMBER;
       server_id_em7      NUMBER;
    BEGIN
       SELECT server_id
         INTO server_id_em7
         FROM ems_servers
        WHERE server_name = :P82_EM7_COLLECTOR;
       FOR i IN 1 .. apex_application.g_f01.COUNT
       LOOP
          SELECT COUNT (*)
            INTO ds_count_em7
            FROM delivered_service_mapping
           WHERE equipment_id = apex_application.g_f01(i)
             AND termination_id IS NULL;
          IF ds_count_em7 = 0
          THEN
             MERGE INTO provision_em7 pem7
                USING (SELECT apex_application.g_f01(i) apex_equip_id_em7
                         FROM DUAL) a
                ON (    a.apex_equip_id_em7 = pem7.equipment_id
                    AND pem7.termination_id IS NULL)
                WHEN MATCHED THEN
                   UPDATE
                      SET "PROVISION_STATE_ID" = 2, "SERVER_ID" = server_id_em7,
                          "LAST_PROVISION_BY" = :app_user
                      WHERE provision_state_id IN (1, 4, 10, 5)
                WHEN NOT MATCHED THEN
                   INSERT (EQUIPMENT_ID, PROVISION_STATE_ID, ERROR_CODE,
                           SERVER_ID, LASTMODIFIED_BY, LAST_MODIFIED_ON,
                           REMARKS, COLLECTOR_IP, COLLECTION_STATE,CURRENT_STATE)
                   VALUES (a.apex_equip_id_em7,2,NULL,server_id_em7,:APP_USER,SYSDATE,NULL,NULL,NULL,NULL                     NULL, , , 'remarks_by_navarose for iv',
             SELECT delivered_service_id
               INTO ds_id_em7
               FROM delivered_service
              WHERE delivered_service_name = apex_application.g_f02(i);
             INSERT INTO delivered_service_mapping
                         (ID, customer_id,
                          equipment_id, termination_id, delivered_service_id,
                          last_modified_by, last_modified_on
                  VALUES (delivered_service_seq.NEXTVAL, NULL,
                          apex_application.g_f01(i), NULL, ds_id_em7,
                          :APP_USER, SYSDATE
             select_flag_em7 := 0;
          ELSE
             UPDATE delivered_service_mapping SET delivered_service_id = apex_application.g_f01(i),
             last_modified_by = :APP_USER, last_modified_on = SYSDATE;  
             select_flag_em7 := 0;
          END IF;
       END LOOP;
       IF select_flag_em7 = 0
       THEN
          IF P82_CHECK_TASK_NAME_EM7 = 1
          THEN
             IF :P82_CHECK_TASK_NAME_EM7 IS NULL
             THEN
                task_name_em7 :=
                      :app_user
                   || '_PROVISIONING PERIODIC EM7_'
                   || TO_CHAR (SYSDATE, 'YYYYMMDD_HHMISS');
                INSERT INTO tasks
                            (task_id, task_name, created_by,
                             created_on, task_action, task_state_id, server_id
                     VALUES (task_id_seq.NEXTVAL, task_name_em7, :app_user,
                             SYSDATE, 14, 1, server_id_em7
             ELSE
                INSERT INTO tasks
                            (task_id, task_name, created_by,
                             created_on, task_action, task_state_id, server_id
                     VALUES (task_id_seq.NEXTVAL, :P82_TASK_NAME_EM7, :app_user,
                             SYSDATE, 14, 1, server_id_em7
             END IF;
             SELECT MAX (task_id)
               INTO latest_task_id
               FROM tasks
              WHERE created_by = :APP_USER;
             FOR i IN 1 .. apex_application.g_f01.COUNT
             LOOP
                INSERT INTO task_details
                            (task_details_id,
                             equipment_id, task_id
                     VALUES (task_detail_seq.NEXTVAL,
                             apex_application.g_f01 (i), latest_task_id
             END LOOP;
          END IF;
       END IF;
    END;The errror is
    1 error has occurred
    ORA-06550: line 42, column 123: PL/SQL: ORA-00917: missing comma ORA-06550: line 28, column 10: PL/SQL: SQL Statement ignored

    Hi,
    This line:
    VALUES (a.apex_equip_id_em7,2,NULL,server_id_em7,:APP_USER,SYSDATE,NULL,NULL,NULL,NULL                     NULL, , , 'remarks_by_navarose for iv',needs a comma between the two nulls - there's just a huge gap instead!
    Andy

  • Why sys_extract_utc(sysdate) never causes error in pl/sql block?

    Oracle 11.2
    I cannot use
    SELECT sys_extract_utc(sysdate) FROM DUAL But I can use
    v := sys_extract_utc(sysdate)in a procedure or a trigger without causing any compile or run-time error.
    In my opinion, the return value of function sysdate doesn't contain any timezone info, so it should not be able to be used as the parameter of function sys_extract_utc, because it needs timezone info to do the conversion.
    Any clues?
    Thanks in advance.

    Kiran wrote:
    use systimestamp it will contain timezone.I know, what I don't know is why sys_extract_utc(sysdate) can be used in procedure without causing any error. It should cause error, right?

  • No Data Found: Exception in SQL inside PL/SQL block

    Hi Friends
    I am trying to execute an SQL SELECT stmt inside a PL/SQL block. But when i execute the procedure, it gives me No Data Found Exception.
    I know it is because no row is fetched in the query, but the condition of the SELECT query i have specified is being satisfied, i have checked it by running it on the SQL prompt.
    But somehow, it is not running from inside the PL/SQL procedure.Can anybody help me out on this as to why is this happening?? I am giving my code for reference and have Highlighted the Query inside it:
    CREATE OR REPLACE procedure insert_sfdc_account
    as
    --DECLARE
    CURSOR C1 IS
    SELECT customer_code, name1, name2, name3, name4, phone_number, fax, web_address, industry_sector, customer_profile, customer_type,
    address, city, postal_code, country_key, zzcust_type, vat_code
    FROM load_cust_general
    WHERE account_group = 'ZSIT';
    v_cust_cur c1%ROWTYPE;
    -- type sales_tab is table of load_cust_sales_area%rowtype;
    v_sales_area load_cust_sales_area%ROWTYPE;
    -- v_sales_area sales_tab;
         v_salesorg varchar2(10);
         v_sales_district varchar2(10);
         v_salesoff varchar2(10);
         v_custgrp varchar2(10);
         v_salesgrp varchar2(10);
    v_type varchar2(20);
    v_nature varchar2(10);
    v_partner_code varchar2(10);
    v_parent_cust varchar2(20);
    v_credit_blk varchar2(20);
    BEGIN
    open c1;
    loop
    fetch c1 into v_cust_cur;
    exit when c1%NOTFOUND;
    for i in (SELECT customer_code, salesorg from load_cust_partner
    where customer_code = v_cust_cur.customer_code ) LOOP
    dbms_output.put_line(v_cust_cur.customer_code );
                        SELECT partner_code into v_partner_code from load_cust_partner
    where customer_code = i.customer_code and salesorg = i.salesorg and partner_function = 'Z1';
    dbms_output.put_line(v_partner_code||i.customer_code);
    SELECT salesorg, sales_district, salesoff, salesgrp, custgrp INTO v_salesorg, v_sales_district, v_salesoff, v_salesgrp, v_custgrp FROM load_cust_sales_area
              WHERE customer_code = i.customer_code and salesorg = i.salesorg;
                   dbms_output.put_line(v_salesorg||i.salesorg);
                        SELECT parent_customer INTO v_parent_cust from load_cust_hierarchy
    WHERE customer_code = i.customer_code and salesorg = i.salesorg and hierarchy_type = 'G'; dbms_output.put_line(v_parent_cust);
                        SELECT credit_block INTO v_credit_blk from load_cust_company_cod
              WHERE customer_code = i.customer_code;
    dbms_output.put_line(v_credit_blk);
    for j in (SELECT account_group, customer_type from load_cust_general
    where customer_code IN (select customer_code from load_cust_partner
                                  where partner_code = i.customer_code and salesorg = i.salesorg and partner_function = 'ZS'))
                                                      LOOP
    -- exit when j%NOTFOUND;
         dbms_output.put_line(j.account_group);
    if (j.account_group = 'ZDIS') THEN
    v_type := 'DISAC';
              v_nature := '06';
         --     EXIT ;
    else
    v_type := 'SPACC';
    v_nature := '01';
    END IF;
    dbms_output.put_line(v_type||' '||v_nature);
    END LOOP;
    INSERT INTO sfdc_account
              (SAP_ACCOUNT_ID__C, NAME, TYPE, RECORDTYPEID, PARENTID, PHONE, FAX, WEBSITE, OWNERID, MARKETING_DOMAIN__C,
    INDUSTRIAL_SECTOR__C, ABC_CLASSIFICATION__C, NAME_1__C, NAME_2__C, NAME_3__C, NAME_4__C, PAYMENT_STATUS__C,
    CUSTOMER_GROUP__C, ADDRESS_STREET__C, CITY__C, POSTAL_CODE__C, COUNTRY__C, SALES_OFFICE__C, SALESORG__C,
    SALESDISTRICT__C, SALESGROUP__C, NATURE__C, VATCODE__C)
    VALUES((i.customer_code||i.salesorg), (v_cust_cur.Name1||' '||v_cust_cur.name2), ' ', v_type, v_parent_cust,
    v_cust_cur.phone_number, v_cust_cur.fax, v_cust_cur.web_address, v_partner_code, SUBSTR(v_cust_cur.industry_sector,1,2),
    v_cust_cur.industry_sector, v_cust_cur.customer_profile, v_cust_cur.name1, v_cust_cur.name2, v_cust_cur.name3,
    v_cust_cur.name4, v_credit_blk, v_custgrp, v_cust_cur.address, v_cust_cur.city, v_cust_cur.postal_code,
    v_cust_cur.country_key, v_salesoff, v_salesorg, v_sales_district,
    v_salesgrp, v_nature, v_cust_cur.vat_code);
    end loop;
    end loop;
    CLOSE c1;
    -- Delete data from Load Table
    -- EXECUTE IMMEDIATE 'TRUNCATE TABLE load_cust_general';
    /* truncate table load_cust_partner;
    truncate table load_cust_hierarhy;
    truncate table load_cust_sales_area;
    truncate table load_cust_company_cod;
    commit;
    exception
    when others then
    raise_application_error( -20001, substr( sqlerrm, 1, 150 ) );
    END;
    Kindly Help.....
    Thanks and Regards

    Create the procedure again and execute it in SQL*Plus environment and paste the output:
    CREATE OR REPLACE procedure insert_sfdc_account
    as
    --DECLARE
    CURSOR C1 IS
    SELECT customer_code, name1, name2, name3, name4, phone_number, fax, web_address, industry_sector, customer_profile, customer_type,
    address, city, postal_code, country_key, zzcust_type, vat_code
    FROM load_cust_general
    WHERE account_group = 'ZSIT';
    v_cust_cur c1%ROWTYPE;
    -- type sales_tab is table of load_cust_sales_area%rowtype;
    v_sales_area load_cust_sales_area%ROWTYPE;
    -- v_sales_area sales_tab;
    v_salesorg varchar2(10);
    v_sales_district varchar2(10);
    v_salesoff varchar2(10);
    v_custgrp varchar2(10);
    v_salesgrp varchar2(10);
    v_type varchar2(20);
    v_nature varchar2(10);
    v_partner_code varchar2(10);
    v_parent_cust varchar2(20);
    v_credit_blk varchar2(20);
    BEGIN
    open c1;
    loop
    fetch c1 into v_cust_cur;
    exit when c1%NOTFOUND;
    for i in (SELECT customer_code, salesorg from load_cust_partner
    where customer_code = v_cust_cur.customer_code ) LOOP
    SELECT partner_code into v_partner_code from load_cust_partner
    where customer_code = i.customer_code and salesorg = i.salesorg and partner_function = 'Z1';
    SELECT salesorg, sales_district, salesoff, salesgrp, custgrp INTO v_salesorg, v_sales_district, v_salesoff, v_salesgrp, v_custgrp FROM load_cust_sales_area
    WHERE customer_code = i.customer_code and salesorg = i.salesorg;
    dbms_output.put_line('Customer_Code : '|| i.customer_code);
    dbms_output.put_line('SalesOrg : '|| i.salesorg);
    SELECT parent_customer INTO v_parent_cust from load_cust_hierarchy
    WHERE customer_code = i.customer_code and salesorg = i.salesorg and hierarchy_type = 'G';
    dbms_output.put_line('Successfully Executed SQL st. Error is somewhere else');
    SELECT credit_block INTO v_credit_blk from load_cust_company_cod
    WHERE customer_code = i.customer_code;
    for j in (SELECT account_group, customer_type from load_cust_general
    where customer_code IN (select customer_code from load_cust_partner
    where partner_code = i.customer_code and salesorg = i.salesorg and partner_function = 'ZS'))
    LOOP
    -- exit when j%NOTFOUND;
    if (j.account_group = 'ZDIS') THEN
    v_type := 'DISAC';
    v_nature := '06';
    -- EXIT ;
    else
    v_type := 'SPACC';
    v_nature := '01';
    END IF;
    END LOOP;
    INSERT INTO sfdc_account
    (SAP_ACCOUNT_ID__C, NAME, TYPE, RECORDTYPEID, PARENTID, PHONE, FAX, WEBSITE, OWNERID, MARKETING_DOMAIN__C,
    INDUSTRIAL_SECTOR__C, ABC_CLASSIFICATION__C, NAME_1__C, NAME_2__C, NAME_3__C, NAME_4__C, PAYMENT_STATUS__C,
    CUSTOMER_GROUP__C, ADDRESS_STREET__C, CITY__C, POSTAL_CODE__C, COUNTRY__C, SALES_OFFICE__C, SALESORG__C,
    SALESDISTRICT__C, SALESGROUP__C, NATURE__C, VATCODE__C)
    VALUES((i.customer_code||i.salesorg), (v_cust_cur.Name1||' '||v_cust_cur.name2), ' ', v_type, v_parent_cust,
    v_cust_cur.phone_number, v_cust_cur.fax, v_cust_cur.web_address, v_partner_code, SUBSTR(v_cust_cur.industry_sector,1,2),
    v_cust_cur.industry_sector, v_cust_cur.customer_profile, v_cust_cur.name1, v_cust_cur.name2, v_cust_cur.name3,
    v_cust_cur.name4, v_credit_blk, v_custgrp, v_cust_cur.address, v_cust_cur.city, v_cust_cur.postal_code,
    v_cust_cur.country_key, v_salesoff, v_salesorg, v_sales_district,
    v_salesgrp, v_nature, v_cust_cur.vat_code);
    end loop;
    end loop;
    CLOSE c1;
    -- Delete data from Load Table
    -- EXECUTE IMMEDIATE 'TRUNCATE TABLE load_cust_general';
    /* truncate table load_cust_partner;
    truncate table load_cust_hierarhy;
    truncate table load_cust_sales_area;
    truncate table load_cust_company_cod;
    commit;
    exception
    when others then
    raise_application_error( -20001, substr( sqlerrm, 1, 150 ) );
    END;
    SQL> set serveroutput on
    SQL> exec insert_sfdc_account;

  • PL/SQL block query error when going to a remote system with 1 parameter.

    Hi,
    I am getting the error:
    Invalid function body condition: ORA-01460: unimplemented or unreasonable conversion requested ORA-02063: preceding line from HANSEN_REMOTE
    The issue appears to result from opening a cursor that is a select statement is in some way accessing records via a dblink and the 'where' clause is has more then one session parameter in it. Here is the smallest pl/sql block that results with an error:
    DECLARE
    CURSOR c_GetPay IS
    SELECT PERSON_ID
    FROM CASH_PERSON@HANSEN_REMOTE
    WHERE LAST_NAME = :P320_HANSEN_LAST_NAME
    AND FIRST_NAME = :P320_HANSEN_FIRST_NAME;
    BEGIN
    OPEN c_GetPay ;
    CLOSE c_GetPay ;
    RETURN TRUE;
    END ;
    If I remove 'AND FIRST_NAME = :P320_HANSEN_FIRST_NAME' from the curser, there is no problem. This block of pl/sql is in a On Load: Before Header
    on a page branch. This issue remains consistent in our 1.6.1.00.02 instance of HTMLDB with an Oracle database version 10.1.0.3.0. This instance is
    a fresh install of the 10g and HTMLDB.
    Does any one have any ideas of why I am getting this error message. I really need to get it resolve soon as we are trying to get an application up by the end of August and there is still alot of coding needing to be done.
    Thanks for the help.
    Lanie

    Scott, I have tried everything that this point except copy the whole table from the remote system.
    Here is a short version of what I have tried...
    -- hard coded condition...timing was not an issue here...it was quick.
    declare
    v_in_PersonId number(9);
    cursor c_GetPay
    IS select PERSON_ID --, first_name, LAST_NAME
         from HANSEN_CONTACT
              where first_name like 'LANIE'
              AND last_name LIKE 'MOORE'
    BEGIN
    OPEN c_GetPay;
    FETCH c_GetPay INTO v_in_PersonId;
    CLOSE c_GetPay;
    RETURN TRUE;
    END           
    -- this is an internal variable set to the string literal...does not as the v function was not called.
    declare
    V_TEST VARCHAR2(150);
    V_TEST2 VARCHAR2(150);
    v_in_PersonId number(9);
    cursor c_GetPay
    IS select PERSON_ID --, first_name, LAST_NAME
         from HANSEN_CONTACT
              where first_name like :V_TEST
              AND last_name LIKE :V_TEST2
    BEGIN
    V_TEST := 'LANIE';
    V_TEST2 := 'MOORE';
    OPEN c_GetPay;
    FETCH c_GetPay INTO v_in_PersonId;
    CLOSE c_GetPay;
    RETURN TRUE;
    END
    -- this has the v function called in the cursor since no matter what I do, I have to call it so I don't get my original error. This takes over a minute to return, and it is using hard coded values...if I use session variables where I place the information from the user, it takes even longer.
    declare
    V_TEST VARCHAR2(150);
    V_TEST2 VARCHAR2(150);
    v_in_PersonId number(9);
    cursor c_GetPay
    IS select PERSON_ID --, first_name, LAST_NAME
         from HANSEN_CONTACT
              where first_name like V(:V_TEST)
              AND last_name LIKE V(:V_TEST2)
    BEGIN
    V_TEST := 'LANIE';
    V_TEST2 := 'MOORE';
    OPEN c_GetPay;
    FETCH c_GetPay INTO v_in_PersonId;
    CLOSE c_GetPay;
    RETURN TRUE;
    END
    It does not appear to be an issue if I am looking at a view going to the remote system or the table it's self. The slowness issue takes place. (In short I have tried replacing HANSEN_CONTACT which is a view with the direct table link of imsv7.contact@HANSEN_REMOTE and that did not solve the timing issue).
    Any ideas?

  • Exception in declarative section to propagating in PL/SQL Block

    Hi All, I have a requirement to send emails to some receipient whenever there is an error in a process. The is working untill the put a wrong database link in the parameter, the cursor is in declarative statement, hence when other exception does not work, create and enclosing block around the initial block so that the exception can propagate to the enclosing block, but this does not work either, please advice. Below is the a brief pseudo code. The bold is the initial block. Please advice.
    DECLARE
    Invalid_table EXCEPTION;
    PRAGMA EXCEPTION_INIT(Invalid_table, -00942);
    BEGIN
    declare
    c_test number;
    cursor c1 is select 1 from tt@sro4link1 --- wrong databaselink sent as a parameter
    where 1 =1;
    */*Because the error is in the cursor select, no email is been sent, that was the reason I put an enclosing block, but the exception is not propagate either */*
    BEGIN
    OPEN C1;
    FETCH C1 into c_test;
    CLOSE C1;
    EXCEPTION
    WHEN OTHERS THEN
    --- Send email
    END; EXCEPTION
    WHEN Invalid_table THEN
    --- send email
    END;
    /

    Ade2 wrote:
    it is not a dynamic sql. Your description is not very clear about what is code and what is pseudo code, but if you are using substitution variables in sqlplus, then that is dynamic SQL.
    sqlplus scans for substitution variables, prompts when needed, replaces the variable (substitutes) with the text input and passes the entire result to the database for validation.
    If the substitution text input results in an invalid PL/SQL block then a compilation error is returned from the database. The PL/SQL cannot be compiled, it never runs, no run time exceptions are possible.
    So you cannot use exceptions to detect errors in values input to substitution variables.
    SQL> declare
      2    l_dummy number;
      3  begin
      4    select 1 into l_dummy from dual;
      5  end;
      6  /
    PL/SQL procedure successfully completed.
    SQL> declare
      2    l_dummy number;
      3  begin
      4    &5
      5  end;
      6  /
    Enter value for 5: select 1 into l_dummy from dual;
    old   4:   &5
    new   4:   select 1 into l_dummy from dual;
    PL/SQL procedure successfully completed.
    SQL> /
    Enter value for 5: this will not compile
    old   4:   &5
    new   4:   this will not compile
      this will not compile
    ERROR at line 4:
    ORA-06550: line 4, column 8:
    PLS-00103: Encountered the symbol "WILL" when expecting one of the following:
    := . ( @ % ;

  • Sql exception occurred during pl/sql upload error in custom integrator

    Hi,
    I have modified custom integrator which was working fine. I have added one column in template and the lov is working fine.
    Issue is that when i upload the file to oracle it showing error as ''sql exception occurred during pl/sql upload".
    I have tried executing the same from back end but it was working fine from back end and inserting properly in interface table.
    Kindly suggest for the issue.
    Regards,
    Gk

    Hi,
    You can get the error message in excel sheet itself by using the following piece of code.
    FND_MESSAGE.CLEAR;
    FND_MESSAGE.SET_NAME ('APPLICATION', 'APPLICATION_MESSAGE_NAME');
    FND_MESSAGE.SET_TOKEN ('ERROR_TOKEN', ERROR MESSAGE);
    FND_MESSAGE.RAISE_ERROR;
    Create an excpetion block and include the above piece of code whilde catching the exception.
    APPLICATION- The applicatio in which you create message
    APPLICATION_MESSAGE_NAME-  The message Name
    ERROR_TOKEN- You must create a token in application message
    ERROR MESSAGE- You can see the  error using SQLERRM.
    Thanks,
    Vinoop

  • PL/SQL Block working fine but same code procedure is giving error.

    Hi Experts,
    I am executing  procedure getting error ORA-27486: insufficient privileges
    If It's PL/SQL block it's creating job classes.
    Both the cases same user.
    CREATE OR REPLACE PROCEDURE JOB_CLASS_PROC
    AS
       V_SQL   VARCHAR2 (4000);
       V_JOB_STEP VARCHAR2 (50);
    BEGIN
    -- Create Job Class if not exist
       BEGIN
       FOR i
          IN (SELECT SNS.OWNER_NAME OWNER_NAME,
                     VDB.NAME
                        SNAME
                FROM SCHEMA_NAMES SNS,
                     V$DATABASE VDB
               WHERE OWNER_NAME NOT IN ('')
                AND (OWNER_NAME || '_JOB_CLASS')
                     NOT IN
                    (SELECT JOB_CLASS_NAME FROM DBA_SCHEDULER_JOB_CLASSES))
       LOOP
          V_SQL :=
                'BEGIN
                  DBMS_SCHEDULER.CREATE_JOB_CLASS
                   job_class_name => ''' || i.owner_name || '_JOB_CLASS'',
                   service           => ''' || i.SNAME || ''',
                   comments       => ''Job class for ' || i.owner_name || '''
                EXCEPTION
                 WHEN OTHERS THEN
                  RAISE;                 
                END;';
          EXECUTE IMMEDIATE V_SQL;
       END LOOP;
    END;
    EXCEPTION
       WHEN OTHERS
       THEN
       RAISE_APPLICATION_ERROR(-20001, V_JOB_STEP||' SQLERRM: ' || SQLERRM || ' SQLCODE: '|| SQLCODE);
    END JOB_CLASS_PROC;
    DECLARE
       V_SQL   VARCHAR2 (4000);
       V_JOB_STEP VARCHAR2 (50);
    BEGIN
    -- Create Job Class if not exist
       BEGIN
       FOR i
          IN (SELECT SNS.OWNER_NAME OWNER_NAME,
                     VDB.NAME
                        SNAME
                FROM SCHEMA_NAMES SNS,
                     V$DATABASE VDB
               WHERE OWNER_NAME NOT IN ('')
                AND (OWNER_NAME || '_JOB_CLASS')
                     NOT IN
                    (SELECT JOB_CLASS_NAME FROM DBA_SCHEDULER_JOB_CLASSES))
       LOOP
          V_SQL :=
                'BEGIN
                  DBMS_SCHEDULER.CREATE_JOB_CLASS
                   job_class_name => ''' || i.owner_name || '_JOB_CLASS'',
                   service           => ''' || i.SNAME || ''',
                   comments       => ''Job class for ' || i.owner_name || '''
                EXCEPTION
                 WHEN OTHERS THEN
                  RAISE;                 
                END;';
          EXECUTE IMMEDIATE V_SQL;
       END LOOP;
    END;
    EXCEPTION
       WHEN OTHERS
       THEN
       RAISE_APPLICATION_ERROR(-20001, V_JOB_STEP||' SQLERRM: ' || SQLERRM || ' SQLCODE: '|| SQLCODE);
    END;
    Why for same code procedure is giving error.
    Please help me.
    Thanks.

    Hi,
    Then with the same grants how the below script is working.
    If I put the below same script in Procedure it's not working.
    DECLARE
       V_SQL   VARCHAR2 (4000);
       V_JOB_STEP VARCHAR2 (50);
    BEGIN
    -- Create Job Class if not exist
       BEGIN
       FOR i
          IN (SELECT SNS.OWNER_NAME OWNER_NAME,
                     VDB.NAME
                        SNAME
                FROM SCHEMA_NAMES SNS,
                     V$DATABASE VDB
               WHERE OWNER_NAME NOT IN ('')
                AND (OWNER_NAME || '_JOB_CLASS')
                     NOT IN
                    (SELECT JOB_CLASS_NAME FROM DBA_SCHEDULER_JOB_CLASSES))
       LOOP
          V_SQL :=
                'BEGIN
                  DBMS_SCHEDULER.CREATE_JOB_CLASS
                   job_class_name => ''' || i.owner_name || '_JOB_CLASS'',
                   service           => ''' || i.SNAME || ''',
                   comments       => ''Job class for ' || i.owner_name || '''
                EXCEPTION
                 WHEN OTHERS THEN
                  RAISE;               
                END;';
          EXECUTE IMMEDIATE V_SQL;
       END LOOP;
    END;
    EXCEPTION
       WHEN OTHERS
       THEN
       RAISE_APPLICATION_ERROR(-20001, V_JOB_STEP||' SQLERRM: ' || SQLERRM || ' SQLCODE: '|| SQLCODE);
    END;
    Please help me.
    Thanks.

  • In which of the following sections of a PL/SQL block is a user-defined exception raised?

    Hi,
    A (somewhat elementary) question:
    In which of the following sections of a PL/SQL block is a user-defined exception raised?
    a) Exception section
    b) Declarative section
    c) Error handling section
    d) Executable section
    I'd be interested to hear people's answers.
    Thanks.

    As Etbin already noted, there are only 3 sections and user-defined exception can be raised in any of them. User-defined exception raised in declarative section example:
    declare
        year_zero exception;
        pragma exception_init(year_zero,-01841);
    begin
        declare
            v_dt date := to_date(1721420,'j');
        begin
            null;
        end;
      exception
        when year_zero
          then
            dbms_output.put_line('Year 0!');
    end;
    Year 0!
    PL/SQL procedure successfully completed.
    SQL>
    User-defined exception raised in executable section example:
    declare
        year_zero exception;
        pragma exception_init(year_zero,-01841);
        v_dt date;
    begin
        v_dt := to_date(1721420,'j');
      exception
        when year_zero
          then
            dbms_output.put_line('Year 0!');
    end;
    Year 0!
    PL/SQL procedure successfully completed.
    SQL>
    User-defined exception raised in exception handling section example:
    declare
        year_zero exception;
        pragma exception_init(year_zero,-01841);
        v_dt date;
    begin
        declare
            v_num number;
        begin
            v_num := 1 / 0;
          exception
            when others
              then
                v_dt := to_date(1721420,'j');
        end;
      exception
        when year_zero
          then
            dbms_output.put_line('Year 0!');
    end;
    Year 0!
    PL/SQL procedure successfully completed.
    SQL>
    SY.

  • How to report an error from anonymous PL/SQL blocks

    Hello,
    The following SQL*Plus script
    WHENEVER OSERROR EXIT FAILURE
    WHENEVER SQLERROR EXIT FAILURE
    DECLARE
    EXIST_INDEXES BOOLEAN := FALSE;
    BEGIN
    FOR INDEX IN (SELECT * FROM INDEXES)
    LOOP
    EXIST_INDEXES := TRUE;
    DBMS_OUTPUT.PUT_LINE(INDEX.SCHEMA || '.' || INDEX.NAME);
    END LOOP;
    IF EXIST_INDEXES THEN
    RAISE_APPLICATION_ERROR(-20000,'Before proceeding, it is recommended to drop the indexes listed above');
    END IF;
    END;
    -- Here go SQL statements that should be executed if no indexes were found
    produces this output when there is an entry in table/view INDEXES:
    SCHEMA_1.INDEX_1
    DECLARE
    ERROR at line 1:
    ORA-20000: Before proceeding, it is recommended to drop the indexes listed above
    ORA-06512: at line 13
    When there are entries in table/view INDEXES, how to:
    - suppress the 'DECLARE' and '*' lines from appearing in the script output;
    - skip executing the SQL statements after the PL/SQL block;
    - have the script return a non-zero code?
    Regards,
    Angel Tsankov

    1 You want the rest of the code not to execute, SO all code should be in one anonymous block.
    The scope of exceptions is one block.
    2 If you want to suppress
    - suppress the 'DECLARE' and '*' lines from appearing in the script output;you should not use raise_application_error, because this is how raise_application_error works.
    - whenever you raise an exception, the return code will be non-zero.
    The code you posted is really very poor, and inefficient, but as it is unclear what you are up to (you seem to want to skip executing everything when there are any indexes, if so you can just count them), it is not possible to provide working code.
    If you want to skip the rest of the code, you can declare your own exceptions, and you should just raise your own exception and the block will abort.
    Hth
    Sybrand Bakker
    Senior Oracle DBA

  • Unknown SQL Exception 208 occurred. Additional error information from SQL Server is included below.Invalid object name 'Webs'.

    SP 2013 Server + Dec 2013 CU. Upgrading from SharePoint 2010.
    We have a web application that is distributed over 7-8 content databases from SharePoint 2010. All but one database are upgradable. However, one database gives:
    Invalid object name 'Webs'.
    while running Test-SPContentDatabase or Mount-SPContentDatabase.
    EventViewer has the following reporting 5586 event Id:
    Unknown SQL Exception 208 occurred. Additional error information from SQL Server is included below.Invalid object name 'Webs'.
    After searching a bit, these links do not help:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/fd020a41-51e6-4a89-9d16-38bff9201241/invalid-object-name-webs?forum=sharepointadmin
    we are trying PowerShell only.
    http://blog.thefullcircle.com/2013/06/mount-spcontentdatabase-and-test-spcontentdatabase-fail-with-either-invalid-object-name-sites-or-webs/
    In our case, these are content databases. This is validated from Central Admin.
    http://sharepointjotter.blogspot.com/2012/08/sharepoint-2010-exception-invalid.html
    Our's is SharePoint 2013
    http://zimmergren.net/technical/findbestcontentdatabaseforsitecreation-problem-after-upgrading-to-sharepoint-2013-solution
    Does not seem like the same exact problem.
    Any additional input?
    Thanks, Soumya | MCITP, SharePoint 2010

    Hi,
    “All but one database are upgradable. However, one database gives:
    Invalid object name 'Webs'.”
    Did the sentence you mean only one database not upgrade to SharePoint 2013 and given the error?
    One or more of the following might be the cause:
    Insufficient SQL Server database permissions
    SQL Server database is full
    Incorrect MDAC version
    SQL Server database not found
    Incorrect version of SQL Server
    SQL Server collation is not supported
    Database is read-only
    To resolve the issue, you can refer to the following article which contains the causes and resolutions.
    http://technet.microsoft.com/en-us/library/ee513056(v=office.14).aspx
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Jason Guo
    TechNet Community Support

Maybe you are looking for

  • Save PDF to folder as JPEG Error

    This is happening in Aperture, and other programs too. When I try to use "Save PDF to folder as JPEG", the export begins, but when it comes to the pop up box that copies the files onto the desktop an error message indicates there has been a problem w

  • Sql greatest,decode,instr.  minimize code lines sql

    I did not write this code and please excuse me for my beginner questions? · Is there a way to make this code cleaner. Code it where its less lines of code? · Can we make the 2 conditions separate rather than a one after the other? For ex. Not like th

  • Connectivity between SSRS and SAP HANA

    Hi all We currently use SSRS as our main Reporting tool, the company is considering to implement SAP HANA, is it possible to connect SQL Server Reporting Services to SAP HAHA? And what if any are the draw backs? Thanks Ruan

  • Saving iBots in the Shared Folder

    Hi, I have a couple of questions regarding iBots: 1. How do I save the iBots in the Common Shared iBots folder? (I can do this as an Administrator, but not as any other user) 2. How can I have the content delivered as an Excel file to my dashboard. I

  • Problem in receiver rule of configured receivers in receiver determination

    Hi, Experts! Can anyone please help me with an issue regarding the receiver determination part of IB? I currently have 2 different receiver rules, each having a different condition but under the same communication component. When I check the message