PL/SQL Block with Cursor

I was trying to create a PL/SQL block where I am trying to call all the SQL Plans and then drop them one by one. Here is how I am doung -
SET SERVEROUT ON;
DECLARE
EXECSTR VARCHAR2(50);
v_plans_dropped pls_integer;
CURSOR C1 IS SELECT SQL_HANDLE FROM DBA_SQL_PLAN_BASELINES;
BEGIN
FOR I IN C1 LOOP
EXECSTR := ''''||I.SQL_HANDLE||'''';
v_plans_dropped:=dbms_spm.drop_sql_plan_baseline(sql_handle=>EXECSTR);
END LOOP;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('ERROR while dropping SQL PLAN: ' || SQLCODE || ' : ' || SQLERRM);
END;
This is giving me error like - ERROR while dropping SQL PLAN: -38131 : ORA-38131: specified SQL handle
'SYS_SQL_1470897e7b72c982' does not exist
Whereas this SQL Plan is there in the baseline - SELECT sql_handle FROM dba_sql_plan_baselines;
SQL_HANDLE
SYS_SQL_1470897e7b72c982
SYS_SQL_75ac336a8071cb06
SYS_SQL_269cdcd4862f8685
SYS_SQL_269cdcd4862f8685
SYS_SQL_0ffdb3bddbe422e2
SYS_SQL_14d81bbae4a7cc93
SYS_SQL_5c512b58e7795ba2
SYS_SQL_33515785e80b75d0
Above PL/SQL block should be same as like deleting it one by one -
DECLARE
v_plans_dropped pls_integer;
BEGIN
v_plans_dropped:=dbms_spm.drop_sql_plan_baseline(sql_handle=>'SYS_SQL_1470897e7b72c982');
END;
If I run this then it will be sucessul but when I run under a PL/SQL block using cursor then it is giving me error ORA-38131.
Can you please tell me where I am going wrong here.
Thanks for your time!

I have this PL/SQL block -
DECLARE
v_plans_dropped pls_integer;
CURSOR C1 IS SELECT SQL_HANDLE FROM DBA_SQL_PLAN_BASELINES;
BEGIN
FOR I IN C1 LOOP
v_plans_dropped:=dbms_spm.drop_sql_plan_baseline(sql_handle=>I.SQL_HANDLE);
END LOOP;
END;
Requirement - This PL/SQL block should read all the records from DBA_SQL_PLAN_BASELINES table and drop all the plans one by one.
Problem - It gives me error like this -
SQL> 2 3 4 5 6 7 8 9 DECLARE
ERROR at line 1:
ORA-38131: specified SQL handle SYS_SQL_45c1170505dda9a9 does not exist
ORA-06512: at "SYS.DBMS_SPM", line 2444
ORA-06512: at line 6
Analysis: When I ran it 4 times, it showed me that the remaining records after the pl/sql run was like -
SQL> SELECT COUNT(*) FROM DBA_SQL_PLAN_BASELINES;
After First Run -
COUNT(*)
33429
After Second Run -
COUNT(*)
33255
After Third Run -
COUNT(*)
33228
After Fourth Run -
COUNT(*)
32988
So, it deletes records but errors out in between. Is it because the PL/SQL block/cursor is not structured properly?
Thanks for your advice!

Similar Messages

  • Cell Offload will Happen for pl/sql Block with variables

    Hello Experts,
    i am working on procedures on exadata now. i was confused with cell offload in exadata. somehow offload is not happening when i ran the sql statement in in pl/sql block with variables.
    here are my findings.
    when i ran insert into from select with values at toad, my query response time is very good. the total process is completed in less than a minute.
    i checked offload is happening.
    same sql statement is placed in plsql block with variable, procedure is taking lot of time and it is not completing. this case offload is not happening.
    is it true, if i use variables in pl/sql block will not use cell offload and smart scan?
    if yes, what is the work around.
    Thanks
    #! Pavan

    Hello Marc,
    Thanks for quick response.
    when i ran the query with literals in toad session i am getting response.
    when i run it with pl/sql block , block is not completing at all.
    here is the plsql block:
    My Apologies for sending big code,with out proper format.
    DECLARE
    P_BUSINESS_DATE DATE;
    P_BATCH_ID NUMBER;
    UTC_OFFSET NUMBER;
    BEGIN
    P_BUSINESS_DATE := to_date('02/01/2012', 'MM/DD/YYYY');
    P_BATCH_ID := 1;
    UTC_OFFSET := 0;
    INSERT /*+ APPEND */ INTO UPL_CLIENT_tbl
    ( reportdate,
    LastName,
    FirstName,
    MiddleInitial,
    AccountNumber,
    Address,
    City,
    State,
    Zip,
    HomePhone,
    WorkPhone,
    BirthDate,
    Age,
    Sex,
    NumberOfChildren,
    Occupation,
    LeadSource,
    Consultant,
    ProgramDirector,
    CallTaker,
    LeadDate,
    FirstVisitDate,
    LastVisitDate,
    BillType,
    ClientType,
    PreviousClientType,
    AppointmentDate,
    DoctorLetterRequired,
    OneYearPermStabilizationDate,
    UnlimitedPermStabilizationDate,
    MaritalStatus,
    ReferrerName,
    ReferrerCentreID,
    CentreID,
    PaymentDateOne,
    PaymentAmountOne,
    PaymentDateTwo,
    PaymentAmountTwo,
    PaymentDateThree,
    PaymentAmountThree,
    PaymentDateFour,
    PaymentAmountFour,
    LibraryPurchased,
    BalanceDue,
    FoodNSFBalance,
    ProductNSFBalance,
    ProgramNSFBalance,
    StartWeight,
    CurrentWeight,
    GoalWeight,
    Height,
    DateGoalWeightAchieved,
    DateSuccessPlusPurchased,
    ReturnToActiveDate,
    VersionNumber,
    HalfWayDate,
    LastLSCDate,
    LastUpdatedDate,
    VitaminWaiverSigned,
    LastSupplementPurchaseDate,
    LastSupplementCodePurchased,
    LastTotalSupplementSupplyCycle,
    LastAddtlSupplPurchaseDate,
    LastAddtlSupplCodePurchased,
    LastAddtlSupplSupplyCycle,
    DiabetesClient,
    DietControlled,
    TakingOralMed,
    TakingInsulin,
    EmailId,
    CTADate,
    RWLDate,
    Address2)
    (SELECT /*+ full(S_CONTACT) full(REFERRER) full(Consultant) full(ProgramDirector) full(CallTaker) full(S_CONTACT_X) full(a) full(a2) full (a3) */ distinct p_business_date reportdate,
    SUBSTR(S_CONTACT.LAST_NAME,1,25) AS LastName,
    SUBSTR(S_CONTACT.FST_NAME,1,25) AS FirstName,
    SUBSTR(S_CONTACT.MID_NAME,1,1) AS MiddleInitial,
    S_CONTACT.X_JC_ACNT_NUM + 900000000 AS AccountNumber,
    SUBSTR(S_ADDR_PER.ADDR,1,40) AS ADDRESS,
    SUBSTR(S_ADDR_PER.CITY,1,20) AS City,
    S_ADDR_PER.STATE AS State,
    SUBSTR(S_ADDR_PER.ZIPCODE,1,15) AS Zip,
    SUBSTR(REPLACE(S_CONTACT.HOME_PH_NUM,'-',''),1,10) AS HomePhone,
    SUBSTR(REPLACE(S_CONTACT.WORK_PH_NUM,'-',''),1,10) AS WorkPhone,
    S_CONTACT.BIRTH_DT AS BirthDate,
    CASE WHEN FLOOR((p_business_date - S_CONTACT.BIRTH_DT)/360) < 0 THEN NULL ELSE FLOOR((p_business_date - S_CONTACT.BIRTH_DT)/360) END AS AGE,
    S_CONTACT.SEX_MF AS SEX,
    NULL AS NumberOfChildren,
    S_CONTACT_X.ATTRIB_34 AS OCCUPATION,
    CASE WHEN SUBSTR(S_CONTACT_X.ATTRIB_37,1,4)='Othe' THEN 'Othr'
    WHEN SUBSTR(S_CONTACT_X.ATTRIB_37,1,4)='Inte' THEN 'Intr'
    WHEN SUBSTR(S_CONTACT_X.ATTRIB_37,1,4)='Prin' THEN 'News'
    WHEN SUBSTR(S_CONTACT_X.ATTRIB_37,1,4)='Gues' THEN 'Gst'
    ELSE SUBSTR(S_CONTACT_X.ATTRIB_37,1,4) END AS LeadSource,
    SUBSTR(Consultant.EMP_NUM,1,10) AS CONSULTANT,
    ProgramDirector.EMP_NUM AS ProgramDirector,
    CallTaker.EMP_NUM CallTaker,
    S_CONTACT.X_LEAD_DT AS LeadDate,
    LEAST(nvl(S_CONTACT.X_LAST_CONSULTATION_DATE,O.FirstPurchaseDate ), nvl(O.FirstPurchaseDate,S_CONTACT.X_LAST_CONSULTATION_DATE+1) ) AS FirstVisitDate, --X_LAST_CONSULTATION_DATE stores the performed date or the legacy client firstvisitdate
    GREATEST(nvl(S_CONTACT_XM.X_CONSULTATION_DT ,S_CONTACT_X.ATTRIB_29), nvl(S_CONTACT_X.ATTRIB_29, S_CONTACT_XM.X_CONSULTATION_DT-1) ) AS LastVisitDate,
    CASE WHEN S_CONTACT.X_INSTALLMENT_BALANCE > 0 THEN 'B' ELSE NULL END AS BillType,
    ct.current_client_type ClientType,
    SUBSTR(ct.saved_client_type,1,1) PreviousClientType,
    S_CONTACT.LAST_CREDIT_DT AS AppointmentDate,
    CASE WHEN a.X_DR_LETTER_STATUS IS NOT NULL THEN 'Y' ELSE 'N' END AS DoctorLetterRequired,
    NULL AS OneYearPermStabilizationDate,
    DECODE(S_PROD_INT.X_PROGRAM_CLASSIFICATION,'Premium',a.START_DT ,NULL) AS UnlimitedPermStabilizationDate,
    SUBSTR(S_CONTACT.MARITAL_STAT_CD,1,1) AS MaritalStatus,
    SUBSTR(REFERRER.FST_NAME ||' '|| REFERRER.LAST_NAME,1,34) AS ReferrerName,
    ORGEXT_REF.LOC AS ReferrerCentreID,
    S_ORG_EXT.LOC AS CentreID,
    NULL AS PaymentDateOne,
    NULL AS PaymentAmountOne,
    NULL AS PaymentDateTwo,
    NULL AS PaymentAmountTwo,
    NULL AS PaymentDateThree,
    NULL AS PaymentAmountThree,
    NULL AS PaymentDateFour,
    NULL AS PaymentAmountFour,
    NULL AS LibraryPurchased,
    nvl(S_CONTACT.X_INSTALLMENT_BALANCE,0) + nvl(S_CONTACT.X_PREPAID_BALANCE,0) AS BalanceDue, -- Changed operation from (-) prepaid to (+) prepaid since the sign was flipped in OLTP.
    NULL AS FoodNSFBalance,
    NULL AS ProductNSFBalance,
    NULL AS ProgramNSFBalance,
    a2.X_START_WEIGHT AS StartWeight,
    a2.X_CURRENT_WEIGHT AS CurrentWeight,
    a2.X_GOAL_WEIGHT AS GoalWeight,
    a3.X_HEIGHT AS Height,
    a2.X_FAXSENT_DATETIME DateGoalWeightAchieved,
    DECODE(S_PROD_INT.X_PROGRAM_CLASSIFICATION,'Premium',a.START_DT,NULL) AS DateSuccessPlusPurchased,
    CASE WHEN A2.ARCHIVE_FLG = 'N' THEN a2.START_DT ELSE NULL END AS ReturnToActiveDate,
    600 VersionNumber,
    a2.X_FAXRECV_DATETIME AS HalfWayDate,
    NULL AS LastLSCDate,
    TRUNC(S_CONTACT.LAST_UPD-UTC_OFFSET/24) AS LastUpdatedDate,
    NULL AS VitaminWaiverSigned,
    LastSupplementPurchaseDate,
    LastSupplementCodePurchased,
    LastTotalSupplementSupplyCycle,
    LastAddtlSupplPurchaseDate,
    LastAddtlSupplCodePurchased,
    LastAddtlSupplSupplyCycle,
    CASE WHEN (a.X_DIABETES_NO_MEDS_FLG='Y' OR a.X_DIABETES_ORAL_MEDS_FLG = 'Y' OR a.X_DIABETES_ON_INSULIN_FLG = 'Y') THEN 'Y' ELSE 'N' END AS DiabetesClient,
    DECODE(a.X_DIABETES_NO_MEDS_FLG,'Y','Y','N') AS DietControlled,
    a.X_DIABETES_ORAL_MEDS_FLG AS TakingOralMed,
    a.X_DIABETES_ON_INSULIN_FLG AS TakingInsulin,
    S_CONTACT.EMAIL_ADDR AS EmailId,
    NULL CTADATE,
    NULL RWLDATE,
    SUBSTR(S_ADDR_PER.ADDR_LINE_2,1,40) AS Address2
    FROM S_CONTACT,
    S_CONTACT REFERRER,
    S_CONTACT Consultant,
    S_CONTACT ProgramDirector,
    S_CONTACT CallTaker,
    S_CONTACT_X,
    (SELECT /*+ parallel full(S_CONTACT_XM) */ PAR_ROW_ID, attrib_05, MAX(X_CONSULTATION_DT) AS X_CONSULTATION_DT FROM S_CONTACT_XM
    WHERE (S_CONTACT_XM.last_upd_by < '1-14WD'
    or S_CONTACT_XM.last_upd_by > '1-14WD')
    AND S_CONTACT_XM.ATTRIB_05 IN (SELECT row_id FROM S_ORG_EXT WHERE S_ORG_EXT.ACCNT_TYPE_CD IN ('Corporate Centre','Franchise Centre')) LOC IN (SELECT centreid FROM UPL_LIVE_CENTRES WHERE LIVE = 'Y' AND BATCHID = p_batch_id)) where S_ORG_EXT.ACCNT_TYPE_CD IN ('Corporate Centre','Franchise Centre')) --
    GROUP BY PAR_ROW_ID, attrib_05) S_CONTACT_XM,
    (SELECT CONTACT_ID, ACCNT_ID,
    MAX(LastSupplementPurchaseDate) AS LastSupplementPurchaseDate,
    MAX(LastSupplementCodePurchased) AS LastSupplementCodePurchased,
    MAX(LastTotalSupplementSupplyCycle) AS LastTotalSupplementSupplyCycle,
    MAX(LastAddtlSupplPurchaseDate) AS LastAddtlSupplPurchaseDate,
    MAX(LastAddtlSupplCodePurchased) AS LastAddtlSupplCodePurchased,
    MAX(LastAddtlSupplSupplyCycle) AS LastAddtlSupplSupplyCycle,
    MIN(FirstPurchaseDate) AS FirstPurchaseDate,
    MAX(LastPurchaseDate) AS LastPurchaseDate
              FROM (
              SELECT /*+ parallel full(S_ORDER) full(S_ORDER_XM) */ S_ORDER.CONTACT_ID AS CONTACT_ID,S_ORDER.ACCNT_ID,
    NULL AS LastSupplementPurchaseDate,
    NULL AS LastSupplementCodePurchased,
    NULL AS LastTotalSupplementSupplyCycle,
    NULL AS LastAddtlSupplPurchaseDate,
    NULL AS LastAddtlSupplCodePurchased,
    NULL AS LastAddtlSupplSupplyCycle,
    (S_ORDER_XM.X_BUSINESS_DATE) FirstPurchaseDate,
    (S_ORDER_XM.X_BUSINESS_DATE) LastPurchaseDate
              FROM S_ORDER,S_ORDER_XM
              WHERE S_ORDER.ROW_ID = S_ORDER_XM.PAR_ROW_ID
              AND S_ORDER.STATUS_CD IN ('Complete', 'Submitted', 'Ready')
              AND TRUNC(S_ORDER_XM.X_BUSINESS_DATE - UTC_OFFSET/24) <= (p_business_date)
              --GROUP BY S_ORDER.CONTACT_ID
              UNION ALL
              SELECT /*+ parallel full(S_ORDER) full (S_ORDER_ITEM) */ S_ORDER.CONTACT_ID AS CONTACT_ID,S_ORDER.ACCNT_ID,
              (CASE WHEN SUBSTR(SUBSTR(S_PROD_INT.PART_NUM,1,INSTR(S_PROD_INT.PART_NUM,'-',1,1)-1),2,4) = '931' THEN S_ORDER.CREATED ELSE NULL END) AS LastSupplementPurchaseDate,
              (CASE WHEN SUBSTR(SUBSTR(S_PROD_INT.PART_NUM,1,INSTR(S_PROD_INT.PART_NUM,'-',1,1)-1),2,4) = '931' THEN 931 ELSE NULL END) AS LastSupplementCodePurchased,
              (CASE WHEN SUBSTR(SUBSTR(S_PROD_INT.PART_NUM,1,INSTR(S_PROD_INT.PART_NUM,'-',1,1)-1),2,4) = '931' THEN 7 ELSE NULL END) AS LastTotalSupplementSupplyCycle,
              (CASE WHEN SUBSTR(SUBSTR(S_PROD_INT.PART_NUM,1,INSTR(S_PROD_INT.PART_NUM,'-',1,1)-1),2,4) = '920' THEN S_ORDER.CREATED ELSE NULL END) AS LastAddtlSupplPurchaseDate,
              (CASE WHEN SUBSTR(SUBSTR(S_PROD_INT.PART_NUM,1,INSTR(S_PROD_INT.PART_NUM,'-',1,1)-1),2,4) = '920' THEN 920 ELSE NULL END) AS LastAddtlSupplCodePurchased,
              (CASE WHEN SUBSTR(SUBSTR(S_PROD_INT.PART_NUM,1,INSTR(S_PROD_INT.PART_NUM,'-',1,1)-1),2,4) = '920' THEN 28 ELSE NULL END) AS LastAddtlSupplSupplyCycle,
              NULL FirstPurchaseDate,
              NULL LastPurchaseDate
              FROM S_ORDER,S_ORDER_ITEM, S_PROD_INT
              WHERE S_ORDER_ITEM.PROD_ID = S_PROD_INT.ROW_ID
                   AND S_ORDER.ROW_ID = S_ORDER_ITEM.ORDER_ID
                   AND S_ORDER_ITEM.qty_req <> 0
                   AND s_order.created_by <> '1-14WD'
                   AND S_ORDER_ITEM.PAR_ORDER_ITEM_ID is null
                   AND (S_ORDER_ITEM.PAR_ORDER_ITEM_ID is null
                   OR EXISTS (select 1 from S_ORDER_ITEM i2,s_prod_int p
    where i2.row_id = S_ORDER_ITEM.PAR_ORDER_ITEM_ID
    and SUBSTR(SUBSTR(S_PROD_INT.PART_NUM,1,INSTR(S_PROD_INT.PART_NUM,'-',1,1)-1),2,4) IN ('931','920')
    and i2.prod_id = p.row_id
                   AND S_ORDER.status_cd in ('Complete', 'Submitted', 'Ready')
                   and SUBSTR(SUBSTR(S_PROD_INT.PART_NUM,1,INSTR(S_PROD_INT.PART_NUM,'-',1,1)-1),2,4) IN ('931','920')
    GROUP BY CONTACT_ID,ACCNT_ID) O,
    S_CONTACT_TNTX,
    S_ORG_EXT,
    S_ORG_EXT ORGEXT_REF,
    S_ADDR_PER,
    S_ASSET a,
    S_PROD_INT,
    S_ASSET a2,
    S_ASSET a3,
    UPL_CLIENT_TYPES ct,
    (select /*+ parallel */ o.contact_id, o.accnt_id
    from S_ORDER o, S_ORDER_XM oxm
    where o.row_id = oxm.par_row_id
    and trunc(oxm.X_BUSINESS_DATE - (UTC_OFFSET/24)) = trunc(p_business_date)
    group by o.contact_id, o.accnt_id) oxm2
    WHERE S_CONTACT.ROW_ID = S_CONTACT_X.PAR_ROW_ID
    AND S_CONTACT_X.ROW_ID = S_CONTACT_XM.PAR_ROW_ID (+)
    AND (S_ORG_EXT.ROW_ID = S_CONTACT.PR_DEPT_OU_ID
    OR S_ORG_EXT.ROW_ID = oxm2.accnt_id
    OR S_ORG_EXT.ROW_ID = S_CONTACT_XM.attrib_05)
    AND ORGEXT_REF.ROW_ID(+) = REFERRER.PR_DEPT_OU_ID
    AND S_CONTACT.CON_ASST_PER_ID = Consultant.ROW_ID
    AND S_ORG_EXT.X_DIRECTOR_ID = ProgramDirector.ROW_ID (+)
    AND S_CONTACT.CREATED_BY = CallTaker.ROW_ID
    AND S_CONTACT.ROW_ID = a.PR_CON_ID (+)
    AND S_CONTACT.PR_PER_ADDR_ID = S_ADDR_PER.ROW_ID (+)
    AND S_CONTACT_TNTX.PAR_ROW_ID (+) = S_CONTACT.ROW_ID
    AND REFERRER.ROW_ID(+) = S_CONTACT_TNTX.REFERRED_BY_ID
    AND a.PROD_ID = S_PROD_INT.ROW_ID (+)
    AND O.CONTACT_ID (+) = S_CONTACT.ROW_ID
    AND a.STATUS_CD (+) = 'Active'
    AND a.TYPE_CD (+) ='Program'
    AND S_CONTACT.ROW_ID = a2.PR_CON_ID (+)
    AND a2.STATUS_CD (+) = 'Active'
    AND a2.TYPE_CD (+) = 'Lifecycle'
    AND a3.PR_CON_ID(+) = S_CONTACT.ROW_ID
    AND a3.STATUS_CD (+) = 'Active'
    AND a3.TYPE_CD (+) = 'HealthSheet'
    AND S_CONTACT.X_JC_ACNT_NUM = ct.CLIENT_NUMBER (+)
    --AND S_ORG_EXT.LOC NOT LIKE 'F%'
    AND S_ORG_EXT.ACCNT_TYPE_CD NOT IN 'Division'
    --AND S_ORG_EXT.Loc in (select to_char(centreid) from UPL_LIVE_CENTRES where LIVE = 'Y')
    AND (trunc(S_CONTACT.LAST_UPD - (UTC_OFFSET/24)) = trunc(p_business_date) or trunc(S_CONTACT_X.LAST_UPD - (UTC_OFFSET/24)) = trunc(p_business_date) OR (S_CONTACT_XM.X_CONSULTATION_DT = p_business_date) OR oxm2.CONTACT_ID IS NOT NULL)
    AND S_CONTACT.last_upd_by not in ('1-14WD')
    AND oxm2.CONTACT_ID (+) = o.CONTACT_ID
    AND S_ORG_EXT.LOC <> 'CW_846'
    AND (a.pr_accnt_id in (select row_id from S_ORG_EXT where S_ORG_EXT.LOC IN (Select CentreID from UPL_Live_Centres where BATCHID = p_batch_id)) or a.pr_accnt_id is null)
    AND (a2.pr_accnt_id in (select row_id from S_ORG_EXT where S_ORG_EXT.LOC IN (Select CentreID from UPL_Live_Centres where BATCHID = p_batch_id)) or a2.pr_accnt_id is null)
    AND (a3.pr_accnt_id in (select row_id from S_ORG_EXT where S_ORG_EXT.LOC IN (Select CentreID from UPL_Live_Centres where BATCHID = p_batch_id)) or a3.pr_accnt_id is null));
    rollback;
    END;
    --------------------------------------------------------------------------------------------------

  • 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

  • Creating a PL/SQL-Block with Boolean-Return and Check

    Hello folks,
    I have some kind of tricky problem. Actually, I want to integrate a small Task-System on my Apex 2.2 installation. Every task is intended to have a field with a anonymous PL/SQL-block in the shape of:
    Declare
    Begin
    return true/false;
    End;
    It is comparable to the condition-PL/SQL-block you can set for almost ev'ry item.
    It's not the problem to write this block half-automated, but how do I check it? Is there any kind of Database-Function?
    Thanks for your replies.
    Matthias.

    I believe Struct is basically used for SQL types , and your 'T_NACHRICHT' is a type of Objects so please pass the objects array to STRUCT.
    For example if type is :
    CREATE OR REPLACE TYPE T_NACHRICHT AS OBJECT
    ID_Nachricht NUMBER,
    ID_Vorgang NUMBER,
    --datum                 TIMESTAMP(6),
    Betreff VARCHAR2(400),
    -- Nachricht CLOB,
    ID_Antwort NUMBER,
    ist_neu VARCHAR2(5),
    CONSTRUCTOR FUNCTION T_NACHRICHT(
    p_ID_Vorgang NUMBER,
    p_Betreff VARCHAR2) RETURN SELF AS RESULT
    then call the struct in below way:
    STRUCT nachrichtSTRUCT = null;
    StructDescriptor structDesc = StructDescriptor.createDescriptor("T_NACHRICHT", conn);
              Object [] obj = {123456,123456,"ABC",123456,"ABCD"};
    nachrichtSTRUCT = new STRUCT(structDesc, conn, obj);

  • Execute PL/SQL block with named binds from within java code?

    Hi guys,
    Is there any good way to execute my PL/SQL code, for example
    BEGIN         :x := :x+1; END;
    from my Java code? I need nothing complicated, just static code block with named binds.
    I have tried the Oracle exetnded JDBC (setXXXbyName methods):
      public static void main(String[] args){     try {     Class.forName("oracle.jdbc.driver.OracleConnection");     Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","user","password"); String SQL="begin :x:=:x+1; end;"; OracleCallableStatement stmt; stmt=(OracleCallableStatement)conn.prepareCall(SQL); stmt.setIntAtName("x", 5); stmt.registerOutParameter("x", Types.INTEGER); stmt.execute(); System.out.println(stmt.getInt("x"));     } catch (Exception x) { x.printStackTrace();    }   }
    And get the java.sql.SQLException: operation not allowed: Ordinal binding and Named binding cannot be combined!
    Then i've tried SQLJ appoach:
      public static void main(String[] args){     try {     Class.forName("oracle.jdbc.driver.OracleConnection");     Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","user","password");       Oracle.connect(conn);       System.out.println("Connected!");           int x=3;       #sql { BEGIN         :x := :x+1;       END; };           System.out.println("x=" + x);     } catch (Exception x) { x.printStackTrace();    }   }
    And x=3 had retuned... Although 4 expected.
    Then, I've set parameter sqlj.bind-by-identifier=true
    And result is another exception! java.sql.SQLException: Missing IN or OUT parameter at index:: 2
    Can you please mark my mistakes/point to correct solution?
    Thanks in advance,
    Alexey

    Found another solution, this time working at least...
      public void testPLSQL() {
           String dynamicSQL=
                "declare\n" +
                "  v_CursorID  INTEGER;\n" +
                "  v_BlockStr  VARCHAR2(500);\n" +
                "  v_Dummy     INTEGER;\n" +
                "  v_x         String(18);\n" +
                "BEGIN\n" +
                "  v_CursorID := DBMS_SQL.OPEN_CURSOR;\n" +
                "  v_BlockStr :=?;" +
                "  DBMS_SQL.PARSE(v_CursorID, v_BlockStr, DBMS_SQL.V7);\n" +
                "  v_x:=?;"+
                "  DBMS_SQL.BIND_VARIABLE(v_CursorID, ':x', v_x,18);\n" +
                "  v_Dummy := DBMS_SQL.EXECUTE(v_CursorID);\n" +
                "  DBMS_SQL.VARIABLE_VALUE(v_CursorID, ':x', v_x);\n" +
                "  DBMS_SQL.CLOSE_CURSOR(v_CursorID);\n" +
                "  ?:=v_x;"+
                "  COMMIT;\n" +
                "EXCEPTION\n" +
                "  WHEN OTHERS THEN\n" +
                "    DBMS_SQL.CLOSE_CURSOR(v_CursorID);\n" +
                "    RAISE;\n" +
                "END DynamicPLSQL;";
             try {
                   Class.forName("oracle.jdbc.driver.OracleConnection");
                   Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","user", "password");
                   System.out.println("Profit");
         String SQL="begin :x:=:x+1; end;";
         OracleCallableStatement stmt;
         stmt=(OracleCallableStatement)conn.prepareCall(dynamicSQL);
         stmt.setString(1, SQL);
         int x=3;
         stmt.setInt(2, x);
         stmt.registerOutParameter(3,     Types.INTEGER);
         stmt.execute();
         x=stmt.getInt(3);
         System.out.println(x);
         assertEquals(4, x);
             } catch (Exception ex) {
                  ex.printStackTrace();
                  assertTrue(false);
      }Now the only thing I need is to code some kind of preprocessor of SQL block, to prepare the dynamicSQL lair for SQL critter...
    Please please please show me something less complicated! :8}

  • Can't create a sequence within a pl/sql block with execute immediate.

    Hi All. I created a user and granted it the 'create sequence' privilege though a role. In a pl/sql block I try to create a sequence using 'execute immediate' but get a 1031-insufficient privileges error. If I grant create sequence directly to the user, the pl/sql block completes successfully. Can anyone explain this behavior? We're running 11.2 Enterprise Editon.
    Thanks,
    Mark

    In a definer's rights stored procedure (the default), you only have access to privileges that have been granted directly, not via a role.
    There are two basic reasons for that. First, roles can be enabled or disabled, default and non-default, password-protected, etc. so the set of roles a particular user actually has is session-specific. Oracle needs to know at compile time what privileges the owner of the procedure has. The only way to do that (without deferring the privilege check) is to ignore privileges granted through roles.
    Second, since 99% of privilege management DBAs do involves granting and revoking roles, it's helpful that changing role privileges will never cause objects to be marked invalid and recompiled which can have side-effects on applications. DBAs only need to worry about causing problems on those rare cases where they are granting or revoking direct privileges to users.
    You can create an invoker's rights stored procedure by adding the clause (AUTHID CURRENT_USER). That defer's the security check to run-time but allows the procedure to see privileges granted through roles in the current session. But that means that the caller of the procedure would need to have the CREATE SEQUENCE privilege through the role, not the owner of the procedure.
    And just to make the point, dynamic object creation in PL/SQL is almost always a red flag that there is something problematic in your design. If you are creating sequences dynamically, that means that you'd have to refer to them dynamically throughout your code which means that your inserts would need to use dynamic SQL. That's not a particularly easy or safe way to develop code.
    Justin

  • Error in pl/sql  block with parameters

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

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

  • Using sql type with cursor in plsql block

    I wanted to bulk collect columns in a table into a sqltype .I cannot use plsql type here since I am using it with table function in a merge statement.
    Sample code is like this
    create type t_type as object(empno number);
    create type tab_type as table of t_type;
    1 declare
    2  t1 tab_type;
    3 begin
    4  select empno bulk collect into t1 from emp;
    5 end;
    /I get an error like
    ERROR at line 4:
    ORA-06550: line 4, column 8:
    PL/SQL: ORA-00932: inconsistent datatypes: expected UDT got NUMBER
    ORA-06550: line 4, column 1:
    PL/SQL: SQL Statement ignored
    Pls suggest some alternative

    Hi,
    You cannot bulk collect into a table of objects like this.
    Are you going to use some DML operations on this SQL collections. If yes then you need SQL collections and objects. Otherwise simple PL/SQL objects and collections will do.
    Anyway, to give an alternative.
    This is one way of doing things;
    create table emp(emp_no number(10),emp_name varchar2(100));
    INSERT INTO EMP ( EMP_NO, EMP_NAME ) VALUES (
    1, 'A');
    INSERT INTO EMP ( EMP_NO, EMP_NAME ) VALUES (
    2, 'B');
    INSERT INTO EMP ( EMP_NO, EMP_NAME ) VALUES (
    3, 'C');
    commit;
    create type t_type as object(empno number(10),empname varchar2(100));
    create type n_type as table of number(10);
    create type v_type as table of varchar2(100);
    create type tab_type as table of t_type;
    declare
    t1 tab_type := tab_type();
    t2 n_type := n_type();
    t3 v_type := v_type();
    begin
    select emp_no,emp_name bulk collect into t2,t3 from emp;
    t1.extend(t2.count);
    for cnt in t2.first..t2.last
    loop
    t1(cnt):=t_type(t2(cnt),t3(cnt));
    end loop;
    for cnt in t1.first..t1.last
    loop
    dbms_output.put_line(t1(cnt).empno||'---'||t1(cnt).empname);
    end loop;
    end;
    Now if you do not require the DML operations then you can do the following;
    declare
    type n_type is table of number(10);
    type v_type is table of varchar2(100);
    type rec_type is record(empno n_type,empname v_type);
    t1 rec_type;
    begin
    select emp_no,emp_name bulk collect into t1.empno,t1.empname from emp;
    for cnt in t1.empno.first..t1.empno.last
    loop
    dbms_output.put_line(t1.empno(cnt)||'---'||t1.empname(cnt));
    end loop;
    end;
    regards,
    Dipankar.

  • Toplink storedProcedure/funtion + PL/SQL Procedure with cursor

    Hi,
    I am working on Toplink storedProcedure but, I am not getting any output. I go through the Oracle Tutorial but, still I am not getting any alternative.
    please, anyone help out....
    Thanking You,
    regards,
    sufian

    Hello Sufian,
    You seem to have a few threads trying to get a Stored proc working. In How to work with Toplink + PL/SQL Procedure + Cursor
    you mention you get an error when executing, have you gotten past this exception? You may want to turn on TopLink logging to see the statement TopLink is creating and sending to the driver. Please see
    http://www.oracle.com/technology/products/ias/toplink/doc/1013/main/_html/sescfg004.htm
    If you are not familar with how to turn on logging.
    Also, are you able to get results from a stored procedure that returns data instead of a cursor?
    Best Regards,
    Chris

  • MS SQL Server with Cursor Problem

    Dear all:I use JDBC type four connect with MS SQL Server and the language is jsp.
    I run it on my local computer is ok.If I run it on the other computer.I get this error messege.
    javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]Error setting up static cursor cache.
    If someone get some or can surve this qusition.
    Please tell me.thinks you kind.

    Jamie,
    Did you ever get a reply from anyone regarding this problem. I too am having a similar problem and would like to know the solution.

  • Pl/sql block with "insert into" and schema qualified table throws "error"

    Simplified test case:
    Oracle9i EE Release 9.2.0.3.0
    Oracle JDeveloper 9.0.3.2 Build 1145
    create user u1 identified by u1
    default tablespace users
    quota unlimited on users;
    grant connect, resource to u1;
    revoke unlimited tablespace from u1;
    create user u2 identified by u2
    default tablespace users
    quota unlimited on users;
    grant connect, resource to u2;
    revoke unlimited tablespace from u2;
    As user u2:
    create table u2.t
    c1 number
    grant select, update, insert, delete on u2.t to u1;
    As user u1:
    create or replace package test_pkg as
    procedure do_insert (p_in number);
    end;
    create or replace package body test_pkg as
    procedure do_insert (p_in number) is
    begin
    insert into u2.t values (p_in);
    commit;
    end;
    end;
    All of the above works fine using command-line sql*plus, and is clearly a simplified version of the actual code to demonstrate the issue at hand. Using JDeveloper, it complains about 'expected ;' at the 'values' keyword in the insert statement. Removing the schema qualification from the table name allows JDeveloper to not flag the statement as an error, but I do not want to create synonyms (private or public) to point to all the tables in the real packages. Since JDeveloper flags the insert statement as an error, I can not browse the package structure etc, even though it compiles with no problems. What gives?
    Thanks in advance for any suggestions, etc...

    Hi Bryan,
    Thanks for following up on this. I will look for the bug fix to be published.
    - Mark

  • Excution of a PL/SQL procedure with CURSOR for big tables

    I have prepared a proceudre that uses CURSOR to make a complex query for tables with big number of records, something like 900'000. And the execution failed; ORA-01652:impossible to extend the temporary segment of 64 in the space of storage TEMP.
    Any sugestion.

    This brings us to the following question: How could I calculate the bytes required by a cursor?. It is a selection of certain fields of very big tables. Let's say that the fields are NUMBER(4), NUMBER(8) and CHAR(2). The fields are in 2 relational tables of 900'000 each. What size is required for a procedure like this.
    Your help is really appreciated.

  • 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

  • First execution of pl/sql block is slow.

    Hi,
    I've introduced TimesTen to improve performance of a pl/sql block in Oracle.
    For that I created certain cachegroups in TimesTen to cache the oracle data.
    After everything is done on TimesTen, when we run the pl/sql block on TimesTen, I observed that it is taking 35 Seconds ( against 48 secs on Oracle) for first time execution on Timesten.  Subsequent execution of same pl/sql block with same parameters are taking just 6 seconds. I want to achieve the same throughput ( 6 sec) when the pl/sql block is executed for the first time. Can you please suggest what exactly I should look into.
    Thanks
    Amit

    Thanks you so much Chris for your response.
    Please find the requested info here:
    1=>
    C:\TimesTen\tt1122_64\bin>ttversion
    TimesTen Release 11.2.2.5.0 (64 bit NT) (tt1122_64:53396) 2013-05-23T16:26:12Z
      Instance admin: shuklaam
      Instance home directory: C:\TimesTen\TT1122~1\
      Group owner: ES\Domain Users
      Daemon home directory: C:\TimesTen\TT1122~1\srv\info
      PL/SQL enabled.
    2, 3=>Complete DSN definition and CG definitions is available in the  doc here https://docs.google.com/file/d/0BxQyEfoOqCkDWVZmSG90NUd5bGM/edit?usp=sharing
    4=>I can't share the source code due to my company policies, but I'm explaining here what exactly it is doing.
    1. Based on the parameters to the proc, build a cursor, and fetch records from various tables.
    2. insert them into pl/sql tables.
    3. Do some calculations on those records, & calculate certain amounts.
    4. Insert these values into a temporary table, and display to the UI.
    At the same time, I found a metalink note 1272819.1 which stats this is a known phenomena. Not sure if setting DSN attribute MemoryLock=4 will resolve the issue.
    Also, I couldn't find this attribute in windows DSN definition any where. Can you please point me where exactly I need to set it.
    Thanks
    Amit

  • RETURN Clause in IF...ELSE Condition in PL/SQL Block

    Hi
    Could you please explain me the importance of a RETURN Clause in IF..ELSE Condition in PL/SQL Block with
    an example.
    Regards
    Nakul.V

    Hi,
    RETURN clause permits get out of the block. For more information you can see [Using the RETURN Statement|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/subprograms.htm#sthref1683]
    SET SERVEROUTPUT ON
    BEGIN
        IF 1 = 1 THEN
            dbms_output.put_line('Before return');
            RETURN;
        ELSE
            dbms_output.put_line('Else');
        END IF;
        dbms_output.put_line('After if');
    END;
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
    Connected as hr
    SQL>
    SQL> BEGIN
      2      IF 1 = 1 THEN
      3          dbms_output.put_line('Before return');
      4          RETURN;
      5      ELSE
      6          dbms_output.put_line('Else');
      7      END IF;
      8      dbms_output.put_line('After if');
      9  END;
    10  /
    Before return
    PL/SQL procedure successfully completed
    SQL> Regards,
    Edited by: Walter Fernández on Dec 12, 2008 9:41 AM - Adding output
    Edited by: Walter Fernández on Dec 12, 2008 9:43 AM - Adding URL...

Maybe you are looking for

  • Crystal Report with jsp

    Please help ............................. <html> <head><title>Table Linking Sample</title></head> <body> <%@ page import= "java.net.*" %> <%@ page import= "java.util.Locale" %> <%@ page import= "com.crystaldecisions.sdk.occa.report.application.Report

  • Installing New Hard Drive for New OS

    I have a MBP (late 2008), and have loved it since I first acquired it.  I am currently running OSX Lion 10.7.4, and I plan on upgrade to Mountain Lion when it is released. My MBP came with a 250-gig HD in it.  I am wanting to swap it out for a 500 Se

  • Pdf to word not working

    Hello all, I am using a Mac OS X 10.5.8 and using Acrobat Pro 9.4.5. I am trying to convert a pdf made in inDesign to a word document. It contains tables, text and images. The images are inside tables also. When I have been creating the pdf I have be

  • How do I get a retention offer with AMEX?

    The time is approaching for me to cancel my PRG. I'd like to call to do online chat or call to cancel but I want to try to get a retention offer. Do they always offer one or should I say something to get one? I don't want to seem deseperate for one b

  • XML publisher with jdeveloper

    Hi all, I'm wondering if there is an API of XML Publisher for using with jdeveloper for development a reporting system. After I have run queries in database, I want to present tuples in a formatted fashion in PDF, RTF document etc. There are open sou