Error with PL/SQL code

i am getting multiple errors when trying to insert data into a table through pl/sql declaration
here are the errors:
--Procedure to insert the values into section table(ex1.sql)
declare
v_section %type;
begin
v_section.SECTIONNO:=&no;
v_section. DESCRIPTION:='&desc';
v_section.SECTION_HEAD_EMPNO:=&empno
insert into section values v_section;
end;
/When i execute the above pl/sql program i am getting errors:
SQL> @ex1
Enter value for no: 10
old   4: v_section.SECTIONNO:=&no;
new   4: v_section.SECTIONNO:=10;
Enter value for desc: Sales
old   5: v_section. DESCRIPTION:='&desc';
new   5: v_section. DESCRIPTION:='Sales';
Enter value for empno: 1005
old   6: v_section.SECTION_HEAD_EMPNO:=&empno
new   6: v_section.SECTION_HEAD_EMPNO:=1005
v_section %type;
ERROR at line 2:
ORA-06550: line 2, column 12:
PLS-00103: Encountered the symbol "%" when expecting one of the following:
constant exception <an identifier>
<a double-quoted delimited-identifier> table LONG_ double ref
char time timestamp interval date binary national character
nchar
The symbol "<an identifier>" was substituted for "%" to continue.
ORA-06550: line 7, column 1:
PLS-00103: Encountered the symbol "INSERT" when expecting one of the following:
* & = - + ; < / > at in is mod remainder not rem
<an exponent (**)> <> or != or ~= >= <= <> and or like
between || multiset member SUBMULTISET_
The sBTW,*section* table is:
SQL> desc section;
Name                                                              Null?    Type
SECTIONNO                                                         NOT NULL NUMBER(2)
DESCRIPTION                                                                VARCHAR2(30)
SECTION_HEAD_EMPNO                                                         NUMBER(4)Kindly,correct me where i am doing wrong
Thanks in advance!!

Hi,
where is the semicolon after v_section.DESCRIPTION :=&empno ?
---it should be section%rowtype not simply %rowtype
Just copy paste the below code. It will work.
DECLARE
  v_section   SECTION%ROWTYPE;
BEGIN
  v_section.SECTIONNO := &NO;
  v_section.DESCRIPTION := '&desc';
  v_section.SECTION_HEAD_EMPNO := &empno;
  INSERT INTO SECTION
  VALUES v_section;
END;
/Test
SQL> CREATE TABLE SECTION
  2  (
  3    SECTIONNO            NUMBER (2) NOT NULL,
  4    DESCRIPTION          VARCHAR2 (30),
  5    SECTION_HEAD_EMPNO   NUMBER (4)
  6  );
Table created.
SQL> DECLARE
  2    v_section   SECTION%ROWTYPE;
  3  BEGIN
  4    v_section.SECTIONNO := &NO;
  5    v_section.DESCRIPTION := '&desc';
  6    v_section.SECTION_HEAD_EMPNO := &empno;
  7 
  8    INSERT INTO SECTION
  9    VALUES v_section;
10  END;
11  /
Enter value for no: 10
old   4:   v_section.SECTIONNO := &NO;
new   4:   v_section.SECTIONNO := 10;
Enter value for desc: sales
old   5:   v_section.DESCRIPTION := '&desc';
new   5:   v_section.DESCRIPTION := 'sales';
Enter value for empno: 1005
old   6:   v_section.SECTION_HEAD_EMPNO := &empno;
new   6:   v_section.SECTION_HEAD_EMPNO := 1005;
PL/SQL procedure successfully completed.
SQL> select * from section;
SECTIONNO DESCRIPTION                    SECTION_HEAD_EMPNO
        10 sales                                        1005
SQL> G.
Edited by: Ganesh Srivatsav on Apr 8, 2011 2:54 PM

Similar Messages

  • Error with Oracle10G Sql Browser while execute package with exec clause

    Dear Experts,
    Please tell me why i am getting Error ORA- 00900 while executing this script with Oracle10G Sql Browserbut not getting error with Oracle9i Sql Browser
    var r1 refcursor;
    var r2 refcursor;
    exec ETKT_CANCEL_TICKET_PCK.GET_DATA(:r1,:r2,'05052007/00000003/0000994','23');

    It would be interesting to know, what Sql Browser is.

  • 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

  • FK error in PL/SQL code.

    I have a application with the following code.
    Declare
    v_num_req varchar2(100); --Recebe o codigo da requisição
    v_cont number; --Conta a quantidade de aparições
    BEGIN
    --Busca o codigo da requisição
    select cod_requisicao
    into v_num_req
    from requisicao
    where cod = :p72_cod_requisicao;
    --Conta o numero de vezes em que aparece a requisição
    select count(numero_documento)
    INTO v_cont
    from amx_documento
    where numero_documento = v_num_req;
    --Se não aparecer nenhuma requisição
    IF (v_cont = 0) then
    BEGIN
    --Insere a movimentação
    INSERT INTO AMX_MOVIMENTACAO_MATERIAL(COD, NUM_GUIA, NUM_EMPENHO,DT_EMISSAO_EMPENHO ,DESTINO, DT_MOVIMENTACAO, COD_TIPO_MOVIMENTACAO, COD_ALMOXARIFADO, COD_STATUS)
    VALUES (AMX_MOVIMENTACAO_MATERIAL_SEQ.NEXTVAL ,to_char(sysdate, 'YYYY/DDMM-SSSSS'),'123SIS',sysdate,175120,sysdate,301,AMX_ALMOXARIFADO_PADRAO(:app_user),2);
    --Insere o documento
    Insert into amx_documento(cod,cod_movimentacao,cod_tipo_documento,valor_documento,numero_documento)
    values(amx_documento_seq.nextval,amx_movimentacao_material_seq.currval,261,0000,v_num_req);
    --inicia o cursor com os materiais.
    for c_item_req in(
    SELECT
    a.cod cod_mat,
    a.qtd_fornecida
    FROM
    item_requisicao a
    INNER JOIN requisicao e on a.cod_requisicao = e.cod
    INNER JOIN AMX_MATERIAL b ON a.cod_material=b.cod
    LEFT JOIN AMX_ESTOQUE c ON a.cod_material=c.cod_material
    AND c.cod_almoxarifado = :p72_almoxarifado
    WHERE
    a.cod_requisicao = :p72_cod_requisicao
    LOOP
    --Insere os items do documento.
    insert into amx_documento_item(cod,quantidade,valor_total,cod_material,cod_documento)
    values(AMX_MOVIMENTACAO_ITEM_SEQ.nextval,c_item_req.qtd_fornecida,00,c_item_req.cod_mat,amx_documento_seq.currval);
    END LOOP;
    END;
    end if;
    end;
    When run, return a error because of the FK cod_material in still new in the PL/SQL world, so please help me.

    post also the complete returned error message.

  • CDS-11025 Error: Oracle Designer generation error with PL/SQL package

    Hi friends,
    We tried to generate a database package from Oracle Designer (10.1.2.6) and getting "syntax errors" but the package has no syntax errors when we copy and paste the code and compile in TOAD (10.6)
    Error from Designer:
    Server Generator 10.1.2.6 (Build 10.1.2.11.12) , Wed Oct 17 10:58:43 2012
    Copyright (c) Oracle Corporation 1995, 2010. All rights reserved.
    CDS-11025 Error: The PL/SQL within PACKAGE BODY AVP_WATER_ANALYSIS_V has syntax errors - At token 'END', around:
    ...te_dist.VLV_INTL_ID;
    END LOOP;
    Processing Complete: 1 error(s), 0 warning(s)
    code snippet from the Error message:
    FOR rec_update_dist IN cur_update_dist (i_anlyd_intl_id,
    i_iterd_intl_id,
    i_phsed_intl_id,
    i_wtrc_intl_id)
    LOOP
    UPDATE AVP_VALVE AvpValve
    SET AvpValve.DIST_FROM_EDGE = rec_update_dist.DIST_FROM_EDGE
    WHERE AvpValve.ANLYD_INTL_ID = rec_update_dist.ANLYD_INTL_ID
    AND AvpValve.ITERD_INTL_ID = rec_update_dist.ITERD_INTL_ID
    AND AvpValve.PHSED_INTL_ID = rec_update_dist.PHSED_INTL_ID
    AND AvpValve.WTRC_INTL_ID = rec_update_dist.WTRC_INTL_ID
    AND AvpValve.VLV_INTL_ID = rec_update_dist.VLV_INTL_ID;
    END LOOP;
    Thanks for any feedback,
    Jim

    Found the problem.
    It was an issue with the CURSOR with the SELECT ... FROM (SELECT CASE WHEN THEN ELSE END). After swithing to the DECODE statement, Designer is able to generate the package.
    CASE
    WHEN ISOLATION_IND = 'Y' THEN
    'A'
    WHEN OPERATED_IND = 'Y' THEN
    'B'
    ELSE
    'C'
    END
    decode(ISOLATION_IND,'Y','A',decode(OPERATED_IND,'Y','B','C'))
    However, still strange to me that Designer doesn't like the CASE as part of SELECT.
    Edited by: user476620 on Oct 18, 2012 8:13 PM

  • Error with PL/SQL xmlGen if unlimited rows

    If I run xmlgen server side from pl/sql and I dont specify a limit on the rows I get the following error
    xml version=1.0
    ERROR
    oracle.xml.sql.OracleXMLSQLEception
    ORA-00600: internal error code, arguments: [kdlseek-kgbtnscb]
    ERROR
    If limit the rows it works ok, the generated xml is not that big only about 600 rows
    Any ideas on whast the problem
    Rob

    I too get the same problem. Has anyone come up with a solution, not a workaround?
    SQL> select xmlgen.getXML('select * from dict where table_name like ''%ROLE%''') from dual;
    XMLGEN.GETXML('SELECT*FROMDICTWHERETABLE_NAMELIKE''%ROLE%''')
    <?xml version = '1.0'?>
    <ROWSET>
    <ROW num="1">
    <TABLE_NAME>DBA_ROLES</T
    SQL> select xmlgen.getXML('select * from dict') from dual;
    select xmlgen.getXML('select * from dict') from dual
    ERROR at line 1:
    ORA-29532: Java call terminated by uncaught Java exception:
    oracle.xml.sql.OracleXMLSQLException: ORA-00600: internal error code,
    arguments: [kdlseek-kgbtnscb], [], [], [], [], [], [], []
    ORA-06512: at "SCOTT.XMLGEN", line 465
    ORA-06512: at "SCOTT.XMLGEN", line 456
    ORA-06512: at line 1
    SQL> select count(*) from dict;
    COUNT(*)
    851
    SQL> describe dict;
    Name Null? Type
    TABLE_NAME VARCHAR2(30)
    COMMENTS VARCHAR2(4000)
    SQL>
    shared_pool_size = 52428800 # 50MB
    large_pool_size = 614400
    java_pool_size = 41943040 # 40MB
    W2K V5 SP1, 8.1.6 RLSE2 & XSU1.2
    Steve.
    null

  • Help with PL/SQL code

    Hi!
    I need help, I don't know why I recieve errors with my code:
    declare
    xMin number(3) NOT NULL := 50;
    xMax number(3) NOT NULL := 70;
    yMin number(3) := 0;
    yMax number(3) := 20;
    begin
    IF xMin < -400 THEN
    xMin = -400;
    ELSIF xMax > 400 THEN
    xMax = 400;
    ELSEIF yMin < -400 THEN
    yMin = -400;
    ELSEIF yMax > 400 THEN
    yMax = 400;
    END IF;
    select sum(population) populacija
    from naselje
    where x BETWEEN xMin AND xMax
    and y BETWEEN yMin AND yMax;
    end;
    error I get is:
    ORA-06550: line 10, column 15:
    PLS-00103: Encountered the symbol "=" when expecting one of the following:
    := . ( @ % ;
    The symbol ":= was inserted before "=" to continue.
    ORA-06550: line 12, column 15:
    PLS-00103: Encountered the symbol "=" when expecting one of the following:
    := . ( @ % ;
    1. declare
    2. xMin number(3) NOT NULL := 50;
    3. xMax number(3) NOT NULL := 70;Thanks for your help!
    Regards,
    Dragan

    Although you got your answer, next time post in the sql/ pl/sql forum.
    PL/SQL

  • Console error with GUI , return code -17

    Hi All,
    I have just finished the Installation of SAP IDES 4.7. Installation was sucessful, after that I Installed GUI 640. But when we are starting the Console it is starting without any error which also shows WP table details in run mode. When we logon to gui, console becomes "Yellow" and dispatch process stop with a return code -17.
    Please help.
    Thanks
    Jagat.

    Hi Kaushal,
    Thanks for ur reply. Actually when we started the installation process, and GUI, we have not provide the loopback adapter in the Primary DNS, but Loopback Adapter was properly configured with IP.
    Later on we realised and added the 127.0.0.1 in the Primary DNS. But its still not working. 
    The Log which u have asked for is attached.
    trc file: "dev_w0", trc level: 1, release: "620"
    ACTIVE TRACE LEVEL           1
    ACTIVE TRACE COMPONENTS      all, M

    B Sat Mar 04 10:18:27 2000
    B  create_con (con_name=R/3)
    B  Loading DB library 'C:\usr\sap\TEK\SYS\exe\run\dboraslib.dll' ...
    B  Library 'C:\usr\sap\TEK\SYS\exe\run\dboraslib.dll' loaded
    B  Version of 'C:\usr\sap\TEK\SYS\exe\run\dboraslib.dll' is "620.02", patchlevel (0.112)
    B  New connection 0 created
    M  systemid   560 (PC with Windows NT)
    M  relno      6200
    M  patchlevel 0
    M  patchno    251
    M  intno      20020600
    M  pid        2792

    M  ***LOG Q0Q=> tskh_init, WPStart (Workproc 0 2792) [dpxxdisp.c   1016]
    I  MtxInit: -2 0 0

    X Sat Mar 04 10:18:29 2000
    X  EmInit: MmSetImplementation( 2 ).
    X  <ES> client 0 initializing ....
    X  Using implementation std
    M  <EsNT> Memory Reset enabled as NT default
    X  ES initialized.
    M  calling db_connect ...
    C  Got ORACLE_HOME=D:\oracle\ora81 from environment

    C Sat Mar 04 10:18:30 2000
    C  Client NLS settings: AMERICAN_AMERICA.WE8DEC
    C  Logon as OPS$-user to get SAPTEK's password
    C  Connecting as /@TEK on connection 0 ...
    C  Attaching to DB Server TEK (con_hdl=0,svchp=06A497E8,svrhp=06A495F4)

    C Sat Mar 04 10:19:07 2000
    C  Starting user session (con_hdl=0,svchp=06A497E8,srvhp=06A495F4,usrhp=06A913AC)
    C  *** ERROR => OCI-call 'OCISessionBegin' failed: rc = 1017
    [dboci.c      3718]
    C  *** ERROR => CONNECT failed with sql error '1017'
    [dboci.c      9536]
    C  Try to connect with default password
    C  Connecting as SAPTEK/<pwd>@TEK on connection 0 ...
    C  Starting user session (con_hdl=0,svchp=06A497E8,srvhp=06A495F4,usrhp=06A913AC)
    C  *** ERROR => OCI-call 'OCISessionBegin' failed: rc = 1017
    [dboci.c      3718]
    C  *** ERROR => CONNECT failed with sql error '1017'
    [dboci.c      9536]
    B  ***LOG BY2=> sql error 1017   performing CON [dbsh#2 @ 962] [dbsh    0962 ]
    B  ***LOG BY0=> ORA-01017: invalid username/password; logon denied [dbsh#2 @ 962] [dbsh    0962 ]
    B  ***LOG BY2=> sql error 1017   performing CON [dblink#1 @ 419] [dblink  0419 ]
    B  ***LOG BY0=> ORA-01017: invalid username/password; logon denied [dblink#1 @ 419] [dblink  0419 ]
    M  ***LOG R19=> tskh_init, db_connect ( DB-Connect 000256) [thxxhead.c   1098]
    M  in_ThErrHandle: 1
    M  *** ERROR => tskh_init: db_connect (step 1, th_errno 13, action 3, level 1) [thxxhead.c   8277]

    M  Info for wp 0

    M    stat = 4
    M    reqtype = 1
    M    act_reqtype = -1
    M    tid = -1
    M    mode = 255
    M    len = -1
    M    rq_id = -1
    M    rq_source = 255
    M    last_tid = 0
    M    last_mode = 0
    M    rfc_req = 0
    M    report = >                                        <
    M    action = 0
    M    tab_name = >                              <

    M  *****************************************************************************
    M  *
    M  *  LOCATION    SAP-Server sapsrv_TEK_00 on host sapsrv (wp 0)
    M  *  ERROR       tskh_init: db_connect
    M  *
    M  *  TIME        Sat Mar 04 10:19:07 2000
    M  *  RELEASE     620
    M  *  COMPONENT   Taskhandler
    M  *  VERSION     1
    M  *  RC          13
    M  *  MODULE      thxxhead.c
    M  *  LINE        8408
    M  *  COUNTER     1
    M  *
    M  *****************************************************************************

    M  Entering TH_CALLHOOKS
    M  ThCallHooks: call hook >SAP-Trace buffer write< for event BEFORE_DUMP
    M  ThCallHooks: call hook >ThrSaveSPAFields< for event BEFORE_DUMP
    M  *** ERROR => ThrSaveSPAFields: no valid thr_wpadm [thxxrun1.c   672]
    M  *** ERROR => ThCallHooks: event handler ThrSaveSPAFields for event BEFORE_DUMP failed [thxxtool3.c  235]
    M  Entering ThSetStatError
    M  Entering ThReadDetachMode
    M  call ThrShutDown (1)...
    M  ***LOG Q02=> wp_halt, WPStop (Workproc 0 2792) [dpnttool.c   345]

  • REPORT WITH PL/SQL  CODE

    DECLARE
    SQ VARCHAR2(100);
    BEGIN
    SQ := 'SELECT * FROM EMP WHERE EMPNO=7788';
    RETURN SQ;
    END
    THE ABOVE PL/SQL CODE WORKING FINE
    BUT I NEED CONDITION BASED ON ENAME
    SQ:='SELECT * FROM EMP WHERE ENAME=''SCOTT'';
    IT IS GIVEING ERROR
    WHAT TO DO?

    Hi,
    You're missing the final quote - you have the quotes for SCOTT but not the one to close the SQ string:
    DECLARE
    SQ VARCHAR2(100);
    BEGIN
    SQ := 'SELECT * FROM EMP WHERE EMPNO=''SCOTT''';
    RETURN SQ;
    ENDAndy

  • Statspack: error with spcreate.sql in 11.1.0.7 on WIndows

    Hello,
    I'm trying to install statspack on a 11.1.0.7 64bit RDBMS on Windows 2008 R2.
    I get this error during spcreate.sql as sysdba
    ... Creating views
    . quisce_t*drms quiesce_time
    ERROR at line 5
    ORA-00904: "QUISCE_T" : invalid identifier
    I wasn't able to find anything related on metalink....
    Any hint?
    I was previously able to run it on 11.2.0.1 and 11.2.0.3 RDBMS on Linux systems...
    I don't know if it is a problem with this particular version of the rdbms.
    Thanks in advance,
    Gianluca

    hello,
    running now a snap as perfstat user I get this error
    SQL> exec statspack.snap;
    BEGIN statspack.snap; END;
    ERROR at line 1:
    ORA-04063: package body "SYS.DBMS_SHARED_POOL" has errors
    ORA-06508: PL/SQL: could not find program unit being called:
    "SYS.DBMS_SHARED_POOL"
    ORA-06512: at "PERFSTAT.STATSPACK", line 5767
    ORA-06512: at line 1
    In fact
    SQL> select owner,object_name,object_type from dba_objects where status='INVALID
    2 order by object_name;
    OWNER OBJECT_NAME OBJECT_TYPE
    SYS DBMS_SHARED_POOL PACKAGE BODY
    PUBLIC STATSPACK SYNONYM
    Trying to recompile as sysdba I get
    Connected to:
    Oracle Database 11g Release 11.1.0.7.0 - 64bit Production
    SQL> alter package dbms_shared_pool compile body;
    Warning: Package Body altered with compilation errors.
    SQL> show errors
    Errors for PACKAGE BODY DBMS_SHARED_POOL:
    LINE/COL ERROR
    87/13 PLS-00323: subprogram or cursor 'PURGE' is declared in a package
    specification and must be defined in the package body
    Could it be that t was my first 10.2.0.3 spcreate.sql putting the package in this state?
    I don't suppose so and that the package was already invalid before... but not sure...
    How to correct? I found similar cases where Oracle oly suggested catalog/catproc runs... but I would like to avoid if possible...
    Thanks in advance

  • What is missing with Pl SQL code?

    Hey guys,
    I am learning out of this book, and the guy Has this bit of Pl/sql.....
    It executes immdiate.
    create table zed ( z varchar2(30);
    declare procedure thisway1
    (p_data in varchar2 )
    is
    begin
    execute immediate
    'insert into zed(z) values(:z)'
    using p_data; end thisway1;
    Is the code correct?

    FrankKulash wrote:
    Hi,
    XevBellringer wrote:
    Hey guys,
    I am learning out of this book, and the guy Has this bit of Pl/sql.....
    It executes immdiate.
    create table zed ( z varchar2(30);
    declare procedure thisway1
    (p_data in varchar2 )
    is
    begin
    execute immediate
    'insert into zed(z) values(:z)'
    using p_data; end thisway1;
    Is the code correct?
    No code is absolutely correct.  Code can be correct for a specific purpose, which means it will be incorrect for other purposes.  If that code was copied out of a book, the book probably explains the context, and why the author chose to use EXECUTE IMMEDIATE when it's not necessary.  (You should use dynamic SQL, such as EXECUTE IMMEDIATE, only when you really have to.  That's one of the most important things to learn about dynamic SQL.  Perhaps the book is using this code to make that point.)
    By itself, the PL/SQL code you posted will get a compilation error.  The DECLARE statement must have matching BEGIN and END statements.  (The BEGIN and END statements above are for procedure thisway1, which is nested inside the DECLARE section.)  I suspect you only copied part of the code from the book.
    The CREATE TABLE statement also has an error; it has 2 left '('s, but only 1 right ')'.  You need to have an equal number of each..
    Thank you so much for replying! Ok, the create table was a typo since im on my phone., but Serioulsy this is the way this procedure code looks like in the book.
    I will do what you said, hopefully i can get it to execute so i can continue on in my studies. Thanks for being nice.

  • Performance issue with pl/sql code

    Hi Oracle Gurus,
    I am in need of your recommendations for a performance issue that I am facing in production envrionment. There is a pl/sql procedure which executes with different elapsed time at different executions. Elapsed Times are 30minutes , 40 minutes, 65 minutes , 3 minutes ,3 seconds.
    Expected elapsed time is maximum of 3 minutes. ( But some times it took 3 seconds too...! )
    Output on all different executions are same that is deletion and insertion of 12K records into a table.
    Here is the auto trace details of two different scenarios.
    Slow execution - 33.65 minutes
    Stat Name                                Statement   Per Execution % Snap
    Elapsed Time (ms)                         1,712,343    1,712,342.6    41.4
    CPU Time (ms)                             1,679,689    1,679,688.6    44.7
    Executions                                        1            N/A     N/A
    Buffer Gets                              ##########  167,257,973.0    86.9
    Disk Reads                                    1,284        1,284.0     0.4
    Parse Calls                                       1            1.0     0.0
    User I/O Wait Time (ms)                       4,264            N/A     N/A
    Cluster Wait Time (ms)                        3,468            N/A     N/A
    Application Wait Time (ms)                        0            N/A     N/A
    Concurrency Wait Time (ms)                        6            N/A     N/A
    Invalidations                                     0            N/A     N/A
    Version Count                                     4            N/A     N/A
    Sharable Mem(KB)                                 85            N/A     N/A
              -------------------------------------------------------------Fast Exection : 5 seconds
    Stat Name                                Statement   Per Execution % Snap
    Elapsed Time (ms)                            41,550       41,550.3     0.7
    CPU Time (ms)                                40,776       40,776.3     1.0
    Executions                                        1            N/A     N/A
    Buffer Gets                               2,995,677    2,995,677.0     4.2
    Disk Reads                                       22           22.0     0.0
    Parse Calls                                       1            1.0     0.0
    User I/O Wait Time (ms)                         162            N/A     N/A
    Cluster Wait Time (ms)                          621            N/A     N/A
    Application Wait Time (ms)                        0            N/A     N/A
    Concurrency Wait Time (ms)                       55            N/A     N/A
    Invalidations                                     0            N/A     N/A
    Version Count                                     4            N/A     N/A
    Sharable Mem(KB)                                 85            N/A     N/A
              -------------------------------------------------------------For security reasons, I cannot share the actual code. Its a report generating code that deletes and load the data into table using insert into select statement.
    Delete from table ;
    cursor X to get the master data ( 98 records )
    For each X loop
    insert into tableA select * from tables where a= X.a and b= X.b and c=X.c ..... ;
    -- 12 K records inserted on average
    insert into tableB select * from tables where a= X.a and b= X.b and c=X.c ..... ;
    -- 12 K records inserted on average
    end loop ;1. The select query is complex with bind variables ( explain plan varies for each values )
    2. I have checked the tablespace of the tables involved, it is 82% used. DBA confirmed that it is not the reason.
    3. Disk reads are high during long execution.
    4. At long running times, I can see a db sequential read wait event on a index object. This index is on the table where data is inserted.
    All I need to find is why this code is taking 3 seconds and 60 minutes on the same day and on the consecutive executions ?
    Is there any other approach to find the root cause of this behaviour and to fix it ? Kindly adivse.
    Thanks in advance your help.
    Regards,
    Hari
    Edited by: BluShadow on 26-Sep-2012 08:24
    edited to add {noformat}{noformat} tags.  You've been a member long enough to know to do this yourself... so please do so in future.  ({message:id=9360002})                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hariharan ST wrote:
    Hi Oracle Gurus,
    I am in need of your recommendations for a performance issue that I am facing in production envrionment. There is a pl/sql procedure which executes with different elapsed time at different executions. Please reedit your post and add some code tags around the trace information. This would improve readability greatly and will help us to help you
    example
    {<b></b>code}
    select * from dual;{<b></b>code}
    Based upon your description I can imagine two things.
    a) The execution plan for the select query does change frequently.
    A typical reason can be not up to date statistics.
    b) Some locking / wait conflict. For example upon a UK index.
    Are there any other operations going on while it is slow? If anybody inserts a value, then your session will wait, if the same (PK/UK) value also is to be inserted.
    Those wait events can be recognized using standard tools like oracle sql developer or enterprise manager while the query is slow.
    Also go through the links that are in the FAQ. They tell you how to get better information for makeing a tuning request.
    SQL and PL/SQL FAQ
    Edited by: Sven W. on Sep 25, 2012 6:41 PM

  • Cursor open error SQLSTT - 72000, SQL code - 969

    We have purchased a product called Access Manager for DB2 and installed it on our AS400. This gives us the connectivitiy to Oracle server with which we do the Warehouse management software interface using our legacy system on AS400.
    I have written several programs in SQLRPGLE and not quite sure as to how I can handle errors coming out of Oracle server.
    As per my knowledge in my programs, I do
    declare cursor
    open cursor
    fetch
    dow look for sqlstate
    fetch next row
    enddo
    close cursor
    I am also new to this much of SQL.
    Now, my programs are running in production and works just fine if we don;t have any issues with oracle server (database server down etc.).
    My question is if the database server goes down for any reason, my SQLRPGLE progam starts giving me cursor not open errors, the actual error is as follows:
    Connection to relational database HJAWCD1 already exists.
    ARDUPAR: ARDUPAR: rc=-1(OCI_ERROR) from OCIStmtExecute when asking for
    Describe-Info
    ARDUPAR(1): ORA-03114: not connected to ORACLE
    ARDAROC: rc = -1 from parse
    SQLSTATE class unknown - SQLSTATE 72000, SQLCODE -969.
    Cursor SEHOST not open.
    Cursor SEHOST not open.
    Cursor SEHOST not open.
    So although, the connection exist between the AS400 and Oracle server as suggested from first statement, but then the cursor is giving me problems of not opening.
    what I would like to know is how do I check in my SQL statement the error and somehow reconnect and open the cursor again.
    Please help in this regard, since I am not finding any help from iseries world becuase no one seems to have knowledge about this product that we have installed and I don;t have too mcuh of documentation on the product nor do I have any sample handling messages program using RPGLE between oracle and AS400 using the product.
    Regards
    Farhan Qadri

    It's been over a decade since I worked on an AS/400 (iSeries), but I've seen an ORA-03114 is thrown from the OCI when you've attempted an illegal statement. That error typically means you are no longer connected to the database. I'd guess that your new application has a defective RPG error management routine.
    Good luck, Michael

  • Rectify the error in PL/SQL code

    CMW_BC_CALC_OF_FIN_YR_SDATE is a function which returns financial start date and CMW_BC_CALC_OF_FIN_YR_EDATE returns financial end date.
    I/P: 2004, 01-jan-2003
    O/P: A
    1 CREATE OR REPLACE FUNCTION CMW_BC_A_C_R
    2 (
    3 D IN VARCHAR2, RD IN DATE
    4 ) RETURN VARCHAR2 is
    5 SDATE DATE;
    6 EDATE DATE;
    7 TYPE VARCHAR2;
    8 BEGIN
    9 SDATE:=CMW_BC_CALC_OF_FIN_YR_SDATE(D);
    10 EDATE:=CMW_BC_CALC_OF_FIN_YR_EDATE(D);
    11 If RD<EDATE and RD>SDATE
    12 then TYPE:='C';
    13 end if;
    14 If RD>EDATE
    15 then TYPE:='A';
    16 end if;
    17 If RD<SDATE
    18 then TYPE:='R';
    19 end if;
    20 return(TYPE);
    21* END;
    SQL> /
    Warning: Function created with compilation errors.
    SQL> show error;
    Errors for FUNCTION CMW_BC_A_C_R:
    LINE/COL ERROR
    0/0 PL/SQL: Compilation unit analysis terminated
    4/11 PLS-00498: illegal use of a type before its declaration
    SQL>

    Hi,
    Use
    SELECT * FROM V$RESERVED_WORDS
    to know all the reserve words.
    Regards

  • ORA-01007 - variable not in select list error in pl\sql code

    Hi,
    When I tried to run this program I am getting below error:
    ORA-01007 - variable not in select list.Please help to resolve.
    Code:
    create or replace procedure "XX_BPM_DATA_P" (P_PROCESS_ID IN VARCHAR2)
    is
    TYPE l_entity_type IS TABLE OF xx_BPM_data.ENTITY%TYPE INDEX BY PLS_INTEGER;
    TYPE l_data_type IS TABLE OF XX_BPM_DATA.DATA%TYPE INDEX BY PLS_INTEGER;
    TYPE l_count_type IS TABLE OF XX_BPM_DATA.count%TYPE INDEX BY PLS_INTEGER;
    l_Entity_v l_Entity_type;
    l_data_v l_data_type;
    l_count_v l_count_type;
    l_security_group_id number;
    app_id number(20);
    l_Actual_value XX_BPM_DATA.DATA%TYPE;
    cursor BPM_CUR is select id,process_id , sequence, to_char(query) query,report_num from xx_test_bpm_dynamic
    where
        process_id = p_process_id
           and report_num=1
    order by process_id, sequence;
    BEGIN
    --delete xx_bpm_data where process_id = p_process_id;
    for bpm_rec in bpm_cur
    loop
    delete xx_bpm_data
    where process_id = bpm_rec.process_id
    and sequence = bpm_rec.sequence
    and report_num = bpm_rec.report_num;
    l_security_group_id := apex_custom_auth.get_session_id_from_cookie;
    --dbms_output.put_line(l_security_group_id);
    execute immediate bpm_rec.query BULK COLLECT INTO l_ENTITY_v,l_DATA_v,l_count_v;
    if (bpm_rec.report_num=2) then
    app_id:= 108;--NV('APP_ID');
    FORALL i IN l_ENTITY_v.FIRST..L_ENTITY_V.LAST
    INSERT INTO XX_BPM_DATA
        (EnTITY,
    value,data,count,
    Process_ID,
    Sequence,report_num)
    VALUES(l_entity_v(i),
    l_data_v(i),
    '<A HREF="f?p='||app_id||':301:'||':APP_SESSION'||'::::P301_process_id,p301_sequence,p301_id,p301_entity:'||bpm_rec.process_id||','||bpm_rec.sequence||','||bpm_rec.id||','||l_entity_v(i)||':">'||l_data_v(i)||'</A>',
        l_count_v(i),bpm_rec.process_id,
    BPM_rec.sequence,
    bpm_rec.report_num);
    else
    FORALL i IN l_ENTITY_v.FIRST..L_ENTITY_V.LAST
    INSERT INTO XX_BPM_DATA(EnTITY,data,
        count,
    Process_ID,
    Sequence,report_num)
    VALUES(l_entity_v(i),
    l_data_v(i),
        l_count_v(i),
        bpm_rec.process_id,
    BPM_rec.sequence,
    bpm_rec.report_num);
    end if;
    select round(avg(value),2) into l_actual_value from xx_bpm_data where process_id=bpm_rec.process_id and sequence=bpm_rec.sequence and report_num=bpm_rec.report_num;
    update xx_test_bpm_dynamic set value=l_actual_value where process_id=bpm_rec.process_id and sequence=Bpm_rec.sequence and report_num= bpm_rec.report_num;
    end loop;
    Commit;
    END;

    When I tried to run this program I am getting below error:
    ORA-01007 - variable not in select list.Please help to resolve.
    You likely would not need any help in you wrote and tested your code using standard best practices.
    Your code has NO exception handler and you are NOT identifying each step in the code so that the exception handler could print/log a message telling you EXACTLY which step raised the exception.,
    v_step NUMBER;
    -- before step 1
    v_step := 1;
    -- before step 2
    v_step := 2;
    Then in the exception handler the value of 'v_step' will tell you which step raised the exception.
    The exception you posted refers to a 'select list' so examine ALL of the select lists in your code. If you do that you will see that the primary query being run is obtained from a database table and then executed using dynamic SQL
    execute immediate bpm_rec.query BULK COLLECT INTO l_ENTITY_v,l_DATA_v,l_count_v;
    We have no way of knowing what query is in 'bpm_rec.query' when the exception happens or what columns that query returns. For all we know the query returns 2 columns and you are trying to load 3 collections. Or maybe the query returns 8 columns and you are trying to load 3 collections.
    Why don't you print out the query and execute it manually so you can see exactly what the result set looks like?
    dbms_output.put_line(bpm_rec.query);
    And don't even get us started on why you are using such security-prone dynamic sql to perform this processing instead of using ordinary SQL statements. Or why you are using associative arrays for the BULK COLLECT instead of nested tables.
    In short your code could blow up in several places and, because you have NO logging statements, control statements or exception handlers, anyone having to troubleshoot that code would have absolutely no idea what part of it may be the problem.

Maybe you are looking for