Trouble compiling a stored procedure

Hello, I have trouble compiling a stored procedure. I include part of the code because I think the key problem is illustrated in these lines:
date1 is declared as a DATE.
index_value2 NUMBER;
BEGIN
date1 := (select sysdate from dual);
index_value2 := (select index_value from tmsdat.a_index_values where price_date < (SELECT sysdate -180
   FROM dual) and price_date > (SELECT sysdate -210
   FROM dual));
[\code]
The problem seems to be that a more complex syntax is included in the allocation statement (:=), can that be the case? That is, no select etc??
How is this solved?
Any help much appreciated!
best regards
Harald                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Well, actually WhiteHat´s magic did the trick, but two errors:
temp := (select (to_number(to_char(sysdate, 'DD'))-1)/(decode(to_char(sysdate,'MM'),'02',28,30)) as result
   from dual);
[\code]
this line generates problems but I think the approach is the same maybe, that is:
select to_number(to_char(sysdate, 'DD'))-1)/(decode(to_char(sysdate,'MM'),'02',28,30)) into temp as result frmo dual
Further, some error about encountering end of line?
END CONVERT_MARKET_INDEX;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Ora-04021 error while compiling a stored procedure

    Hi Gurus,
    I am getting a ora-04021 timeout error while trying to compile a stored procedure. My Oracle version is 9i on Unix.
    Thanks
    Amitava.

    amitavachatterjee1975 wrote:
    Hi Gurus,
    I am getting a ora-04021 timeout error while trying to compile a stored procedure. My Oracle version is 9i on Unix.
    Thanks
    Amitava.
    my car won't go.
    tell me how to make my car go.
    How do I ask a question on the forums?
    https://forums.oracle.com/forums/thread.jspa?threadID=2174552#9360002
    [oracle@localhost ~]$ oerr ora 4021
    04021, 00000, "timeout occurred while waiting to lock object %s%s%s%s%s"
    // *Cause:  While waiting to lock a library object, a timeout occurred.
    // *Action: Retry the operation later.
    [oracle@localhost ~]$

  • Error while compiling a stored procedure

    Hi Expertise,
    I want to have all table names with their column name and tried using below stored procedure and it is throwing some compiler error at "fetch TestCurr into temp2;"
    I am very new to Data base and writing stored procedure and not able to understand how to resolve it. Please anyone help me out to correct it and provide some better idea to achieve my requirement. This is very urgent. One more thing, I want all these data into a log file.
    create or replace
    procedure temp as
    begin
    DECLARE
    cursor C1 IS SELECT COLUMN_NAME FROM user_tab_columns;
    file_id UTL_FILE.FILE_TYPE;
    Temp1 all_tables.table_name%TYPE;
    temp2 user_tab_columns.COLUMN_NAME%TYPE;
    cursor TempCur is Select table_name from all_tables where owner='XSS_ADMIN' order by TABLE_NAME;
    begin
    open TempCur;
    loop
    fetch TempCur into Temp1;
    exit when TempCur%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE(Temp1);
    declare cursor TestCurr is select COLUMN_NAME from user_tab_columns where table_name= Temp1;
    open TestCurr;
    loop
    fetch TestCurr into temp2;
    exit when TestCurr%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE(Temp2);
    end loop ;
    close TestCurr;
    end loop;
    Thanks in advance
    R e h a n

    Hi,
    declare cursor TestCurr is select COLUMN_NAME from user_tab_columns where table_name= Temp1;
    open TestCurr;
    loop The Cursor Declarations Should be done in the declaration Section of the PLSQL Block.
    The General Structure of Cursor Declaration is:
    DECLARE
    CURSOR curr IS
    SELECT FROM WHERE;
    rec curr%ROWTYPE;
    BEGIN
    OPEN curr;
    LOOP
    FETCH curr INTO rec;
    EXIT WHEN curr%NOTFOUND;
    END LOOP;
    CLOSE curr;
    END;
    If Use Multiple Cursor Declaration, then Use the below Structure ,
    DECLARE
    CURSOR curr IS
    SELECT FROM WHERE;
         CURSOR curr_1 IS
    SELECT FROM WHERE;
    rec curr%ROWTYPE;
    rec_1 curr_1%ROWTYPE;
    BEGIN
    OPEN curr;
    LOOP
    FETCH curr INTO rec;
    EXIT WHEN curr%NOTFOUND;
    END LOOP;
    CLOSE curr;
    END;
    So, You can Fetch the value for the Second Cursor in the LOOP of the First Cursor Statement.
    Or Just Declare a Single Cursor and User FOR-CURSOR LOOP as
    DECLARE
    CURSOR curr IS
    SELECT FROM WHERE;
    rec curr%ROWTYPE;
    BEGIN
    OPEN curr;
    LOOP
    FETCH curr INTO rec;
    EXIT WHEN curr%NOTFOUND;
         for rec_curr in(select *from where  col_name =rec.col_value)loop
         .............Processing
         end loop;
    END LOOP;
    CLOSE curr;
    END;
    You have ample example available for ,Please have a look at it and Try.. All the Best !!!!!
    Thanks,
    Shankar

  • Trouble compiling external oracle procedure.

    I've been trying to play around with this problem but i've now decided to try and seek help as im stuck. We migrated our machines from
    Oracle 9.0.2.1 to 10.2.0
    SunOS 5.8 to 5.9As part of the migration i have to re-compile some C shared libraries using gcc 4.2.2 whereas on the old environment we used gcc 3.4.2
    The make file for compiling and building the shared library is shown below
    gcc -c -o runLoad.o runLoad.c
    make -f $ORACLE_HOME/rdbms/demo/demo_rdbms.mk \
            extproc_callback \
            SHARED_LIBNAME=${ORACLE_HOME}/lib/libextCCS.so  \
            OBJS=runLoad.oI tried to run the above make file and got the following error
    /usr/ccs/bin/ld -G -z text -L/disk2/ccsbill/app/oracle/product/10.2.0/db/lib -R/disk2/ccsbill/app/oracle/product/10.2.0/db/lib -o /disk2/ccsbill/app/oracle/product/10.2.0/db/lib/libextCCS.so runLoad.o /disk2/ccsbill/app/oracle/product/10.2.0/db/lib/libpls10.a -lclntsh   `cat /disk2/ccsbill/app/oracle/product/10.2.0/db/lib/sysliblist` -R/disk2/ccsbill/app/oracle/product/10.2.0/db/lib -laio  -lposix4 -lkstat -lm  -lthread -lpthread
    ld: fatal: file /disk2/ccsbill/app/oracle/product/10.2.0/db/lib/libclntsh.so: wrong ELF class: ELFCLASS64
    ld: fatal: File processing errors. No output written to /disk2/ccsbill/app/oracle/product/10.2.0/db/lib/libextCCS.so
    *** Error code 1
    make: Fatal error: Command failed for target `extproc_callback'I tried to investigate this and i think it has something to do with the fact that gcc is producing 32bit objects. I've tried all the following options with no luck
    - changed gcc compile command to gcc -m64 -c -o runLoad.o runLoad.c
    - Changed the make command to use demo_rdbms.mk, demo_rdbms64.mk and demo_rdbms32.mk but none of them worked
    If i use demo_rdbms.mk with the -m64 option on the compile command, the error i get is
    ld: fatal: relocation error: R_SPARC_H44: file runLoad.o: symbol MAX_PATH: relocations based on the ABS44 coding model can not be used in building a shared object
    *** Error code 1
    make: Fatal error: Command failed for target `extproc_callback'When i try to run "ldd runLoad.o" to see what libraries are being used in the object i get the following error
    warning: ldd: runLoad.o: is not executable
    ld.so.1: lddstub: fatal: relocation error: R_SPARC_H44: file ./runLoad.o: symbol MAX_PATH: relocations based on the ABS44 coding model can not be used in building a shared objectI have tried everything and now i've run out of ideas. Has anyone got any clues as to what im doing wrong?
    Thanks

    Hi:
    I think you must fix the problem appeared in line:
    ld: fatal: file /disk2/ccsbill/app/oracle/product/10.2.0/db/lib/libclntsh.so: wrong ELF class: ELFCLASS
    by adding to your system any package ELF related, I don't know which. Check your system package versions with the Oracle required.

  • Compile Stored Procedure using JDBC ?

    I am using JDBC thin driver and able to create stored procedure without any problem.
    But if the stored procedure is invalid, it
    won't throw SQLException during creation.
    Is there any way that I can compile the
    stored procedure and catch the semantic exception during creation ?
    Please help, thanks.
    null

    The only thing that springs to mind is the user_errors view. If the procedure fails to compile, then there will be rows in this view indicating the error ..... so maybe you could use
    select count(*) from user_errors
    and check from Java that 0 is returned.

  • Compiling stored procedure

    Hi,I am facing problem in compilation of stored procedure.If i alter some table or column which is getting used by some stored procedure,i have to recomplie that stored procedure.
    Also is there any way when i compile some stored procedure,it should not give error regardless it is calling another stored procedure which is not compiled.
    Lets say i m compiling stored Procedure 'ABC' which is calling stored procedure 'DEF' and 'DEF' is not complied yet.So is there any way that 'ABC' get complied ithout errors regardless 'DEF' is compiled or not.

    I don't think this is possible according to the way Oracle handles object dependencies.

  • How do I get the returned cursor from a stored procedure to an asp.

    Sorry if this topic has been answered before but I am new to Oracle and ASP. I have been asked to create some stored procedures and access the results from the ASP. I will be passing one variable in and could be getting upto 200 rows returned.
    I have no trouble with the stored procedure but have no clue how to retrieve the data returned by it.

    Assuming that the stored procedure has a single argument, an OUT cursor, you should be able to do
    SQLExecDirect
    {call <stored_proc>() }
    SQLFetch
    SQLGetData
    We'll handle all the 'magic' underneath.
    Justin Cave
    ODBC Development

  • Need Help With a Stored Procedure

    Help With a Stored Procedure
    Hi everyone.
    I am quite new relative to creating stored procedures, so I anticipate that whatever help I could get here would be very much helpful.
    Anyway, here is my case:
    I have a table where I need to update some fields with values coming from other tables. The other tables, let us just name as tblRef1, tblRef2 and tblRef3. For clarity, let us name tblToUpdate as my table to update. tblToUpdate has the following fields.
    PlanID
    EmployeeIndicator
    UpdatedBy
    CreatedBy
    tblRef1, tblRef2 and tblRef3 has the following fields:
    UserName
    EmpIndicator
    UserID
    In my stored procedure, I need to perform the following:
    1. Check each row in the tblToUpdate table. Get the CreatedBy value and compare the same to the UserName and UserID field of tblRef1. If no value exists in tblRef1, I then proceed to check if the value exists in the same fields in tblRef2 and tblRef3.
    2. If the value is found, then I would update the EmployeeIndicator field in tblToUpdate with the value found on either tblRef1, tblRef2 or tblRef3.
    I am having some trouble writing the stored procedure to accomplish this. So far, I have written is the following:
    CREATE OR REPLACE PROCEDURE Proc_Upd IS v_rec NUMBER;
    v_plan_no tblToUpdate.PLANID%TYPE;
    v_ref_ind tblToUpdate.EMPLOYEEINDICATOR%TYPE;
    v_update_user tblToUpdate.UPDATEDBY%TYPE;
    v_created_by tblToUpdate.CREATEDBY%TYPE;
    v_correct_ref_ind tblToUpdate.EMPLOYEEIDICATOR%TYPE;
    CURSOR cur_plan IS SELECT PlanID, EmployeeIndicator, UPPER(UpdatedBy), UPPER(CreatedBy) FROM tblToUpdate;
    BEGIN
    Open cur_plan;
         LOOP
         FETCH cur_plan INTO v_plan_no, v_ref_ind, v_update_user, v_created_by;
              EXIT WHEN cur_plan%NOTFOUND;
              BEGIN
              -- Check if v_created_by has value.
                   IF v_created_by IS NOT NULL THEN
                   -- Get the EmpIndicator from the tblRef1, tblRef2 or tblRef3 based on CreatedBy
                   SELECT UPPER(EmpIndicator)
                        INTO v_correct_ref_ind
                        FROM tblRef1
                        WHERE UPPER(USERNAME) = v_created_by
                        OR UPPER(USERID) = v_created_by;
                        IF v_correct_ref_ind IS NOT NULL THEN
                        -- Update the Reference Indicator Field in the table TRP_BUSPLAN_HDR_T.
                             UPDATE TRP_BUSPLAN_HDR_T SET ref_ind = v_correct_ref_ind WHERE plan_no = v_plan_no;
                        ELSIF
                        -- Check the Other tables here????
                        END IF;
                   ELSIF v_created_by IS NULL THEN
                   -- Get the EmpIndicator based on the UpdatedBy
                        SELECT UPPER(EmpIndicator)
                        INTO v_correct_ref_ind
                        FROM tblRef1
                        WHERE UPPER(USERNAME) = v_update_user
                        OR UPPER(USERID) = v_created_by;
                        IF v_correct_ref_ind IS NOT NULL THEN
                        -- Update the Reference Indicator Field in the table TRP_BUSPLAN_HDR_T.
                             UPDATE TRP_BUSPLAN_HDR_T SET ref_ind = v_correct_ref_ind WHERE plan_no = v_plan_no;
                        ELSIF
                        -- Check the Other tables here????
                        END IF;
                   END IF;
              END;
         END LOOP;
         CLOSE cur_plan;
         COMMIT;
    END
    Please take note that the values in the column tblToUpdate.UpdatedBy or tblToUpdate.CreatedBy could match either the UserName or the UserID of the table tblRef1, tblRef2, or tblRef3.
    Kindly provide more insight. When I try to execute the procedure above, I get a DATA NOT FOUND ERROR.
    Thanks.

    Ah, ok; I got the updates the wrong way round then.
    BluShadow's single update sounds like what you need then.
    I also suggest you read this AskTom link to help you see why you should choose to write DML statements before choosing to write cursor + loops.
    In general, when you're being asked to update / insert / delete rows into a table or several tables, your first reaction should be: "Can I do this in SQL?" If you can, then putting it into a stored procedure is usually just a case of putting the sql statement inside the procedure header/footers - can't really get much more simple than that! *{;-)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Help Needed in Xml Stored Procedure

    Hi , i am trying to write one sp which takes xml document as a parameter. I want to update/Insert the data in the xml based on some conditions. So i put the data from xml to a global TEMPORARY table. The i process this data and will update /Insert the data based on the output.
    Right now i am unable to create global TEMPORARY table my stored procedure .When i compile the stored procedure , its showing the following error
    Compilation errors for PROCEDURE SYSTEM.TESTXML
    Error: PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:
    begin case declare exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe
    Line: 8
    Text: CREATE GLOBAL TEMPORARY TABLE temp
    I am attaching my sp below
    create or replace procedure testxml
    ( xmlDoc IN clob )
    is
    updCtx DBMS_XMLStore.ctxType;
    rows NUMBER;
    begin
    CREATE GLOBAL TEMPORARY TABLE temp
    ( cdcalendar NUMBER,
    cdperiod NUMBER,
    cdsubperiod NUMBER,
    cdglperiod NUMBER,
    dtstartsubperiod date,
    dtendsubperiod date
    ) ON COMMIT PRESERVE ROWS;
    updCtx := DBMS_XMLStore.newContext(temp)
    rows := DBMS_XMLStore.insertXML(updCtx,xmlDoc);
    DBMS_XMLStore.closeContext(updCtx);
    if Not exists
    (Select Distinct cd_calendar from Calendar_Period
    Where cd_calendar = select Distinct cdcalendar from temp )
    Then
    Insert into calendar_period
    cd_calendar,
    cd_period,
    cd_subperiod,
    cd_gl_period,
    dt_start_subperiod,
    dt_end_subperiod
    select cdcalendar,
    cdperiod,
    cdsubperiod,
    cdglperiod,
    dtstartsubperiod,
    dtendsubperiod
    from temp ;
    Else
    Update calendar_period
    Set cdp.cd_calendar = temp.cdcalendar ,
    cdp.cd_period = temp.cdperiod,
    cdp.cd_subperiod = temp.cdsubperiod ,
    cdp.cd_gl_period = temp.cdglperiod,
    cdp.dt_start_subperiod = temp.dtstartsubperiod ,
    cdp.dt_end_subperiod = temp.dtendsubperiod
    From
    calendar_period cdp Inner Join temp
    On
    cdp.cd_calendar = temp.cdcalendar
    cdp.cd_subperiod = temp.cdsubperiod
    cdp.cd_period = temp.cdperiod ;
    End if
    end testxml;
    Kindly guide me !!!!

    Hi,
    "CREATE GLOBAL TEMPORARY TABLE" is not a PL/SQL sommand; it is a SQL command. That explain the error message you're getting.
    Normally, tables (including Global Temporary Tables) are created once for all, without using PL/SQL. After they are created, you can write PL/SQL code to populate and use them. This job doies not seem to be an exception.
    In the rare event that you do need to create a table in PL/SQL, use EXECUTE IMMEDIATE, which can do any SQL command from withiin PL/SQL.
    EXECUTE IMMEDIATE is documented in the PL/SQL manual:
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/dynamic.htm#sthref857

  • Calling stored procedure from EJB in JSever

    I have some trouble to call stored procedure from EJB deployed to JServer on Oracle8i (815).
    I have been able to sucessfully test the stored procedure using thin client JDBC driver. But when I user the default connection in JServer, the stored procedure never got called. Is there any restriction of EJB in JServer?
    Thanks
    null

    Thanks man! that was a great help. looks like i am almost there. i created those items t obe hidden.
    now i am passing three parameters to the procedure. my url for that column value looks like this,
    javascript:P65_PARTITION_ID=#PARTITION_ID#;P65_DBC=#DBC#;P65_FILE_ID=#FILE_ID#;doSubmit('Sku_Save');
    the #DBC# parameter is a name of the person that has spaces(firstname lastname). i am getting a javascript error saying,
    Line: 1
    Char: 37
    Error:Expected ';'
    i see that char 37 is the space after firstname.
    any idea how i should get rid of this error.
    Also, as you have been very helpful, a question further beyond :). the above procedure will return a OUT varchar parameter. i guess i have to create another item for that. how do i read it and display just below my report as text.
    Thanks Again!

  • Error while parsing Stored Procedure

    Hi all,
    i try to migrate a MS SQL Server 2000 database to Oracle 9.2 with the Migration Workbench and got into trouble with some Stored Procedures, that contain LEFT JOINS on SELECT-Statements. While parsing the following example Stored Procedure sp_test, an parse-error occurs (ENCOUNTERED: LEFT):
    CREATE PROCEDURE [dbo].[sp_test]
    AS
    SELECT
    FROM
    tbl_Test1 AS test1
    LEFT JOIN (Select * From tbl_Test2 Where column1 IS NOT NULL) AS test2 ON test1.test2_id = test2.id
    GO
    If i run this command in SQL-Worksheet, the SP is created correctly.
    If i modify the SP as it follows, no parse-error-occurs:
    CREATE PROCEDURE [dbo].[sp_test]
    AS
    SELECT
    FROM
    tbl_Test1 AS test1
    LEFT JOIN tbl_Test2 AS test2 ON test1.test2_id = test2.id
    GO
    Is it a bug?
    Thank you for help,
    Torsten

    Hi Torsten,
    This has been logged as a bug      3635749.
    There are no plans to fix this in the current release of the OMWB.
    But the next release of the OMWB should cope with this issue.
    Im afraid the workaround is to comment out the offending statement in the Source Model and reparse it to the Oracle Model. In the Oracle Model you will have to remove the comment and manually migrate the statement yourself.
    Regards,
    Dermot.

  • Stored Procedure Vs PL-SQL Block

    Hi,
    I came across an interesting problem last week. Fortunately, I was able to solve it or find an acceptable workaround for myself. But wanted to get some clarification from the experts. So posting it here.
    Also, I am new to Orcle, so please excuse any shortcomings in the post.
    My data model has following tables-
    TABLE_PARENT (ID, other columns)
    TABLE_CHILD (ID, other columns, PARENT_ID_FK)
    Here, ID is the primary key column for the respective tables; PARENT_ID_FK is the foreign key referencing the ID column from the TABLE_PARENT.
    I created a stored procedure programmatically (using MS Excel) to insert records in the two tables. The stored procedure has insert statements for an indefinite number of records in the parent table and for every such record, there's a corresponding record inserted in the child table. Here's the sample code.
    BEGIN
    /*first record*/
    parent_id := MY_SEQUENCE_GENERATOR.NEXTVAL;
    INSERT INTO TABLE_PARENT(ID, other columns) VALUES (parent_id, other values);
    INSERT INTO TABLE_CHILD(ID, other values,parent_id );
    /*second record*/
    parent_id := MY_SEQUENCE_GENERATOR.NEXTVAL;
    INSERT INTO TABLE_PARENT(ID, other columns) VALUES (parent_id, other values);
    INSERT INTO TABLE_CHILD(ID, other values,parent_id );
    /*third record*/
    parent_id := MY_SEQUENCE_GENERATOR.NEXTVAL;
    INSERT INTO TABLE_PARENT(ID, other columns) VALUES (parent_id, other values);
    INSERT INTO TABLE_CHILD(ID, other values,parent_id );
    /*and so on*/
    END
    When I run this stored procedure, I keep getting following exception intermittently-
    ORA-02291: integrity constraint violated-parent key not found tips.
    My thinking is that it comes because the insert statements are executing ahead of turn of the parent_id assignment statement. And this is happening possibly because of some parallelism that is taking place during the execution of the stored procedure, or, some sort of optmization that the DB server does (though erroneously) when it compiles the stored procedure.
    I tried out everything that I could think of but it didn't go away. Finally, when I executed the same set of statements as a PL-SQL block, it worked fine.
    To understand it better, I am looking for clarification on the following questions.
    1) Why does the exception come with stored procedure but not with PL-SQL block? Is my reasoning given above correct (parallelism or some sort of optimization coming into play)?
    2) If it is due to parallelism, how to run a Oracle stored procedure with defree of prallelism set to 1?
    3) If it is due to optimization done by the compiler, how to instruct the compiler to not do any such optimization. Also, in any case, isn't it an error to optimize but lose program semantics?
    4) Another question related to the same piece of work I have is to use transactions in the PL-SQL block, I had to explicitly COMMIT/ROLLBACK it in the code. In whatever references I had read, it was said that by default the transaction begins with BEGIN statement and commits with END. Also, it seems to work with a Stored Proedure though. So is it that a PL_SQL block needs explicity call to COMMIT/ROLLBACK to achive transactions but stored procedures do not?
    Any inputs/clarifications will be much appreciated.
    Thank you
    Neelesh

    Ok, your last couple of paragraphs were helpful. Here're the details that were missing in my earlier post.
    - I am on Oracle 10.2.0.
    - Table definitions-
    CREATE TABLE "MYUSER"."TABLE_PARENT"
    *(     "ID" NUMBER(19,0) NOT NULL ENABLE,*
    *     "NAME" VARCHAR2(30),*
    *     "DESCRIPTION" VARCHAR2(80),*
    *     "RULETYPE" NUMBER(10,0) NOT NULL ENABLE,*
    *     "OPERATOR" NUMBER(10,0),*
    *     "MININTERCEPT" FLOAT(126),*
    *     "PRIORITY" NUMBER(10,0),*
    *     "PENALTY" NUMBER(10,0),*
    *     "STATUS" NUMBER(10,0),*
    *     PRIMARY KEY ("ID")*
    USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE(INITIAL 131072 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "USERS"  ENABLE,
    *) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING*
    STORAGE(INITIAL 131072 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "USERS"
    CREATE TABLE "MYUSER"."TABLE_CHILD"
    *(     "ID" NUMBER(19,0) NOT NULL ENABLE,*
    *     "WEIGHT" NUMBER(19,0),*
    *     "PARENTID_FK" NUMBER(19,0),*
    *     PRIMARY KEY ("ID")*
    USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE(INITIAL 131072 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "USERS"  ENABLE,
    *     CONSTRAINT "FK3A78BF1E6A9DCE51" FOREIGN KEY ("PARENTID_FK")*
    *     REFERENCES "MYUSER"."TABLE_PARENT" ("ID") ENABLE*
    *) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING*
    STORAGE(INITIAL 131072 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "USERS"
    - The Stored procedure definition is-
    CREATE OR REPLACE PROCEDURE LOAD_RULES_SP AS
    ruleid NUMBER(19,0);
    tempid NUMBER(19,0);
    BEGIN
    */* First parent record */*
    SELECT IDGENERATOR.NEXTVAL INTO ruleid FROM dual;
    INSERT INTO TABLE_PARENT (ID, NAME, DESCRIPTION, RULETYPE, OPERATOR, MININTERCEPT, PRIORITY, penalty, STATUS) VALUES (ruleid, 'Rule 1',null,3,0,0,null,null,1);
    */* Corresponding child records */*
    SELECT IDGENERATOR.NEXTVAL INTO tempid FROM dual;
    INSERT INTO TABLE_CHILD (id, weight, PARENTID_FK)
    VALUES (tempid, 0.2, ruleid);
    SELECT IDGENERATOR.NEXTVAL INTO tempid FROM dual;
    INSERT INTO TABLE_CHILD (id, weight, PARENTID_FK)
    VALUES (tempid, 0.5, ruleid);
    SELECT IDGENERATOR.NEXTVAL INTO tempid FROM dual;
    INSERT INTO TABLE_CHILD (id, weight, PARENTID_FK)
    VALUES (tempid, 0.3, ruleid);
    */* First parent record */*
    SELECT IDGENERATOR.NEXTVAL INTO ruleid FROM dual;
    INSERT INTO TABLE_PARENT (ID, NAME, DESCRIPTION, RULETYPE, OPERATOR, MININTERCEPT, PRIORITY, penalty, STATUS) VALUES (ruleid, 'Rule 1',null,3,0,0,null,null,1);
    */* Corresponding child records */*
    SELECT IDGENERATOR.NEXTVAL INTO tempid FROM dual;
    INSERT INTO TABLE_CHILD (id, weight, PARENTID_FK)
    VALUES (tempid, 0.2, ruleid);
    SELECT IDGENERATOR.NEXTVAL INTO tempid FROM dual;
    INSERT INTO TABLE_CHILD (id, weight, PARENTID_FK)
    VALUES (tempid, 0.5, ruleid);
    SELECT IDGENERATOR.NEXTVAL INTO tempid FROM dual;
    INSERT INTO TABLE_CHILD (id, weight, PARENTID_FK)
    VALUES (tempid, 0.3, ruleid);
    */* And so on for a few parent records more */*
    END;
    Can you throw some light on the exception I was seeing now? Note that when I changed from stored procedure to an anonymous block, it worked fine.
    One correction in my earlier post is that as the code snippet shows, there are multiple inserts in the child table for every record inserted in the parent one.

  • Using Parameterized Arrays in Stored Procedure

    I tried following code to pass array value to stored procedure but its giving error, as I am new to this procedure, please advise what am I missing ?
    Best Regards,
    Luqman
    My code is as below.
    CREATE TYPE num_array AS table of number;
    create or replace procedure give_me_an_array
    ( p_array in num_array )
    as
    begin
    for i in 1 .. p_array.count
    loop
    dbms_output.put_line( p_array(i) );
    end loop;
    end give_me_an_array;
    declare
    mdata num_array;
    begin
    mdata(1) := 1234;
    mdata(2) := 10;
    give_me_an_array(mdata);
    end;

    Hi Satya,
    Now I got it, thanks,
    Can you please advise, if I use the same stored procedure for EMP Table and use my array values to retrieve the selected EMPNo
    I tried following but I could not succeed.
    When I compile the stored procedure, error occurs:
    "inconsistent datatypes: expected NUMBER got NUM_ARRAY"
    for example:
    CREATE TYPE NUM_ARRAY AS TABLE OF NUMBER;
    Create or Replace Package TB_Data
    Is Type CV_Type Is REF CURSOR;
    END TB_DATA;
    Create or Replace Stored Procedure give_me_an_array
    (CV IN OUT TB_DATA.CV_TYPE,
    MEmpNo In Num_Array)
    Is
    Begin
    Open CV for
    Select * from EMP
    Where Empno in MEmpNo;
    End myProc;
    declare
    mdata num_array:=num_array(7839,7844);
    begin
    give_me_an_array(mdata);
    end;
    Best Regards,
    Luqman

  • Warnings in stored procedure

    i am new to oracle i am writing a stored procedure of about 1600 lines when i compiled the stored procedure
    it is giving me warnings AND not any error and got compiled successfully which i write below
    warnings
    Warning(6,2): PLW-07203: parameter 'P_RN' may benefit from use of the NOCOPY compiler hint
    Warning(168,72): PLW-07204: conversion away from column type may result in sub-optimal query plan
    Warning(169,48): PLW-07204: conversion away from column type may result in sub-optimal query plan
    Warning(1,1): Only first 20 issues are reported -- coming at last
    and when check the status of the stored procedure by running the below query
    informing that object is INVALID
    select status from all_objects where object_name='USP_GENERATERUNNINGNUMBER';
    and as far as i know that if warnings come and no error then it means procedure has been
    compiled successfully and becomes VALID
    please help me somebody

    thanks for your reply but its status is coming INVALID this i am not understanding when the procedure has been compiled its status should become valid and this also giving me this message
    Warning(1,1): Only first 20 issues are reported
    what i am thinking that after 20 warnings there may be a error which it is not showing
    please guide me in this aspect

  • XmlAgg Order By in SQL Statement vs Stored Procedure - 9.2.0.3.0

    Hi All,
    I'm having a problem with the XMLAgg function's ORDER BY clause after upgrading to 9.2.0.3.0.
    I'm finding that I can succesfully execute a SQL statement with the XMLAgg ORDER BY clause, but cannot compile a stored procedure using ORDER BY. Below are two examples executing against the SCOTT Schema. They use the same code, except one is contained in a procedure.
    I'm running 9.2.0.3.0 on Windows XP Pro, SP1
    Plain SQL Statement (executes correctly):
    SELECT
    XMLElement("test",
    XMLAgg(
    XMLElement("element",
    XMLAttributes(Scott.Emp.Ename as "ename", Scott.Emp.Empno as "enum")
    ) --xmlElement element
    ORDER BY Scott.Emp.Ename desc
    ) --XmlAgg
    ).getClobVal() --xmlElement test
    as TestXML
    from Scott.Emp;
    Stored Procedure:
    create or replace procedure zorder(TestXML OUT clob) is
    begin
    SELECT
    XMLElement("test",
    XMLAgg(
    XMLElement("element",
    XMLAttributes(Scott.Emp.Ename as "ename", Scott.Emp.Empno as "enum")
    ) --xmlElement element
    ORDER BY Scott.Emp.Ename desc
    ) --XmlAgg
    ).getClobVal() --xmlElement test
    into TestXML
    from Scott.Emp;
    end zorder;
    I get the following errors when attempting to compile the stored procedure:
    7 PLS-00306: wrong number of types or arguments in call to 'XMLAGG'
    7 PL/SQL: ORA-00904: "XMLAGG": invalid identifier
    5 PL/SQL: SQL Statement ignored
    Does anybody know why this code executes correctly in a SQL statement, but fails in a procedure? Is the Order By clause not available in a procedure? I need to get this functionality working in the procedure.
    Thanks,
    Brian

    A good simple workaround (that doesn't require runtime parsing) is to simply sub-query:
    SELECT
    XMLElement("test",
        XMLAgg(
            XMLElement(
                "element",
                XMLAttributes(Scott.Emp.Ename as "ename", Scott.Emp.Empno as "enum")
            ) --xmlElement element
        ) --XmlAgg
    ).getClobVal() --xmlElement test
    into TestXML
    from (
        SELECT Ename,Empno
        FROM Scott.Emp
        ORDER BY Scott.Emp.Ename desc

Maybe you are looking for

  • Interrmittant dispaly of error message on JSP Page

    Hi , I am developing an application using JSP and servlets. I ma having a peculiar issue with it. I have few links on a JSP page. When a user clicks on the link, its credentials are verified from database and if he is authorised, he will be taken to

  • Item numbers are differing when i am creating billing document.

    item numbers are differing when i am creating billing document with reference to delivery. eg:  item 10  Nimusulide       item 20 paracetomol but in invoice it is as follows item 50  Nimusulide item 100 paracetomol plz help me

  • Color using only one CPU?

    When rendering with Color it seams that it using only one CPU, according to "top". Is it possible to make use of all CPUs?

  • WP die but R3trans is ok

    My sap system is 46D-ext running on Win2003/ora10.2 oracle start with no error, but SAP don't. I get message "db connect failed" and all the wp die. R3trans -d is ok : C:\Documents and Settings\bcpadm>R3trans -d This is R3trans version 6.05 (release

  • Parameters in a PROC

    Can any one please tell me how to deal with parameters within a procedure. I am passing 2 dates to the procedure. Later I am trying to delete all the records that are greater than one date and also delete all those records that are lesser than oher d