Exit stored procedure after UPDATE

Hello,
I have written a LOOP that calls a second Stored Procedure.
In the second Stored Procedure I have 3 INSERTS each SELECT's values limited with a WHERE clause.
Example:
begin
dynsql:=INSERT INTO destinationtable (ID,DATE,NAME)
SELECT src.ID,src.DATE, dest.NAME FROM sourcetable src INNER JOIN destinationtable dest ON dest.ID=src.ID WHERE dest.date between '01.JAN.2012 and '03.JAN.2012' --if not condition not met, no insert
execute immediate dynsql;
dynsql:=UPDATE destinationtable SET DATE = dest.DATE FROM sourcetable src INNER JOIN destinationtable dest ON dest.ID=src.ID WHERE dest.date between '01.JAN.2012 and '03.JAN.2012'
execute immediate dynsql;
dynsql:=INSERT INTO destinationtable (ID,DATE,NAME)
SELECT src.ID,src.DATE, dest.NAME FROM sourcetable src INNER JOIN destinationtable dest ON dest.ID=src.ID WHERE dest.date between '01.APR.2012 and '01.MAY.2012'  --if not condition not met, no insert
execute immediate dynsql
dynsql:=UPDATE destinationtable SET DATE = dest.DATE FROM sourcetable src INNER JOIN destinationtable dest ON dest.ID=src.ID WHERE dest.date between '01.APR.2012 and '01.MAY.2012'
execute immediate dynsql;
dynsql:=INSERT INTO destinationtable (ID,DATE,NAME)
SELECT src.ID,src.DATE, dest.NAME FROM sourcetable src INNER JOIN destinationtable dest ON dest.ID=src.ID WHERE dest.date between '01.JUN.2012 and '01.JUL.2012'  --if not condition not met, no insert
execute immediate dynsql;
dynsql:=UPDATE destinationtable SET DATE = dest.DATE FROM sourcetable src INNER JOIN destinationtable dest ON dest.ID=src.ID WHERE dest.date between  '01.JUN.2012 and '01.JUL.2012'
execute immediate dynsql;
end;
commit;What do I do?
I update the existing "old" row with a new date and then I am basically duplicating that row but adding it with a new DATE, the ID and NAME is "copied" as it is.
The big problem is that the rows result in recursive updates. if the first statement updates a date it might make the conditions for the second and first update become "true".
Which is not what I want. Initially, only one of the statements is true, ever. The problem with my code is that after the first update and date setting, another "might" become true.
This should stop. After one of the updates occured, I need to stop the stored procedure.
How do I stop it after upate?

metalray wrote:
Hello BlueShadow, that makes sense. Thanks.
Can you tell me when sql&rowcount is reset, after an execute immediate, after a commit?It doesn't get 'reset' in the strict sense. When a PL/SQL program unit is initiated the implicit "SQL" cursor space is defined and exists in the scope of that program unit. At that point it is like any variable that is declared with it's value undefined (null). When you issue any DML statement (insert, update, delete, merge etc.), these will explicitly set the ROWCOUNT attribute within the SQL cursor space. Other SQL statements are also issued from PL/SQL through the SQL "space" (interface), and as such, they may (it's not defined anywhere) effect the values of attributes within it, including the ROWCOUNT, but we cannot say exactly in what way. Therefore, the only thing that can be definitely determined is that a) when it's first instantiated, the SQL%ROWCOUNT will be null, and also, )_immediately_ after any appropriate DML statement the SQL%ROWCOUNT will contain the number of rows effected. If the SQL%ROWCOUNT value is examined at any other point, the value is indeterminate so, for example, after a commit statement, we cannot be sure what value it has or what that value refers to.
I loop through each tax no. need to do either an update, update or delete, delete, each with different WHERE clauses. the danger is that
I update and then the where clause for the deletion becomes true, but my process should not do the deletion if an update happened. its a sequential check and ones true and update/deletion made, the loop stored procedure should terminate. right now I check for sql&rowcount to "not" get into a update or delete if one already happened but I fail to grasp the logic of when sql&rowcount gets which value . I have the feeling that the parent stored procedure that calls my second one with the update and deletes sets the sqlrowcount to 1 because it has an insert. (I use 11g)After your insert/update you should immediately get the value of SQL%ROWCOUNT into a variable, so that you have the value before it is effected by other statements.
You can then use that value in your variable to determine program logic e.g. whether the delete should process or not, regardless of whether you issued further code between the insert/update and the check to see if you should delete. Don't rely on things 'resetting' the ROWCOUNT attribute, only rely on things setting it.

Similar Messages

  • Strange error on stored procedure after update to version 7.6.06.10

    Hi,
    in past version MaxDB 7.6.03 i created a stored procedure with follow SQL statement inside:
    TRY
                SELECT SUM(QTDE) QTDE_SAIDA
                   FROM VENDOR_CONCES.MVIEW_MOVPRODUTOS mviewS
                   WHERE mviewS.MY_EMPRESA = :OID_EMPRESA AND
                         mviewS.MY_PRODUTO_DEF = :OID_PRODUTO_DEF AND
                         mviewS.GERA_ESTOQUE = 'S' AND
                         mviewS.TIPO = 'S' AND
                         mviewS.DATA BETWEEN :MAX_DATA_ESTOQUE_INICIAL AND :DTA_ESTOQUE AND
                         EXISTS(SELECT * FROM VENDOR_CONCES.MVIEW_MOVPRODUTOS mviewE WHERE 
                            mviewE.my_Empresa = mviewS.my_Empresa AND
                            mviewE.tipo = 'E' AND
                            mviewE.data <= mviewS.data AND
                            mviewE.my_Produto = mviewS.my_Produto AND
                            mviewE.gera_Estoque = 'S' AND
                            mviewE.gera_Financeiro != 'N'
                FETCH INTO :QTDE_SAIDA;
            CATCH
                IF $rc <> 100 THEN STOP ($rc, 'unexpected error ao contar Saidas');
    if execute that procedure with new version 7.6.06.10 i get an error:
    (at 1834): Data types must be compatible.
    the line of error is this:
    mviewS.DATA BETWEEN :MAX_DATA_ESTOQUE_INICIAL AND :DTA_ESTOQUE AND
    if i remove the EXISTS part that procedure works, but i need to use EXISTS there.
    ps: MVIEW_MOVPRODUTOS is a table, not a view, i preceed tables with MVIEW for tables created by triggers, to simulate Materialized Views.
    ps2: DATA field is DATE field on english.
    any idea what can be wrong?
    best regards.
    Clóvis

    Hi, Elke
    you are right, changing SELECT * to SELECT oid works, follow the full procedure with changes:
    CREATE DBPROC SP_ESTOQUE_ATUAL_DATA_PROD_DEF (
        IN OID_EMPRESA VARCHAR(8),
        IN OID_PRODUTO_DEF VARCHAR(8),
        IN DTA_ESTOQUE TIMESTAMP,
        OUT ESTOQUE_ATUAL VARCHAR(200))
    AS
        VAR MAX_DATA_ESTOQUE_INICIAL TIMESTAMP;
            QTDE_ESTOQUE_INICIAL FIXED(10,3);
            QTDE_SAIDA FIXED(10,3);
            QTDE_ENTRADA FIXED(10,3);
        BEGIN
            TRY
                SELECT MAX(DATA) MAX_DATA_ESTOQUE_INICIAL
                   FROM VENDOR_CONCES.ESTOQUEINICIAL
                   WHERE MY_EMPRESA = :OID_EMPRESA AND
                       MY_PRODUTO = :OID_PRODUTO_DEF AND
                       DATA <= :DTA_ESTOQUE;
                FETCH INTO :MAX_DATA_ESTOQUE_INICIAL;
            CATCH
                IF $rc <> 100 THEN STOP ($rc, 'unexpected error em MAXDATAEINI');
            TRY
                IF MAX_DATA_ESTOQUE_INICIAL IS NULL THEN BEGIN
                    SET MAX_DATA_ESTOQUE_INICIAL = '1900-01-01 00:00:00.000';
                    SET QTDE_ESTOQUE_INICIAL = 0;
                END ELSE BEGIN
                    SELECT QTDE QTDE_ESTOQUE_INICIAL
                       FROM VENDOR_CONCES.ESTOQUEINICIAL
                       WHERE MY_EMPRESA = :OID_EMPRESA AND
                           MY_PRODUTO = :OID_PRODUTO_DEF AND
                           DATA BETWEEN :MAX_DATA_ESTOQUE_INICIAL AND :DTA_ESTOQUE;
                    FETCH INTO :QTDE_ESTOQUE_INICIAL;
                END;
            CATCH
                IF $rc <> 100 THEN STOP ($rc, 'unexpected error em Carregamento do Estoque Inicial');
            TRY
                SELECT SUM(QTDE) QTDE_SAIDA
                   FROM VENDOR_CONCES.MVIEW_MOVPRODUTOS mviewS
                   WHERE mviewS.MY_EMPRESA = :OID_EMPRESA AND
                         mviewS.MY_PRODUTO_DEF = :OID_PRODUTO_DEF AND
                         mviewS.GERA_ESTOQUE = 'S' AND
                         mviewS.TIPO = 'S' AND
                         mviewS.DATA BETWEEN :MAX_DATA_ESTOQUE_INICIAL AND :DTA_ESTOQUE AND
                         EXISTS(SELECT oid FROM VENDOR_CONCES.MVIEW_MOVPRODUTOS mviewE WHERE 
                            mviewE.my_Empresa = mviewS.my_Empresa AND
                            mviewE.tipo = 'E' AND
                            mviewE.data <= mviewS.data AND
                            mviewE.my_Produto = mviewS.my_Produto AND
                            mviewE.gera_Estoque = 'S' AND
                            mviewE.gera_Financeiro != 'N'
                FETCH INTO :QTDE_SAIDA;
            CATCH
                IF $rc <> 100 THEN STOP ($rc, 'unexpected error ao contar Saidas');
            TRY
                IF QTDE_SAIDA IS NULL THEN
                    SET QTDE_SAIDA = 0;
            CATCH
                IF $rc <> 100 THEN STOP ($rc, 'unexpected error ao zerar saida');
            TRY
                SELECT SUM(QTDE) QTDE_ENTRADA
                   FROM VENDOR_CONCES.MVIEW_MOVPRODUTOS
                   WHERE MY_EMPRESA = :OID_EMPRESA AND
                       MY_PRODUTO_DEF = :OID_PRODUTO_DEF AND
                       GERA_ESTOQUE = 'S' AND
                       TIPO = 'E' AND
                       DATA BETWEEN :MAX_DATA_ESTOQUE_INICIAL AND :DTA_ESTOQUE;
                FETCH INTO :QTDE_ENTRADA;
            CATCH
                IF $rc <> 100 THEN STOP ($rc, 'unexpected error ao contar entradas');
            TRY
                IF QTDE_ENTRADA IS NULL THEN
                    SET QTDE_ENTRADA = 0;
            CATCH
                IF $rc <> 100 THEN STOP ($rc, 'unexpected error ao zera entrada');
            TRY
                SET ESTOQUE_ATUAL = CHR(QTDE_ESTOQUE_INICIAL + QTDE_ENTRADA - QTDE_SAIDA);
            CATCH
                IF $rc <> 100 THEN STOP ($rc, 'unexpected error');
        END;
    about the error, I discovered the line using database studio, as I droped the old procedure and tried to recreate, database studio says that error is at BETWEEN expression, but you find the right problem with select * in exists.
    best regards
    Clóvis

  • How to use the Stored Procedure to update my UDF

    I want to use the Stored Procedure to update my UDF U_InstokCS when the warehouse "OnHand" was changed. The UDF is display the stock by cases. I copied the query as follewing. I couldn't see any thing in the UDF after I made some transactions. Can anybody tell me why? How to continue it?
    if @transaction_type in ('A','U','D') and @Object_type='64'
    begin
    Update OITW
    Set U_InstokCS = OnHand/(Select T0.NumInBuy from [DBO].[OITM] T0
    Where T0.ItemCode = @list_of_cols_val_tab_del)
    Where ItemCode = @list_of_cols_val_tab_del
    end
    Thanks.
    Ying Zhang

    Ying,
    The use of any stored procedures against the SAP Business One database is not allowed per SAP Support.  There is not an instance where you can use SP's.  The ONLY SP that you are allowed to use is the SBO_SP_TransactionNotification SP that comes with SAP Business One itself. You can read about the use of this SP from this article...
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e991e2b9-0901-0010-0395-ef5268b00aaf
    Eddy

  • Stored Procedure to update Ids

    Hi,
    I want to write a stored procedure to update IDs in detail table by matching description from master table i.e.
    TabMaster
    Col1: 1 2 3 4 5 6 7 8
    Col2: A B C D E F G H
    TabDetail
    Col:
    Col2: D B C E D A A B G H C
    Please Help!
    Thanks in advance

    Now sure what you are really after, but it looks like you may only need a correlated update statement. This statement can then be put inside a stored procedure:
    UPDATE  TabDetail TD
    SET     Col = (
                    SELECT  Col1
                    FROM    TabMaster TM
                    WHERE   TD.Col2 = TM.Col2
                  )This will update ALL the rows in the TabDetail table. However if you need to restrict the rows to be updated you can always add on a WHERE clause.

  • Stored procedure to update particular key column with increment of +1

    Hi,
    This is my table
    EMPID,NAME
    1 SSS
    2 AAA
    I NEED STORED PROCEDURE TO UPDATE EMPID WITH INCREMENT OF +1.BASED ON
    MAX(EMPID).fOr example if i execute stored procedure once it will update empid 2 as 3,
    if i run same procedure again it will take increment +1 then emp id should be 4 like that i want output.
    Any one please help me on this scenario...

    937506 wrote:
    Hi All,
    I have two tables,one is date dimension table,one is fact table.
    when we load data through informatica (source as csv file),then key will be populated in fact table based on lookup on
    date dimension table.it will create corresponding date key in fact table.
    My scenario:we load data in to fact table with etl with "n" number of records only once at a time.
    But next time onwords we will update that datekey in fact table through stored procedure.stored procedure
    will take only max(date_key) from fact table then update that key as like +1(logic n+1)
    If i run stored procedure nextday it will update that record with increment +1.
    we wil schedule this storedprocedure to run daily once.For this i need stored procedure..
    I think you will clear now................
    thxSo, are you saying you want to keep the same data you loaded "yesterday" but update the date_key so it appears as if it was from today?
    Still seems strange: why aren't you loading today's data?
    Also, you are assuming that the date_key in the date dimension table increments with no gaps: if it was sequence generated, that might not be true.

  • With clause in a stored procedure with update

    create table TEMP_STAGE as
    (select '111111' student_id, 'N' TMP_TEST FROM DUAL
    UNION
    select '111111' student_id, 'N' TMP_TEST FROM DUAL
    UNION
    select '222222' student_id, 'N' TMP_TEST FROM DUAL
    CREATE OR REPLACE PROCEDURE TEMP_SEC_TEST
    AS
    BEGIN
    UPDATE TEMP_STAGE S
    SET S.TMP_TEST = 'Y'
    WHERE STUDENT_ID IN
    WITH MARK AS
    SELECT '111111' STUDENT_ID FROM DUAL
    select STUDENT_ID from MARK
    END;
    I have a huge sql statement with several 'with' tables in the statement...It works if I execute it as a script but it does not work when I put it in a stored procedure.
    When I execute the above it gives me an error...
    Error Syntax Check (8:9)
    Found 'MARK' expecting .....
    It gives me an error at the wth Mark as line....
    I have to do it in the stored procedure as the statement is very complicated...
    Please help.

    What tool are you using to create the procedure? Error Syntax Check (8:9) is not an Oracle error, nor as far as I know from any Oracle product.
    It works just fine in sqlplus.
    SQL> CREATE procedure my_p AS
      2  BEGIN
      3     UPDATE t
      4     SET descr = 'Un'
      5     WHERE id IN (WITH tmp AS (
      6                     SELECT 1 x FROM dual)
      7                  SELECT x FROM tmp);
      8  END;
      9  /
    Procedure created.
    SQL> SELECT * FROM t;
            ID DESCR
             1 One
    SQL> exec my_p;
    PL/SQL procedure successfully completed.
    SQL> SELECT * FROM t;
            ID DESCR
             1 UnJohn

  • Stored Procedure for updating dynamic columns in a table

    I have a table with a lot of columns around 30ish
    Now I want to create a stored procedure that will update a specific column to a new value.
    I the @columname and @newvalue to be the parameters, and an addition @itemId for the WHERE clause so it will update that specific row/data only.
    here's my Stored Procedure
    USE [db]
    GO
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[usp_UpdateData]
    @itemID int,
    @ColumnName varchar(50),
    @newValue nvarchar(50)
    AS
    BEGIN
    Update dbo.ProjectAllocation
    Set @ColumnName = @newValue
    Where itemID = @itemID END
    When I pass the following
    @ColumnName: UserName
    @newValue: NewUserName
    @itemID: 1
    it doesnt update row with itemID = 1.
    How can I do this?
    ----------------------- Sharepoint Newbie

    Did you try my last post method. Its better to use parameterized approach.
    Anyway, if you want to change your code,you may need to change as below.....
    SET @sql = 'UPDATE dbo.table SET ' + @ColumnName + '=''' + @newValue + ''' WHERE [itemID] = ' + cast(@itemID as varchar(50));

  • Query slower in stored procedure(after upgrade to 16)

    Hi all,
    We are looking to upgrade our SQL Anywhere 9 database to 16. We thought version 16 is slower in update tables, but the reason of slowness are query's in stored procedures called from the trigger. One of the query's has a duration of 8 times the duration in version 9!! When I run the query in Interactive Sql(v16), they run fast like version 9. So the query runs slower in a stored procedure.
    I thought parameter sniffing, but it's not MS Sql Server. I've no idea why it was good in v9 and bad in v16. Have someone a idea?
    It's a query with subquery's in the where , a view in the from. In the view are unions. Looks not so special.
    thanks

    It may be more convenient for you to ask this question on the other forum: SAP SQL Anywhere Forum
    Preamble...
    It sometimes happens that (a) the same query will perform faster or slower in different versions because of different behaviors by the query optimizer. In most cases a minor change is necessary to restore good performance; in some rare cases, the changes are difficult.
    It also sometimes happens that (b) the same query will perform faster or slower under different operating conditions; e.g., client request (ISQL) versus inside a BEGIN block (stored procedure). Again, minor changes all that's required in most cases, sometimes otherwise.
    Details...
    In order to help, we will need more information. Two graphical plans with statistics for the same problematic query, both using V16, one captured in ISQL, and the other one captured inside the stored procedure, is the best way to pass on the information; ALL OTHER forms are inadequate, especially prose descriptions and edited snippets of code (that way lies frustration for all parties).
    There are a number of articles about graphical plans on this blog.

  • Check Stored Procedures after Migration from MS SQL Server 2008 to Oracle11

    I successfully migrated my application database (azteca) from MS SQL Server 2008 to Oracle 11g R2. After migration, I found there are few stored procedures are not valid. How do I check these invalid stored procedures and find what is wrong with them by using SQL Developer? Thanks for your help.
    Kevin

    Hi Kevin,
    You posted quite a bit today, so perhaps you have already worked this out. If not...
    1. View -> Reports -> Data Dictionary Reports -> All Objects -> Invalid Objects [for a specific schema name]
    2. Next, for each invalid stored procedure listed in (1)...
    a. Open in the code editor from the Connections navigator tree
    b. Click on the Compile icon (two gears meshed together) in code editor tool bar.
    c. Look in the Compiler log pane for errors.
    d. Correct the errorsOf course, success in addressing any errors depends on your skill level dealing with Oracle PL/SQL.
    Also, it may be helpful to read over section *3.2 Stored Procedures* in the supplementary migration guide:
    http://docs.oracle.com/cd/E35137_01/doc.32/e18462/trig_stored_proc.htm#CHDEIGBC
    Regards,
    Gary
    SQL Developer Team

  • Stored Procedure - for update of commit problem

    HI all,
    I am getting an ORA-01002 error when rnning my stored procedure. I understnad this is because i am "commiting" when using a "For update of". But I am not sure how to commit or rollback this transaction. The procedure is below.

    oraCraft wrote:
    Do you know any way I can clean the code?Depends what's wrong with it. If you are getting the message 'Sorry, this content is not allowed' then there is a word blocked by the forum software (like 'dis&#99;ount').
    If it doesn't display at all, then it may be to do with HTML. For example, posting <tt>&lt;></tt> is tricky.

  • Form on table: Using stored procedure to update?

    I have a view which joins a handful of tables. I have a PL/SQL API that contains all the necessary business logic and translations to update the tables underlying this view.
    If I use the HTMLDB wizard to create a form on this view, it would automatically generate plain INSERT/UPDATE statements for DML against the view. How can I make it use my API instead? (Yes, I can probably plug in my API in INSTEAD OF triggers on the view, but I really dont want to do that)
    [Of course, the reason I would use the built-in form-on-table wizard is to get the automatic lost-update detection, locking, etc features]
    Help? Thanks

    The wizards are there to help you build typical pages like "form based on a table", "form on based a stored procedure".
    There is no wizard for "form based on a view, using my own API for inserts, updates and delete" - but that doesn't prevent you building such a form by hand. I have built similar forms, and found it quite easy to approach it like this:
    1) use "form based on a stored procedure" to create a form based on your API insert procedure
    2) add further buttons and processes to call your API's update and delete procedures
    3) add an "on load" process to select the row from the view and populate the form for update or delete
    You need to add some logic for context-sensitivity - e.g. Update and Delete buttons only appear when in "update mode", etc.

  • Stored Procedure to update some or all fields of a record

    Hi,
    I want to create a stored procedure in oracle pl/sql 8.1.7 which takes all field values of a table as a parameters and update the table. What if i want to update only selected fields via same procedure? Can we have something like this:
    create table students (stdno number(4), stdname varchar2(20), stdaddress varchar2(30));
    create procedure update_student (stdno2 number, stdname2 varchar2, stdaddress2 varchar2 default :old.stdaddress)
    begin
    update students set stdname = stdname2, stdaddress = stdaddress2 where stdno = stdno2;
    end;
    exec update_student(12, 'Ali');
    And it updates only student name?
    Thanks.

    create or replace
    procedure update_student (p_stdno number, p_stdname varchar2 default null, p_stdaddress varchar2 default null) is
    begin
    if p_stdname is not null or p_stdaddress is not null then
    update students A
    set stdname = nvl(p_stdname ,A.stdname )
    ,stdaddress = nvl(p_stdaddress,A.stdaddress)
    where stdno = p_stdno
    end if ;
    end ;

  • Stored procedure to update the new table by using back up table

    Hi all,
    oracle version -10g
    iam planning to do one time legacy conversion during the migration of one of the tables.
    for that i took the back up of table , now i need to transfer all of the data from the backup table to the new table with some changes..
    so please suggest me how to write the stored procedure?
    back up table name: test t
    new table: test n
    new table will have extra one row .. in that i need to put the logic
    so am planning to write a procedure like below
    create or replace procedure test as
    begin
    insert into TEST T ( u
              v
              w
              X
              y
              z) VALUES
    SET T.U = O.U
    T.V = O.V
    T.W = DECODE(O.W, AD     '01',
                   00     '01')
    T.X = O.X
    T.Y = IF O.W = 'AD' AND O.Y = 'YES' THAN PUT 'AD'
         IF O.W = '00' AND O.Y = 'YES' THAN PUT 'PD'
    IF O.W NOT IN ('AD','00') AND O.Y = 'YES' THEN PUT 'E'
    O.Y= 'NO' THEN PUT 'D'.
         '

    10g is not an Oracle version number. Please run the following:
    SELECT * FROM v$version;What about your situation indicates a requirement for a stored procedure? I wouldn't write one based on what you have posted. It seems, again from what little you posted, that all you need is:
    INSERT INTO <new_table>
    SELECT ... FROM <temp_table>;

  • Problem with Update Select in Stored procedure

    I am using Oracle 8. I'm writing a StoredProcedure and Oracle doesn't like the statement:
    update
    Leave_Coverages
    set
    Rate_Monthly = Rate_Monthly + (select Rate_Monthly from Leave_coverages where Leave_Coverage_ID = 10800)
    where
    Leave_Coverage_ID = 10799;
    When I run the above statement from the command line - I have no problem. This statement in the stored procedure works:
    update
    Leave_Coverages
    set
    Rate_Monthly = Rate_Monthly + 4
    where
    Leave_Coverage_ID = 10799;
    So essentially, I'm having trouble using a select in an update statement, but only in a Stored Procedure.

    Denis,
    This question was answered on this forum in the last week or so but I wasn't quickly able to locate this post.
    Basically Oracle prior to version 9 had an SQL parser and a separate PL/SQL parser. The PL/SQL parser had to be updated each time new features were added to the SQL parser; often it lagged behind so that there were things you could do in plain SQL but weren't supported when using the same SQL in a cursor or directly in PL/SQL (with an INTO clause or RETURNING ... INTO clause).
    From Oracle 9 these two parsers have been rolled into one so that new features introduced into SQL automatically also become available when used from PL/SQL.
    So the answer to your curiousity on whether it will work in 9 or 10 is: if it works in SQL it should work just fine from PL/SQL.
    Cheerio,
    Colin

  • Parent-Child Table Update via Single Stored Procedure

    Uses: Oracle 9i Server via a Remote Connection with restriction, Oracle 9i client, .NET 2.0+System.Data.Oracle namespace, Delphi+BDE;
    I have an entry form which consists of a parent and a child table. I'm so keen in knowing whether there is any possibilities of updating the records via a single stored procedure? I mean if parent have a single record and corresponding to it, child have few records (more than 1 rows). I need to take the parent's value and child's value send it to the stored procedure and update it.
    Regards,

    The entry form gets the raw data from the user. So yes the data is captured front end but not updated nor processed. Once the user clicks "Save" or what ever the values are taken to the SP. In the SP the operations are done either as update or insert. Lets concentrate on Inserts only at the moment.
    I.e. there are 2 tables as:
    tbl_Payment(_PaymentID_, PaymentMode,PaymentDate, TotalPaymentValue);
    tbl_PaymentAccount(_PaymentID,AccountID_,PaymentValue);
    So the form has a top part which is bounded to the Parent Table which is "tbl_Payment" to few text boxes, and below it has a Datagrid, bounded to Child Table which is "tbl_PaymentAccount". And assume the the Single Stored Procedure as "sp_payment_addchg".
    I can pass newly entered values to the SP as:
    Command.Text = "sp_payment_addchg";
    /*so all the parent table bounded values are updated as*/
    Command.Parameter[0].value = text1.text;
    Command.Parameter[1].value = text2.text;
    and so on
    Since the DataGrid may have multiple rows, I cant figure it out how to get those rows into a single parameter.
    Regards,

Maybe you are looking for