Error in the pl/sql block using associative arrays

Hi
I tried the following block of code using associative arrays.
DECLARE
   TYPE NumTab IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
   CURSOR c1 IS SELECT empno FROM emp;
   empnos NumTab;
   rows   NATURAL := 10;
BEGIN
   OPEN c1;
   FOR i in empnos.first..empnos.last LOOP
      /* The following statement fetches 10 rows (or less). */
      FETCH c1 BULK COLLECT INTO empnos LIMIT rows;
      EXIT WHEN c1%NOTFOUND;
      DBMS_OUTPUT.PUT_LINE ( empnos.next(i));
   END LOOP;
   CLOSE c1;
END;and the error is
DECLARE
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at line 8could you please let me know where i'm wrong
and please guide me where we use these associative arrays.
Thanks

Something like this. Do minor modification in your code.
DECLARE
   TYPE NumTab IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
   CURSOR c1 IS SELECT empno FROM emp;
   empnos NumTab;
   rows   NATURAL := 5;
BEGIN
   OPEN c1;
   LOOP  
    /* The following statement fetches 5 rows (or less). */
      FETCH c1 BULK COLLECT INTO empnos LIMIT rows;
      EXIT WHEN c1%NOTFOUND;
      DBMS_OUTPUT.PUT_LINE ( empnos.count);
   END LOOP;
   CLOSE c1;
END;
/

Similar Messages

  • Construct a Sql block using With Clause to improve the performance

    I have got four diff parametrized cursor in my Pl/Sql Procedure. As the performance of the Procedure is very pathetic,so i have been asked to tune the Select statements used in those cursors.
    So I am trying to use the With Clause in order to club all those four Select Statements.
    I would appreciate if anybody can help me to construct the Sql Block using With Clause.
    My DB version is..
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    Four Diff cursors are defined below.
    CURSOR all_iss (
          b_batch_end_date   IN   TIMESTAMP,
       IS
          SELECT isb.*
                FROM IMPLMN_STEP_BREKPN  isb
               , ISSUE iss
          WHERE isb.issue_id = iss.issue_id
           AND iss.issue_status_id  =  50738
           AND ewo_no IN
          (SELECT TO_CHAR(wo_no)
            FROM MGO_PLANT_AUDIT
           WHERE dml_status = 'U' OR dml_status = 'I')
          UNION ALL
          SELECT isb.*
           FROM IMPLMN_STEP_BREKPN  isb
            , ISSUE iss
           WHERE isb.issue_id = iss.issue_id
           AND iss.issue_status_id  =  50738
           AND CAST (isb.last_updt_timstm AS TIMESTAMP) >=
                                                                  b_batch_end_date;
          CURSOR ewo_plant  ( p_ewo_no IN  IMPLMN_STEP_BREKPN.ewo_no%TYPE)
          IS
          SELECT DISTINCT wo_no ,
          plant_code
          FROM MGO_PLANT
          WHERE TO_CHAR(wo_no) = p_ewo_no;
          CURSOR iss_ewo_plnt (
          p_issue_id IN IMPLMN_STEP_BREKPN.issue_id%TYPE ,
          p_ewo_no IN IMPLMN_STEP_BREKPN.EWO_NO%TYPE,
          p_plnt_code IN IMPLMN_STEP_BREKPN.PLT_FACLTY_ID%TYPE)
          IS
          SELECT *
          FROM IMPLMN_STEP_BREKPN
          WHERE issue_id = p_issue_id
          AND ewo_no = p_ewo_no
          AND
          (plt_faclty_id = p_plnt_code
          OR
          plt_faclty_id IS NULL);
          CURSOR iss_ewo_plnt_count (
          p_issue_id IN IMPLMN_STEP_BREKPN.issue_id%TYPE ,
          p_ewo_no IN IMPLMN_STEP_BREKPN.EWO_NO%TYPE,
          p_plnt_code IN IMPLMN_STEP_BREKPN.PLT_FACLTY_ID%TYPE)
          IS
          SELECT COUNT(*)
          FROM IMPLMN_STEP_BREKPN
          WHERE issue_id = p_issue_id
          AND ewo_no = p_ewo_no
          AND
          (plt_faclty_id = p_plnt_code
          OR
          plt_faclty_id IS NULL);

    Not tested. Some thing like below. i just made the queries as tables and given name as a,b,c and substituted columns for the parameters used in the 2nd cursor and third cursor. Try like this.
    CURSOR all_iss (
    b_batch_end_date IN TIMESTAMP,
    IS
    select a.*,b.*,c.* from
    ( SELECT isb.*
    FROM IMPLMN_STEP_BREKPN isb
    , ISSUE iss
    WHERE isb.issue_id = iss.issue_id
    AND iss.issue_status_id = 50738
    AND ewo_no IN
    (SELECT TO_CHAR(wo_no)
    FROM MGO_PLANT_AUDIT
    WHERE dml_status = 'U' OR dml_status = 'I')
    UNION ALL
    SELECT isb.*
    FROM IMPLMN_STEP_BREKPN isb
    , ISSUE iss
    WHERE isb.issue_id = iss.issue_id
    AND iss.issue_status_id = 50738
    AND CAST (isb.last_updt_timstm AS TIMESTAMP) >=
    b_batch_end_date) a,
    ( SELECT DISTINCT wo_no ,
    plant_code
    FROM MGO_PLANT
    WHERE TO_CHAR(wo_no) = p_ewo_no) b,
    ( SELECT *
    FROM IMPLMN_STEP_BREKPN
    WHERE issue_id = p_issue_id
    AND ewo_no = p_ewo_no
    plt_faclty_id IS NULL) c
    where b.wo_no = c.ewo_no and
    c.issue_id = a.issue_id ;
    vinodh
    Edited by: Vinodh2 on Jul 11, 2010 12:03 PM

  • Error in the below sql.

    Hi
    I am getting the below error in the below sql
    Hi
    I am getting the error in the below sql
    DECLARE
       pgm_id                  NUMBER := &1;
       schd_dt                 DATE := TO_DATE('&2','MM/DD/YYYY');
       l_schd_dt               DATE := NULL;
       l_pgm_id                NUMBER :=0;
       l_src_id                NUMBER;
       l_bulkCollectSize       NUMBER;
       l_trace_level           NUMBER := 0;
       l_CommitAllowance       INFT1.PRM_VALUE%TYPE;
       v_insrcdcnt             NUMBER := 0;
       g_ErrorString           VARCHAR2(500) := NULL;
       g_log_error             VARCHAR2(300) := NULL;
       g_recs_upd              NUMBER :=0;
       g_recs_ins              NUMBER :=0;
       g_aud_upd_ts            DATE := NULL;
       l_data_nbr              NUMBER := 0;
       l_ts_1             DATE :=NULL;
       l_ts_2               DATE :=NULL;
       l_rest_empno  emp_STG.mbr_nbr%TYPE :='0';
      l_Commitsize            NUMBER;
       CURSOR curTrnRecs(l_rest_empno VARCHAR)
       IS
        SELECT /* user_hash(tmp) PARALLEL(tmp,8) */  tmp.sec_lbl
        ,tmp.empno
         ,tmp.ename
        ,tmp.sal
        ,tmp.deptno
           FROM emp_stg tmp where tmp.mbr_nbr > l_rest_empno   order by tmp.mbr_nbr;
       TYPE rec_emp_stg is TABLE OF emp_STG%ROWTYPE index by PLS_INTEGER;
      stg_emp_stg rec_emp_stg   ;
       counter                 NUMBER         :=0;
       l_idx                  NUMBER;
       errors                  PLS_INTEGER;
        ins_errors EXCEPTION;
        PRAGMA EXCEPTION_INIT(ins_errors, -24381);
    BEGIN
        /* Copy values into local variables */
        l_pro:= pgm_id;
        l_schd_dt := schd_dt;
            /* Check if this is the first execution of the program; Get the last processed timestamp if the run is a restart */
        /* The restartability of this program is slightly differnt. Data_nbr =1 indicates that the last run was successful. The same program can*/
        /* be called multiple times for the same t47date. The restartability is designed accordingly */
        BEGIN
            SELECT /* SQL_TAG(<$RCSfile: t50lyt_can_hist_trans_load.sql,v $><2>) */
                   data_nbr,1,1,
                    NVL(key_text,'0')
            INTO l_data_nbr,
                 l_ts_1,
                 l_ts_2,
                 l_rest_mbr_nbr
            FROM inft
            WHERE TRUNC(key_ts)=TRUNC(l_schd_dt)
              AND pro_id = l_pro_id;
        EXCEPTION
            WHEN NO_DATA_FOUND THEN
              l_data_nbr:=9;
              NULL;
            WHEN OTHERS then
              g_ErrorString := g_log_error||' : SQLCODE = '||SQLCODE||' , ERRORMESSAGE = '||substr(SQLERRM, 1,200);
              RAISE;
        END;
           IF l_data_nbr = 1 THEN
          crm_msg.msg('Exiting:: Program already run');
          RETURN;
        ELSIF l_data_nbr = 0 THEN
          crm_msg.msg('This is a restart for the date '||l_schd_dt);
        ELSIF l_data_nbr= 9 THEN
            crm_msg.msg('First execution of this program');
       END IF;  
        BEGIN
            if l_data_nbr =9 THEN
             crm_msg.msg('This is the First execution of this program');
             INSERT
             INTO inft
               pgm_id,
               key_ts,
               key_text,
               data_nbr,
               data_ts,
               data_text
             VALUES
               l_pro,
               l_schd_dt,
               0,  --to hold empno
               sysdate,
               0   --no of recs processed
       COMMIT;
        END IF;
      END;
        OPEN curTrn(l_rest_empno);
        LOOP
          BEGIN
               FETCH curTrn BULK COLLECT INTO stg_emp_rec LIMIT 50000;
               IF nvl(curTrnRecs%ROWCOUNT,0)=0 THEN
                 crm_msg.msg('No Historical Data');
               END IF;
           FORALL i in 1..stg_emp_rec.COUNT SAVE EXCEPTIONS
             INSERT INTO emp values stg_emp_stg(i);
          counter := counter + 1;         
           g_recs_ins   := g_recs_ins+SQL%ROWCOUNT;
       EXCEPTION
          WHEN ins_errors THEN
             errors := SQL%BULK_EXCEPTIONS.COUNT;
            for j in 1..errors
            LOOP
            l_idx :=sql%bulk_exceptions(j).error_index;
          UPDATE emp SET src_id=stg_emp_rec(i).empno,ename=stg_emp_rec(i).ename,sal = stg_emp_rec(i).sal,
                 WHERE deptno= stg_emp_rec(i).deptno;  
           g_recs_upd := g_recs_upd + SQL%ROWCOUNT;
       ---END;
    -- EXIT WHEN curTrnRecs%NOTFOUND;
    -- END LOOP;
    -- CLOSE curTrnRecs;
      EXCEPTION
       WHEN OTHERS THEN
       g_ErrorString := g_log_error||' : SQLCODE = '||SQLCODE||' , ERRORMESSAGE = '||substr(SQLERRM, 1,200);
       crm_msg.msg(g_ErrorString);
       RAISE;
       END;
    END
        IF (counter >= l_CommitSize) THEN
            BEGIN /* To keep track of the timestamp of the last record processed inthe batch; for restartability */
                                            UPDATE   inft
                        SET      data_ts      = SYSDATE
                               ,key_text     = l_empno (idx)
                        WHERE    pgm_id       = l_pgm_id
                         AND     TRUNC(key_ts)= TRUNC(l_schd_dt);
                        COMMIT;
                    counter:=0;
                    END IF;
                EXCEPTION
                        WHEN OTHERS THEN
                          g_ErrorString := g_log_error||' : SQLCODE = '||SQLCODE||' , ERRORMESSAGE = '||substr(SQLERRM, 1,200);
                          crm_msg.msg(g_ErrorString);
                          RAISE;
                END;
       COMMIT;
      EXIT WHEN curTrn%NOTFOUND;
    --       END LOOP; --End of looping for the main cursor  fetch
       END LOOP;
      CLOSE curTrn;
       BEGIN /* Update the data_nbr to 1 to indicate the update is complete */
             UPDATE inft
             SET data_nbr=1,
                 data_ts=nvl(g_aud_upd_ts,data_ts),
                 data_text = counter
             WHERE pro_id = l_pgm_id
              AND TRUNC(key_ts)=TRUNC(l_schd_dt);
            COMMIT;
           EXCEPTION
             WHEN OTHERS THEN
               g_ErrorString := g_log_error||' : SQLCODE = '||SQLCODE||' , ERRORMESSAGE = '||substr(SQLERRM, 1,200);
               crm_msg.msg(g_ErrorString);
               RAISE;
        END;
        g_log_error := 'LOGGING SUMMARY';
        crm_msg.msg_tab('RECS UPDATED',g_recs_upd);
        crm_msg.msg_tab('RECS INSERTED',g_recs_ins);
        crm_msg.msg('Program ends Successfully');
    EXCEPTION
       WHEN OTHERS THEN
         g_ErrorString := g_log_error||' : SQLCODE = '||SQLCODE||' , ERRORMESSAGE = '||substr(SQLERRM, 1,200);
         crm_msg.msg(g_ErrorString);
    END;
    Elapsed: 00:00:00.00
      EXCEPTION
    ERROR at line 248:
    ORA-06550: line 248, column 3:
    PLS-00103: Encountered the symbol "EXCEPTION" when expecting one of the following:
    ( begin case declare end exit for goto if loop mod null
    pragma raise return select update when while with
    <an identifier> <a double-quoted delimited-identifier>
    <a bind variable> << continue close current delete fetch lock
    insert open rollback savepoint set sql execute commit forall
    merge pipe purge
    ORA-06550: line 255, column 5:
    PLS-00103: Encountered the symbol "IF" when expecting one of the following:
    ORA-06550: line 314, column 2:
    PLS-00103: Encountered the symbol "EXCEPTION" when expecting one of the following:
    ( begin case declare end exit for goto if loop mod null
    pragma raise return select update while with <an identifier>
    <a double-quoted delimited-
    ORA-06550: line 322, column 0:
    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
    end not pragma final instantiable order overriding static
    member constructor mapAppreciate ur help on the above?
    Edited by: user1014019 on Oct 3, 2011 6:45 AM
    Edited by: BluShadow on 03-Oct-2011 15:08
    added {noformat}{noformat} tags. Please read {message:id=9360002} and learn to do this yourself.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Please provide a code that can be compiled, the sample that you provided has compilation errors:
    Have made change to your code block, so that it compiles.Try to run the below code block:
    /* Formatted on 2011/10/03 21:08 (Formatter Plus v4.8.5) */
    DECLARE
       pgm_id              NUMBER                 := &1;
       schd_dt             DATE                   := TO_DATE ('&2', 'MM/DD/YYYY');
       l_schd_dt           DATE                   := NULL;
       l_pgm_id            NUMBER                 := 0;
       l_src_id            NUMBER;
       l_bulkcollectsize   NUMBER;
       l_trace_level       NUMBER                 := 0;
       l_commitallowance   inft1.prm_value%TYPE;
       v_insrcdcnt         NUMBER                 := 0;
       g_errorstring       VARCHAR2 (500)         := NULL;
       g_log_error         VARCHAR2 (300)         := NULL;
       g_recs_upd          NUMBER                 := 0;
       g_recs_ins          NUMBER                 := 0;
       g_aud_upd_ts        DATE                   := NULL;
       l_data_nbr          NUMBER                 := 0;
       l_ts_1              DATE                   := NULL;
       l_ts_2              DATE                   := NULL;
       l_rest_empno        emp_stg.mbr_nbr%TYPE   := '0';
       l_commitsize        NUMBER;
       CURSOR curtrnrecs (l_rest_empno VARCHAR)
       IS
          SELECT /* user_hash(tmp) PARALLEL(tmp,8) */ tmp.sec_lbl, tmp.empno,
                    tmp.ename, tmp.sal, tmp.deptno
              FROM emp_stg tmp
             WHERE tmp.mbr_nbr > l_rest_empno
          ORDER BY tmp.mbr_nbr;
       TYPE rec_emp_stg IS TABLE OF emp_stg%ROWTYPE
          INDEX BY PLS_INTEGER;
       stg_emp_stg         rec_emp_stg;
       counter             NUMBER                 := 0;
       l_idx               NUMBER;
       ERRORS              PLS_INTEGER;
       ins_errors          EXCEPTION;
       PRAGMA EXCEPTION_INIT (ins_errors, -24381);
    BEGIN
       /* Copy values into local variables */
       l_pro := pgm_id;
       l_schd_dt := schd_dt;
           /* Check if this is the first execution of the program; Get the last processed timestamp if the run is a restart */
       /* The restartability of this program is slightly differnt. Data_nbr =1 indicates that the last run was successful. The same program can*/
       /* be called multiple times for the same t47date. The restartability is designed accordingly */
       BEGIN
          SELECT /* SQL_TAG(<$RCSfile: t50lyt_can_hist_trans_load.sql,v $><2>) */
                 data_nbr, 1, 1, NVL (key_text, '0')
            INTO l_data_nbr, l_ts_1, l_ts_2, l_rest_mbr_nbr
            FROM inft
           WHERE TRUNC (key_ts) = TRUNC (l_schd_dt) AND pro_id = l_pro_id;
       EXCEPTION
          WHEN NO_DATA_FOUND
          THEN
             l_data_nbr := 9;
             NULL;
          WHEN OTHERS
          THEN
             g_errorstring :=
                   g_log_error
                || ' : SQLCODE = '
                || SQLCODE
                || ' , ERRORMESSAGE = '
                || SUBSTR (SQLERRM, 1, 200);
             RAISE;
       END;
       IF l_data_nbr = 1
       THEN
          crm_msg.msg ('Exiting:: Program already run');
          RETURN;
       ELSIF l_data_nbr = 0
       THEN
          crm_msg.msg ('This is a restart for the date ' || l_schd_dt);
       ELSIF l_data_nbr = 9
       THEN
          crm_msg.msg ('First execution of this program');
       END IF;
       BEGIN
          IF l_data_nbr = 9
          THEN
             crm_msg.msg ('This is the First execution of this program');
             INSERT INTO inft
                         (pgm_id, key_ts, key_text, data_nbr, data_ts, data_text
                  VALUES (l_pro, l_schd_dt, 0,                     --to hold empno
                                              SYSDATE, 0    --no of recs processed
             COMMIT;
          END IF;
       END;
       OPEN curtrn (l_rest_empno);
       LOOP
          BEGIN
             FETCH curtrn
             BULK COLLECT INTO stg_emp_rec LIMIT 50000;
             IF NVL (curtrnrecs%ROWCOUNT, 0) = 0
             THEN
                crm_msg.msg ('No Historical Data');
             END IF;
             FORALL i IN 1 .. stg_emp_rec.COUNT SAVE EXCEPTIONS
                INSERT INTO emp
                     VALUES stg_emp_stg (i);
             counter := counter + 1;
             g_recs_ins := g_recs_ins + SQL%ROWCOUNT;
          EXCEPTION
             WHEN ins_errors
             THEN
                ERRORS := SQL%BULK_EXCEPTIONS.COUNT;
                FOR j IN 1 .. ERRORS
                LOOP
                   l_idx := SQL%BULK_EXCEPTIONS (j).ERROR_INDEX;
                   UPDATE emp
                      SET src_id = stg_emp_rec (i).empno,
                          ename = stg_emp_rec (i).ename,
                          sal = stg_emp_rec (i).sal
                    WHERE deptno = stg_emp_rec (i).deptno;
                   g_recs_upd := g_recs_upd + SQL%ROWCOUNT;
                END LOOP;
    --END;
             -- EXIT WHEN curTrnRecs%NOTFOUND;
    --END LOOP;
    --CLOSE curTrnRecs;
             WHEN OTHERS
             THEN
                g_errorstring :=
                      g_log_error
                   || ' : SQLCODE = '
                   || SQLCODE
                   || ' , ERRORMESSAGE = '
                   || SUBSTR (SQLERRM, 1, 200);
                crm_msg.msg (g_errorstring);
                RAISE;
          END;
          IF (counter >= l_commitsize)
          THEN
             BEGIN
    /* To keep track of the timestamp of the last record processed inthe batch; for restartability */
                UPDATE inft
                   SET data_ts = SYSDATE,
                       key_text = l_empno (idx)
                 WHERE pgm_id = l_pgm_id AND TRUNC (key_ts) = TRUNC (l_schd_dt);
                COMMIT;
                counter := 0;
             EXCEPTION
                WHEN OTHERS
                THEN
                   g_errorstring :=
                         g_log_error
                      || ' : SQLCODE = '
                      || SQLCODE
                      || ' , ERRORMESSAGE = '
                      || SUBSTR (SQLERRM, 1, 200);
                   crm_msg.msg (g_errorstring);
                   RAISE;
             END;
          END IF;
          COMMIT;
          EXIT WHEN curtrn%NOTFOUND;
    --       END LOOP; --End of looping for the main cursor  fetch
       END LOOP;
       CLOSE curtrn;
       BEGIN     /* Update the data_nbr to 1 to indicate the update is complete */
          UPDATE inft
             SET data_nbr = 1,
                 data_ts = NVL (g_aud_upd_ts, data_ts),
                 data_text = counter
           WHERE pro_id = l_pgm_id AND TRUNC (key_ts) = TRUNC (l_schd_dt);
          COMMIT;
       EXCEPTION
          WHEN OTHERS
          THEN
             g_errorstring :=
                   g_log_error
                || ' : SQLCODE = '
                || SQLCODE
                || ' , ERRORMESSAGE = '
                || SUBSTR (SQLERRM, 1, 200);
             crm_msg.msg (g_errorstring);
             RAISE;
       END;
       g_log_error := 'LOGGING SUMMARY';
       crm_msg.msg_tab ('RECS UPDATED', g_recs_upd);
       crm_msg.msg_tab ('RECS INSERTED', g_recs_ins);
       crm_msg.msg ('Program ends Successfully');
    EXCEPTION
       WHEN OTHERS
       THEN
          g_errorstring :=
                g_log_error
             || ' : SQLCODE = '
             || SQLCODE
             || ' , ERRORMESSAGE = '
             || SUBSTR (SQLERRM, 1, 200);
          crm_msg.msg (g_errorstring);
    END;Hope its useful.
    Cheers

  • Executing a PL/SQL block (using Toplink)

    I have a scenario where I need to execute some fairly complex PL/SQL blocks. As a tester, I am attempting to execute the following simple block:
    declare val NUMBER := 1; begin val := 2; end;
    Both wrapping this in an SQLCall, or a DataReadQuery give the following exception. What is the best way to execute a PL/SQL block using Toplink?
    Local Exception Stack:
    Exception [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-00900: invalid SQL statement
    Error Code: 900
    Call: declare val NUMBER := 1; begin val := 2; end;
    Query:DataReadQuery()
         at oracle.toplink.exceptions.DatabaseException.sqlException(DatabaseException.java:290)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:570)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:442)
         at oracle.toplink.threetier.ServerSession.executeCall(ServerSession.java:453)
         at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:117)
         at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:103)
         at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:174)
         at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeSelect(DatasourceCallQueryMechanism.java:156)
         at oracle.toplink.queryframework.DataReadQuery.executeNonCursor(DataReadQuery.java:118)
         at oracle.toplink.queryframework.DataReadQuery.executeDatabaseQuery(DataReadQuery.java:110)
         at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:603)
         at oracle.toplink.queryframework.DataReadQuery.execute(DataReadQuery.java:96)
         at oracle.toplink.publicinterface.Session.internalExecuteQuery(Session.java:2062)
         at oracle.toplink.publicinterface.Session.executeQuery(Session.java:981)
         at oracle.toplink.publicinterface.Session.executeQuery(Session.java:938)

    Could you try the following:
            Session s = ...
            DataModifyQuery dmq = new DataModifyQuery();
            SQLCall sqlCall = new SQLCall();
            sqlCall.setQueryString(
                "declare\n" +
                "  val NUMBER := 1;\n" +
                "begin\n" +
                "  val := 2;\n" +
                "end;");
            sqlCall.setQuery(dmq);
            dmq.setCall(sqlCall);
            s.executeQuery(dmq);

  • 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

  • Tune the PL/SQL block with SQL_ID

    Hi There,
    I have found some recommendation in ADDM report as follows.
    "" Action
    Tune the PL/SQL block with SQL_ID "48trcns4mx5bk". Refer to the "Tuning
    PL/SQL Applications" chapter of Oracle's "PL/SQL User's Guide and
    Reference".
    Related Object ""
    can any one let me how to Tune the PL/SQL block with SQL_ID?
    looking forward.
    Db: 11.1.0.7
    OS: OracleLinux5-86*64
    Regards,
    Mohsin

    Hi,
    you can't tune a PL/SQL block directly. Instead, you'll need to profile it first (i.e. see how much time SQL statements inside it consume) using dbms_profiler or some other tool. If you find that the problem is that some SQL is called too frequently because of flawed PL/SQL logic, then you'll need to address that. Otherwise, you'll need to take the top time consuming statement(s) and tune it (them).
    Best regards,
    Nikolay

  • How to use Associative Array in sql query?

    Hello,
    I have a problem on using Associative Array variable on query; and my query is similar to the one below;
    TYPE OTHERGENERICS IS TABLE OF NUMBER(10) INDEX BY BINARY_INTEGER;
    othersGenerics OTHERGENERICS;
    CURSOR cursor_othersGenerics IS
    select master.GENERICCODEID
    from ASMTRG_ARTICLEMASTER master
    join ASMTRG_ARTICLEMAP map on MAP.ARTICLECODEID = MASTER.ID
    group by MASTER.GENERICCODEID
    minus
    select FGG.GENERICCODEID
    from asmtrg_icfocusgroup fg
    join asmtrg_icfocusgrpchannel fgc on FGC.GROUPID = FG.ID and fgc.isactive=1
    join asmtrg_icfocusgengroup fgg on FGG.GROUPID = FG.ID and FGg.ISACTIVE=1
    where fgc.channelid=1 and fg.isactive = 1
    group by FGG.GENERICCODEID;
    BEGIN
    OPEN cursor_othersGenerics;
    FETCH cursor_othersGenerics BULK COLLECT INTO othersGenerics;
    CLOSE cursor_othersGenerics;
    SELECT icfrd.*,
    CASE
    WHEN EXISTS(select ta.genericcodeid from <???XXX???> ta where ta.genericcodeid = icfgrp.genericcodeid) THEN -1
    ELSE icfrd.icfgroupid
    END CLASSIFICATION
    FROM ASMTRGVIW_ICFOCUSREPORTDATA icfrd
    LEFT JOIN ASMTRG_ICFOCUSGROUP icfgrp on icfrd.ICFGROUPID = icfgrp.ID
    WHERE (channelId IS NULL OR icfrd.CHANNELID = channelId)
    AND (asmCodeId IS NULL OR icfrd.ASMCODEID = asmCodeId)
    AND (yearId IS NULL OR icfrd.YEARID = yearId)
    AND (monthId IS NULL OR icfrd.MONTHID = monthId)
    END;
    By the way this is a part of my function.
    The "othersGenerics" is my associative array variable and <???XXX???> is the place where I need to use my "othersGenerics" array to check. So far I've tried
    "select ta.genericcodeid from table(cast(otherGenerics as OTHERGENERICS)) ta where ta.genericcodeid = icfgrp.genericcodeid",
    "select ta.genericcodeid from table(otherGenerics) ta where ta.genericcodeid = icfgrp.genericcodeid",
    "select ta.genericcodeid from otherGenerics ta where ta.genericcodeid = icfgrp.genericcodeid"
    and these are not working.
    What is your suggestions?

    Your type will have to be created as an independent object in your schema. So CREATE TYPE cannot be in your function declaration, it has to be outside it. (And then the line inside your declaration that defines the type will have to be removed.)
    But now I can see that you use this array as a kind of "temporary lookup table" - you populate the array and then use it for lookup in your select statement. An alternative way of doing this could be like this completely without arrays:
    with othergenerics as (
      select master.GENERICCODEID
      from ASMTRG_ARTICLEMASTER master
      join ASMTRG_ARTICLEMAP map on MAP.ARTICLECODEID = MASTER.ID
      group by MASTER.GENERICCODEID
      minus
      select FGG.GENERICCODEID
      from asmtrg_icfocusgroup fg
      join asmtrg_icfocusgrpchannel fgc on FGC.GROUPID = FG.ID and fgc.isactive=1
      join asmtrg_icfocusgengroup fgg on FGG.GROUPID = FG.ID and FGg.ISACTIVE=1
      where fgc.channelid=1 and fg.isactive = 1
      group by FGG.GENERICCODEID
    SELECT icfrd.*,
    CASE
    WHEN EXISTS(select ta.genericcodeid from othergenerics ta where ta.genericcodeid = icfgrp.genericcodeid) THEN -1
    ELSE icfrd.icfgroupid
    END CLASSIFICATION
    FROM ASMTRGVIW_ICFOCUSREPORTDATA icfrd
    LEFT JOIN ASMTRG_ICFOCUSGROUP icfgrp on icfrd.ICFGROUPID = icfgrp.ID
    WHERE (channelId IS NULL OR icfrd.CHANNELID = channelId)
    AND (asmCodeId IS NULL OR icfrd.ASMCODEID = asmCodeId)
    AND (yearId IS NULL OR icfrd.YEARID = yearId)
    AND (monthId IS NULL OR icfrd.MONTHID = monthId)
    ...The with clause (subquery factoring) you can think of as a kind of temp table called othergenerics created "on-the-fly".
    The optimizer may decide to actually create a temp table for you and use in the lookup, or it may decide to rewrite the query into suitable joins or nested loops or hashing - whatever the optimizer decides will be the optimal way of doing things :-)
    So unless you use your array other places in your function, I would recommend dropping the array completely, skip populating an array, and instead use a with clause for your temporary lookup.

  • How to obtain the transformed SQL query using SEM_MATCH

    Dear all,
    Is it possible to get the transformed relational SQL query when using the SEM_MATCH prefix, by querying directly on the database. We are able to obtain the relational SQL query using Joseki/Jena, however this is not the way to go for us. We would like (if possible) to get it straight from the oracle database by logging or something.
    Kind regards.
    Max

    Hi Max,
    Just to clarify. What SEM_MATCH prefix are you talking about?
    A SEM_MATCH based query is indeed a SQL query as SEM_MATCH is a SQL table function. So if you don't want to go through Java APIs or web service endpoint, then running SEM_MATCH directly should give you what you need. Or maybe you just want to see the underlying generated (from SEM_MATCH) SQL query. If that is true, can you please tell us why?
    Thanks,
    Zhe Wu

  • REP-1437: Run time error in the PL/SQL development environment (DE).

    I have a report that has always worked. Now I get the following error
    REP-0003: Warning: Unable to open global preference file.
    Starting report STCONF6 [Mon Nov 10 21:38:59 2008] ...
    REP-1437: Run time error in the PL/SQL development environment (DE).
    PDE-PSD001 Could not resolve reference to <Unknown Program Unit> while loading <Unknown> <Unknown>.
    End report STCONF6 [Mon Nov 10 21:39:10 2008].
    What is it? I DON'T know.
    Regards SILVIA

    I recall my report from a form, I get the parameter form with my parameters, then click on the traffic light to run and the error appears here
    Silvia

  • Error connectiong with teh SQL DB using the domain user

    Hello,
    I am installing BCM 7 SP02 on windows server 2008 / SQL server 2008 R2.
    i have insatlled the Virtual Units and added them to the HAC. When i try to launch them i have always error in the Core VU in the CEM component. in the log of the call dispatcher of the CORE VU i got the following:
    10:46:59.805 (05488/IpcWorker) WRN> Connection/01B84660 [172.29.6.41:21000<-172.29.6.39:53329]: Disconnecting due protocol error: Connection attempt with unidentified remote peer from
    10:47:00.403 (05636/BCMApplicationThread) ERR> Failed to initialize WCDService - near failure
    10:47:02.405 (02000/main          ) ALW> Watchdog: Application instance stopped
    10:49:07.094 (03452/main) ALW> Started [CallDispatcher] version [7.0.2.0] in virtual unit [Elis_Core] in computer [hostname] with process id [362c9234-437f-43fe-8daa-d11057fd38d6]
    and in the DataCollector ti have the folowing:
    16:25:09.396 (05544/TransactionHandler) ERR> Failed to connect to database destination [hostname- BCM_DEV_Monitoring_History] using [Driver=SQL Server;Server=hostname;Database=BCM_DEV_Monitoring_History;Trusted_Connection=no;UID=<protected>;PWD=<protected>;]
    16:25:09.396 (05544/TransactionHandler) ERR> SQLDriverConnect failed (/28000/[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'DOMAIN\adminbcm_dev'.) : Connected = [false]
    16:25:09.396 (05544/TransactionHandler) ERR> Database = [], SQLState = [28000], errorCode = [18456] : [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'DOMAIN\adminbcm_dev'.
    from the log of the SQl i saw the the domainuser adminbcm_dev is trying to connect to the DB as sql user authentication:
    01/09/2012 15:58:47,Logon,Unknown,Login failed for user 'DOMAIN\adminbcm_dev'. Reason: Attempting to use an NT account name with SQL Server Authentication. [CLIENT: IP]
    The DB was created using the same user and no error were generated, and the same user have the SA rights in the DB.
    In the VU of the Agents , Core and DB, the windows authentication option is checked and no password was provided.
    Does the "Trusted_Connection" should be YES, if yes how to change it?
    Thanks in advance for your help.

    The databse BCM_DEV_Monitoring_History  was created in the SQL server.
    I got just one error several hours hours ago in the CEM service:
    10:14:39.626 (01256/Message Receiver) ERR> Connection/03D1567C [0.0.0.0:0->172.29.6.41:21009]: Failed to receive from [172.29.6.41:21009] : Socket = [-1], BytesRead = [0] : TcpConnection::ReceiveSync, WSARecv failed - 10038 (0x2736) An operation was attempted on something that is not a socket.
    All the other errors are related to the Datacollectore.
    14:23:23.608 (01800/TransactionHandler) ERR> Failed to connect to database destination [MD1ODYWSV1 - BCM_DEV_Monitoring_History] using [Driver=SQL Server;Server=MD1ODYWSV1;Database=BCM_DEV_Monitoring_History;Trusted_Connection=no;UID=<protected>;PWD=<protected>;]
    14:23:23.608 (01800/TransactionHandler) ERR> SQLDriverConnect failed (/28000/[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'DOMELIS\adminbcm_dev'.) : Connected = [false]
    14:23:23.608 (01800/TransactionHandler) ERR> Database = [], SQLState = [28000], errorCode = [18456] : [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'DOMELIS\adminbcm_dev'.
    Use Windows Authentication for Database Connections ELIS_DEV_DB:YES
    Configuration Database Server Address or Name           ELIS_DEV_DB:MD1ODYWSV1
    Configuration Database Name                                          ELIS_DEV_DB:BCM_DEV
    Configuration Database User Name                                 {[BCM_DEV_00].[HAC_SERVICE_USER]}
    Configuration Database Password                                   nothing was added stayed Blank
    Internal Server Certificate in Use                                       checked
    Internal Server Certificate Common Name                          BCM.elis.priv
    Internal Server Certificate Issuer                                       elis-MD1ODYWSV1-CA
    Internal Server Certificate Store                                         HKLM/My

  • ORA-06550 - while compiling the PL/SQL block.

    I am trying a to populate a table based on the below pl/sql block
    Declare
    temp source.source%type;
    tregion varchar2(40);
    tversion varchar2(40);
    tsource varchar2(100);
    Cursor c1 is
    Select * from Source;
    Begin
    Open c1;
    Loop
    fetch c1 into temp;
    select REGION, VERSION, SOURCE into tregion, tversion, tsource from QUOTE_LETTERS_MASTER where SOURCE = temp AND REGION = 'eSource';
    insert into esource values(tregion, tversion, tsource);
    Exception
    when no_data_found then
    insert into esource values('No eSource',' ',temp.source);
    exit when c1%notfound;
    End Loop;
    close c1;
    end;

    yes, there are more than one rows that is returned when i do a Select Into statement.
    I am trying to resolve by using a cursor C2 inside the already existing cursor C1, i will use a inner loop to get the select statement value to cursor c2 then i will assign the vlaues the variables, then once i read all the values of cursor c2 i will exit inner loop and go to outer loop to read the next value of c1 and then again go to cursor c2 and inner loop.
    Do you think it will work ?
    Thank you,
    rakesh
    I have pasted the code below.
    Declare
    temp1 source.source%type;
    temp2 QUOTE_LETTERS_MASTER%rowtype;
    Cursor c1 is
    Select * from Source;
    Begin
    open c1;
    loop
    fetch c1 into temp;
    cursor c2 is
    select region, version, source from QUOTE_LETTERS_MASTER where SOURCE = temp AND REGION = 'eSource';
    open c2;
    loop
    begin
    fetch c2 into temp2;
    insert into esource values(temp2.region, temp2.version, temp2.source);
    Exception
    when no_data_found then
    insert into esource values('No esource',' ',temp);
    exit when c2%notfound;
    end loop;
    close c2;
    exit when c1%notfound;
    end loop;
    close c1;
    end;
    But is giving this error : - ORA-06550: line 10, column 13:
    ***PLS-00103: Encountered the symbol "C2" when expecting one of the following:
    ***:= . ( @ % ;
    ***1. Declare***
    ***2. temp1 source.source%type;
    ***3. temp2 QUOTE_LETTERS_MASTER%rowtype;
    Edited by: rakesh119 on Apr 10, 2013 11:08 AM

  • Accepting user input and executing a PL/SQL block using it

    Hi All,
    I am working on a requirement wherein I have to accept values from the user for the various arguments to be supplied to a PL/SQL block and then execute it using these values. For now, I am using the following logic:
    PROMPT Enter value for the Category
    ACCEPT cCategory CHAR PROMPT 'Category:'
    DECLARE
    cCategry CHAR(1) := '&cCategory';
    BEGIN
    DBMS_OUTPUT.PUT_LINE('The value of the Category as entered by you is' || cCategory);
    END;
    PROMPT Press y if you want to proceed with the current values, or press n if you want to re-enter the values
    ACCEPT cChoice CHAR Prompt 'Enter y or n:'
    DECLARE
    cCategry CHAR(1) := '&cCategory';
    sErrorCd VARCHAR2(256);
    sErrorDsc VARCHAR2(256);
    BEGIN
    IF '&cChoice' = 'y'
    THEN
    DBMS_OUTPUT.PUT_LINE('Starting with the process to execute the stored proc');
    --- schema1.package1.sp1(cCategry, sErrorCd, sErrorDsc);
    --- DBMS_OUTPUT.PUT_LINE('Error Code :' || sErrorCd);
    --- DBMS_OUTPUT.PUT_LINE(' Error Description :' || sErrorDsc);
    ELSIF '&cChoice' = 'n'
    THEN
    Now I want that the proc again start executing in the loop from the 1st line i.e. PROMPT Enter value for the Category. However i see that this is not possible to do that PROMPT statements and accepting user inputs execute only on the SQL prompt and not inside a PL/SQL block.
    Is there an alternate method to establish this?
    Thanks in advance.

    Hi,
    You can write a genric procedure to achive the desired output. Pass 'Y' or 'N' in the procedure.
    Call that procedure in simple pl/sql block during runtime using substituton operator.
    For ex
    create or replace procedure p1(category_in in varchar2)
    IS
    BEGIN
    if (category_in='Y')
    then
    prcdr1()
    /** Write your logic here ***/
    elsif(category_in='N') then
    prcdr2()
    /** write your logic here***/
    end if;
    exception
    /***write the exception logic ***/
    end p1;
    Begin
    p1('&cat');
    end;Regards,
    Achyut K
    Edited by: Achyut K on Aug 6, 2010 5:20 AM

  • Calling a SQL script from the PL/SQL block.

    Hello All,
    I am using oracle 11g database.
    My requirment is as follows. I have a SQL script to alter the table. But before alter the table I need to test some condition , if the condition satisfy then I have to alter the table through the SQL script. For the checking the condition I have to use the plsql block and inside I need to call the SQL script.
    Can I call a SQL script from PL/SQL block, if yes then how?
    I am tring to use START, RUN and @ command but it is throughing error.
    Thanks
    SUN

    [PL/SQL manual|http://download.oracle.com/docs/cd/B10501_01/server.920/a96540/functions55a.htm#77600] Ctrl-F start, finds nothing. [SQLPlus manual|http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/toc.htm] Ctrl-F start finds this. Isn't it wonderful that Oracle documents this stuff so we don't have to guess.
    Can I call a SQL script from PL/SQL block, if yes then how? No.
    You could call the stored procedure in a SQL*Plus script before the alter table and have it raise an exception if the condition is not met and have the script quit when there is an error.

  • Error at the time of execution using weblogic10

    Hi All,
              i am new in the implementetion of weblogic10. anyhow i am able to deploy the message driven bean application successfully, but getting the following errors at the time of execution:
              Error 500--Internal Server Error
              java.lang.NullPointerException
                   at jsp_servlet.__calculator._jspService(__calculator.java:137)
                   at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
                   at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:226)
                   at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:124)
                   at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
                   at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
                   at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3370)
                   at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
                   at weblogic.security.service.SecurityManager.runAs(Unknown Source)
                   at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2117)
                   at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2023)
                   at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1359)
                   at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)
                   at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)
              so requesting all members of bea to suggest me what to do?
              regards
              mina

    hi,
              in the total application i ve nt used calculator.java anywhere. my client file is as following:
              <%@ page import="example.*, javax.naming.*, javax.jms.Queue, java.text.*,javax.jms.*,java.sql.Timestamp"%>
              <%
              if ("send".equals(request.getParameter ("action"))) {
              QueueConnection cnn = null;
              QueueSender sender = null;
              QueueSession sess = null;
              Queue queue = null;
              try {
              InitialContext ctx = new InitialContext();
              queue = (Queue) ctx.lookup("java:comp/env/jms/testQueue");
              QueueConnectionFactory factory =
              (QueueConnectionFactory) ctx.lookup("java:comp/env/jms/connectionFactory");
              cnn = factory.createQueueConnection();
              sess = cnn.createQueueSession(false,
              QueueSession.AUTO_ACKNOWLEDGE);
              } catch (Exception e) {
              e.printStackTrace ();
              TextMessage msg = sess.createTextMessage(
              request.getParameter ("start") + "," +
              request.getParameter ("end") + "," +
              request.getParameter ("growthrate") + "," +
              request.getParameter ("saving")
              // The sent timestamp acts as the message's ID
              long sent = System.currentTimeMillis();
              msg.setLongProperty("sent", sent);
              sender = sess.createSender(queue);
              sender.send(msg);
              // sess.commit ();
              sess.close ();
              %>
              <html>
              <head><meta http-equiv="REFRESH" content="3;URL=check.jsp?sent=<%=sent%>"></head>
              <body>
              Please wait while I am checking whether the message has arrived.
              Go back to Calculator
              </body>
              </html>
              <%
              return;
              } else {
              int start = 25;
              int end = 65;
              double growthrate = 0.08;
              double saving = 300.0;
              %>
              <html>
              <body>
              <p>Investment calculator
              <form action="calculator.jsp" method="POST">
              <input type="hidden" name="action" value="send">
              <b> Start age = <input type="text" name="start" value="<%=start%>">
              End age = <input type="text" name="end" value="<%=end%>">
              Annual Growth Rate = <input type="text" name="growthrate" value="<%=growthrate%>">
              Montly Saving = <input type="text" name="saving" value="<%=saving%>"></b>
              <input type="submit" value="Calculate">
              <INPUT type="button" value="Close Window" onClick="window.close()">
              </form>
              </p>
              </body>
              </html>
              <%
              return;
              %>
              please check out my JNDI name in this program, and suggest me what to do.
              Thanks
              Minakshi

  • Error connection Oracle to SQL Server using tg4msql, HELP Please....

    Hi, my name is Gregory,
    I am a newbie in oracle forum here, and need some help from the database guru here...
    I am trying to create the database link from Oracle database to SQL Server.
    here are the information:
    host name of OracleDB = a3500
    host name/Ip of SQL Server = 172.16.1.58
    SQL Server database name = CKS_VSSD
    i had create the new initntchsql.ora file under tg4msql\admin folder, and i also had create the new listener.
    here is the file contains
    ############ initntchsql.ora ###################
    HS_FDS_CONNECT_INFO="SERVER=172.16.1.58;DATABASE=CKS_VSSD"
    HS_FDS_TRACE_LEVEL=OFF
    HS_FDS_RECOVERY_ACCOUNT=RECOVER
    HS_FDS_RECOVERY_PWD=RECOVER
    ############ listener.ora ######################
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = a3500)(PORT = 1521))
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    (ADDRESS LIST=
    (ADDRESS = (PROTOCOL = TCP)(HOST = a3500)(PORT = 1521))
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = C:\oracle\ora92)
    (PROGRAM = extproc)
    (SID_DESC =
    (GLOBAL_DBNAME = orclems)
    (ORACLE_HOME = C:\oracle\ora92)
    (SID_NAME = orclems)
    (SID_DESC =
    (GLOBAL_DBNAME = cps4)
    (ORACLE_HOME = C:\oracle\ora92)
    (SID_NAME = cps4)
    (SID_DESC =
    (PROGRAM = tg4msql)
    (SID_NAME = NTCHSQL)
    (ORACLE_HOME = C:\Oracle\Ora92)
    #################### tnsnames.ora #################
    NTCHSQL =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = a3500)(PORT = 1521))
    (CONNECT_DATA =
    (SID = NTCHSQL)
    (HS = OK)
    and i had created databaselink named ntchsql
    then i select statement:
    select * from vssd50@ntchsql
    and error occured:
    ORA-02068: Following severe error from NTCHSQL
    ORA-28511: lost RPC connection to heterogenous remote agent using SID=%s
    ORA-28509: unable to establish a connection to non-Oracle system
    did i missed something on the configuration?
    oya... i also see other thread that said i have to comment
    SQLNET.AUTHENTICATION_SERVICES = (NTS)
    from sqlnet.ora file, and i did that, and the error still the same...
    can somebody help me?

    sorry my fault hehehee....
    here is the lsnrctl stat
    LSNRCTL> stat
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=a3500)(PORT=1521))(ADDRE
    SS LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=a3500)(PORT=1521))))
    STATUS of the LISTENER
    Alias LISTENER
    Version TNSLSNR for 32-bit Windows: Version 9.2.0.4.0 - Produc
    tion
    Start Date 16-FEB-2006 15:30:24
    Uptime 0 days 0 hr. 26 min. 57 sec
    Trace Level off
    Security OFF
    SNMP OFF
    Listener Parameter File C:\oracle\ora92\network\admin\listener.ora
    Listener Log File C:\oracle\ora92\network\log\listener.log
    Listening Endpoints Summary...
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=a3500)(PORT=1521))(ADDRESS LIST=(ADD
    RESS=(PROTOCOL=TCP)(HOST=a3500)(PORT=1521))))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC0ipc))(ADDRESS L
    IST=(ADDRESS=(PROTOCOL=TCP)(HOST=a3500)(PORT=1521))))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=a3500)(PORT=8080))(Presentation=HTTP
    )(Session=RAW))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=a3500)(PORT=2100))(Presentation=FTP)
    (Session=RAW))
    Services Summary...
    Service "NTCHSQL" has 1 instance(s).
    Instance "NTCHSQL", status UNKNOWN, has 1 handler(s) for this service...
    Service "PLSExtProc" has 1 instance(s).
    Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
    Service "cps4" has 2 instance(s).
    Instance "cps4", status UNKNOWN, has 1 handler(s) for this service...
    Instance "cps4", status READY, has 1 handler(s) for this service...
    Service "cps4XDB" has 1 instance(s).
    Instance "cps4", status READY, has 1 handler(s) for this service...
    Service "orclems" has 1 instance(s).
    Instance "orclems", status UNKNOWN, has 1 handler(s) for this service...
    The command completed successfully
    thanks for helping.... :-)

Maybe you are looking for

  • Fustration with FCP and trying to edit in HD

    Someone Please Help! Over the last several days I have been trying to start to be able to edit in HD so that I can ultimately be able to produce a Blu-Ray option for my customers by June 2010 (i'm trying to get an early jump on a what I suspect is a

  • RegEx Problem with flag COMMENTS

    Hello, I have the following Exception: java.util.regex.PatternSyntaxException: Unclosed group near index 9 when my program is running with this flags: Pattern patt = Pattern.compile("^(@#@.+)$", Pattern.MULTILINE | Pattern.COMMENTS);but when I run th

  • Unknown outbound adapter (name = SOAP)

    Hi folks, I am working on a PROXY --> PI --> SOAP scenario. I get this error in PI'S SXMB_MONI. How to resolve this issue and what is causing it? <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <!--  Call Adapter  --> <SAP:Error xmlns:SAP="h

  • Please send me exiftool output for your camera (xml format).

    I am writing a metadata plugin that incorporates at least some of the metadata from raw files that Adobe "missed" - this metadata will be displayed in the right-hand panel in the Library module, and be available for Library Filtering and Smart Collec

  • Switch workspace in command line interface

    Hi, I'd like to write a script that launches some applications, but in different workspaces. Is there any tool or built-in command to switch (and maybe also rename) workspace from a command line interface (terminal, script...)??? Thanks a lot