Records Not Commiting - PLSQL Block

Hi,
Good Day to all..
DECLARE
  v_annotation_id_1   VARCHAR2(200):='101';
  v_annotation_type_1 VARCHAR2(200):='OMG';
  v_j                 NUMBER;
  v_user_id_string    VARCHAR2(200);
  v_user_id           NUMBER;
BEGIN
  FOR v_j IN 1..2
  LOOP
    SELECT MAX(TRUNC(NVL(user_id,0)))
    INTO v_user_id_string
    FROM TABLE_XXX;
    v_user_id:= to_number(trim(v_user_id_string))+1;
    dbms_output.put_line('v_user_id_string-->'||v_user_id_string);
    dbms_output.put_line('v_user_id-->'||v_user_id);
    INSERT
    INTO TABLE_XXX
        TTT_annotation_id,
        user_id,
        digital_package_id,
        annotation_id,
        time_code,
        annotation_type,
        created_date,
        created_by
      VALUES
        seq_TTT_annotation_id.nextval,
        v_user_id,
        1004,
        v_annotation_id_1,
        100,
        v_annotation_type_1,
        sysdate,
        'TTTService'
       dbms_output.put_line('v_user_id 1 -->'||v_user_id);
    INSERT
    INTO TABLE_XXX
        TTT_annotation_id,
        user_id,
        digital_package_id,
        annotation_id,
        time_code,
        annotation_type,
        created_date,
        created_by
      VALUES
        seq_TTT_annotation_id.nextval,
        v_user_id,
        1004,
        v_annotation_id_1,
        100,
        v_annotation_type_1,
        sysdate,
        'TTTService'
      dbms_output.put_line('v_user_id 2 -->'||v_user_id);
     COMMIT;
     DBMS_OUTPUT.PUT_LINE('SQL%ROWCOUNT -->'||SQL%ROWCOUNT);
  END LOOP;
  COMMIT;
END;
Sample Output
v_user_id_string-->100002828932367
v_user_id-->100002828932368
v_user_id 1 -->100002828932368
v_user_id 2 -->100002828932368
SQL%ROWCOUNT -->0
v_user_id_string-->100002828932368
v_user_id-->100002828932369
v_user_id 1 -->100002828932369
v_user_id 2 -->100002828932369
SQL%ROWCOUNT -->0
TABLE_XXX --> Primary Key - TTT_annotation_id NOT NULL Datatype: NUMBER
Data is not getting committed; when i checked the SQL%ROWCOUNT it shows "0".
I have no idea why it is not commiting the data.
All the sessions are either COMMITTED or ROLLBACK.
Thanks for reply....

You are over committing.
SQL> create table t (n number);
Table created.
SQL> set serverout on
SQL> begin
  2    insert into t values (1);
  3    dbms_output.put_line ('Rows inserted: '|| sql%rowcount);
  4  end;
  5  /
Rows inserted: 1
PL/SQL procedure successfully completed.
SQL> edi
Wrote file afiedt.buf
  1  begin
  2    insert into t values (1);
  3    commit;
  4    dbms_output.put_line ('Rows inserted: '|| sql%rowcount);
  5* end;
SQL> /
Rows inserted: 0
PL/SQL procedure successfully completed.Commit ends the current transaction and will result in subsequent sql%rowcount being zero.

Similar Messages

  • Record not in plsql but appears in report

    Hi,
    I am trying to check why certain records are appearing in a Discoverer aging report but not in the Trial Balances. The Discoverer report is based on an sql custom folder with a join to po_vendors with the vendor_id (1 to 1, no outer joins...) .
    It appears to be that the missing invoices in the Trial Balances are the ones that have status "needs revalidation" or "never validated".
    In order to check these records, I figured that I would do the usual, i.e. run the sql in plsql with an extra condition "where invoice_num = " and "vendor_id = ", and then begin playing around with the where statement.
    The surprise is that I cannot get those records when I run the sql in plsql. I tried retrieving 6 records: 4 records that do not appear in the Trial Balances and 2 that are in the Trial Balances. The two that appear in the Trial Balances are retrieved, but the other four are not.
    How can it be that I am getting records in a report which are not retrieved from the main sql? I tried removing the po_vendor folder from the report (I did not delete the join), but it made no difference. I cannot theoretically understand how this is happening.
    Can anyone help?
    Thank you.
    Leah

    Thank you to anyone who checked this out. I was beginning to think that there was a problem with a function, but everything seems to be working now. I redefined the sql.
    Thanks again.
    Leah

  • Transaction not committed

    Hi
    how can i find transaction not committed? I cannot find in v$lock, but i want find first transaction, which is not committed and block others.
    Any ideas?
    Thanks

    Use v$transaction view to check uncomiited transactions.
    See here it's already discussed:
    Re: How to query uncommited transactions
    Locked objects can find with this select:
    select
    c.owner,
    c.object_name,
    c.object_type,
    b.sid,
    b.serial#,
    b.status,
    b.osuser,
    b.machine
    from
    v$locked_object a ,
    v$session b,
    dba_objects c
    where
    b.sid = a.session_id
    and
    a.object_id = c.object_id;

  • Can not delete record from the master block ,frm-40202 field must be entere

    hi ,
    i have built a form which contain master and details blocks
    the problem is
    when i try to delete a record from the master block it gives me new serial for the transaction and when i try to save it, it says
    >frm-40202 field must be entered
    where this field is required and i cant save it
    although in another form when i delete from the master it gives me the previous record and it works properly
    if any one has any ideas pls help me
    thank u
    ------- the master block has a trigger when-create-recoder
    Declare>v_dummy number;
    Begin
    Select nvl(max(ERNT_NO),0) + 1 >Into v_dummy
    From LM_RENT_EXPNMST >Where cmp_no = :LM_RENT_EXPNMST.cmp_no
    And brn_no = :LM_RENT_EXPNMST.brn_no>and fiscal_yr = :LM_RENT_EXPNMST.fiscal_yr;
    >:LM_RENT_EXPNMST.ERNT_NO := v_dummy;
    END;
    IF :PARAMETER.RNT_NO IS NOT NULL THEN
         :LM_RENT_EXPNMST.RNT_NO:=:PARAMETER.RNT_NO;
              :LM_RENT_EXPNMST.RNT_YR:=:PARAMETER.RNT_YR;
         :LM_RENT_EXPNMST.CUST_DESC:=:PARAMETER.RNT_ADESC;
    END IF;Edited by: ayadsufyan on May 8, 2013 2:03 PM

    If this is a FORMS question you should mark this one ANSWERED and repost your question in the FORMS forum
    Forms

  • RFC fetching data from table which is not commited

    Hi Experts,
                   I have a query regarding commit work.Below is the RFC that i have written
    FUNCTION ZBAPI_CREATE.
    *"*"Local Interface:
    *"  TABLES
    *"      IT_ZABAP_RFC STRUCTURE  ZBAPI_RFC_STR OPTIONAL
    *"      RETURN STRUCTURE  BAPIRET2 OPTIONAL
    CALL FUNCTION 'ZBO_BAPI_CREATE'
    TABLES
       IT_ZABAP_RFC       = IT_ZABAP_RFC
       RETURN             = return
    Break-point.
    DATA lt TYPE TABLE OF ZBAPI_RFC_STR_MAIN.
    CALL FUNCTION 'ZBAPI_SEARCH_RANGE'
    * EXPORTING
    *   IS_STR        =
    TABLES
       ET_TAB        = lt
    *   RETURN        =
    ENDFUNCTION.
    here in first RFC call i am creating a record in ZTABLE , and then at break-point
    i check the ZTABLE where it does not create any record because data is not commited into ZTABLE upto this point, but just after it i have written code for fetching data from ZTABLE but i am able to get this new record in lt.
    Can anybody please explain that from where this serach RFC is providing data because inside serach i am simply selecting data from ZTABLE.
    Regards,
    Abhishek Bajpai
    Edited by: ABHISHEK BAJPAI on Jan 28, 2009 1:12 PM

    Hi Thomas,
                     Thanks for reply , i checked in ZTABLE ,before search RFC call data is not there but if i commit explicitly only then it is showing data in ZTABLE. Actually my requirement is different -
    I have two RFCs 1. Create 2. Search , Now  from web dynpro user will call first Create RFCs but at this point it should not insert record in ZTABLE and just after it user will call another search RFC and in this search he should be able to get these newly created records.
    I want to have the functionality which a user gets when working with normal database front end like SQLPLus for Oracle. In these scenarios we see that whenever user does any insert or update the data sits in the table but still it is not committed. So there he fires Select query he sees the inserted data. But if he logs off from SQL PLUS and then logs in again, and fires Select query he does not see the data as it was not committed. I want a similiar functionalty in which if user inserts the data through Create RFC and fires the Select query through Search RFC then he can see the newly Created data also even though this data is not committed.
    Although if i call create RFC in update task it will not update ZTABLE but in this situation , if user will call search RFC he will not be able to get newly created records.
    So my requirement is that i should be able to get those records which are not commited in ZTABLE .If you have still any doubt regarding my question then please let me know.
    Regards,
    Abhishek

  • Formula field, Detail records not getting updated

    Hello seniors,
    i need help on 2 issues;
    first, Issue No. 1
    i have master-detail form with the following tables;
    POH                                  master record table
    PH_NO                              pk
    PH_PARTY
    PH_FXRATE                       exchange rate
    PH_PD_LOCAL_TOT           total of PD_LOCAL_AMT  from details records
    PH_PD_FOREIGN_TOT       total of PD_FOREIGN_AMT  from details records
    POD                      Detail records table
    PD_PHNO              fk
    PD_ITEM
    PD_QTY
    PD_PRICE
    PD_LOCAL_AMT        
    PD_FOREIGN_AMT
    M_PD_FOREIGN_AMT       Formula (PD_QTY * PD_PRICE)
    M_PD_LOCAL_AMT           Formula (M_PD_FOREIGN_AMT/PH_FXRATE)
    CTRL                 Control block
    M_PH_PD_LOCAL_TOT           Summary-Sum-Table=POD, Field=M_PD_LOCAL_AMT
    M_PH_PD_FOREIGN_TOT       Summary-Sum-Table=POD, Field=M_PD_FOREIGN_AMT
    Triggers
    POH Table
    Pre-Insert   and   Pre-Update
    :PH_PD_LOCAL_TOT := :M_PH_PD_LOCAL_TOT
    :PH_PD_FOREIGN_TOT  := :M_PH_PD_FOREIGN_TOT
    POD Table
    Pre-Insert   and   Pre-Update
    :PD_LOCAL_AMT := :M_PD_FOREIGN_AMT
    :PD_FOREIGN_AMT :=  :M_PD_LOCAL_AMTThe problem that i am facing is while i UPDATE a record.
    whats happening is when the form is in Query mode and if i change a record, lets say
    change the value of the field PH_FXRATE, then what happens is, on screen i get all Detail
    record's M_PD_LOCAL_AMT Calculated & Updated, but the actual db field PD_LOCAL_AMT remains unchanged
    in the database after i press F10 or Save button.
    The update takes place for the POH table and form displays 1 Record updated.
    whereas if i have for example 4 detail records, then form should update those as well and display finally
    5 records updated is'nt it..?
    In query mode,if i insert new or modify an existing record in the detail block, then at this point, form marks just
    that particular record as CHANGED. Thus making changes at db level only for this particular record.
    what i want is once i make changes to the field PH_FXRATE, then form should mark all detail records
    as CHANGED and on saving, the PRE-UPDATE tigger of POD table should come in to force and the changes
    in the values of M_PD_LOCAL_AMT in turn to the db field PD_LOCAL_AMT should get affected at db level.
    i have also tried to put these assignments
    :PD_LOCAL_AMT := :M_PD_FOREIGN_AMT
    :PD_FOREIGN_AMT := :M_PD_LOCAL_AMT
    at PRE-UPDATE of POH table, thinking that form might consider
    all detail records, at this point. i noticed that it does it, but only picks
    1 record (i guess just the first record always) and change a db level.
    No. 2 Issue:
    i have put a POST-FORM-COMMIT at form level for auditing the Total fields of POH table against the details records.
    Declare
         M_LC_AMOUNT NUMBER(13,3);
                  M_FC_AMOUNT NUMBER(13,3);
    Begin
         SELECT SUM(PD_LOCAL_AMT) INTO M_LC_AMOUNT
         FROM POD
         WHERE  PD_PHNO = :PD_PHNO;
         IF  :PH_PD_LOCAL_TOT != M_LC_AMOUNT  THEN
              :PH_PD_LOCAL_TOT := M_LC_AMOUNT;
         END IF;
         SELECT SUM(PD_LOCAL_AMT) INTO M_FC_AMOUNT
         FROM    POD
         WHERE  PD_PHNO = :PD_PHNO;
         IF  :PH_PD_FOREIGN_TOT != M_FC_AMOUNT  THEN
              :PH_PD_FOREIGN_TOT := M_FC_AMOUNT;
         END IF;
    End;i was testing and notice that in a query mode when all records are displayed.
    if i go on changing values on records and save or save later keeping the form open,
    form allows, but if 1 come back to a record which i may have changed and saved earlier, then it flashes Error;
    "Records has been changed by another user, requery to ..."
    i want to do an Audit before final db-Commit and keep the user free from this Error..
    Please tell me first of all, is my approach for both of my issues,correct.?
    if not, then please suggest what should be changed.
    i'll highly appreciate for all your help. TYVM. Regards.

    I did exactly as you suggested. It works well for new record insertion
    but when i press F7 to query it, its flashes messages before displaying detail records
    Field must be entered.
    Mr. Andreas,
    i have problem only when i change value of PH_FXRATE. It re-calculates on screen values for M_PD_LOCAL_AMT
    (Formula M_PD_FOREIGN_AMT/PH_FXRATE)
    i want the changed value of M_PD_LOCAL_AMT to be saved in the actual db-field PD_LOCAL_AMT.
    for this i have PRE-UPDATE on POD Table
    :PD_LOCAL_AMT := :M_PD_LOCAL_AMT
    :PD_FOREIGN_AMT := :M_PD_FOREIGN_AMT
    Which is doing that.It is not marking the detial record as CHANGED.
    I tried giving the above assignments in the PRE-UPDATE on POH table.
    It saves the changed value in the db-field, but not all detail records, if more than 1.
    what you have suggested, will get me acheived what i am looking for..?

  • Difference between empty plsql record and null plsql record

    Hi there,
    I am kinda getting confused with empty plsql record and null plsql record.
    How do I assign plsql record to be empty and to be null?
    create type emp_obj as object (enum number, ename varchar2);
    CREATE OR REPLACE TYPE emp_type AS TABLE OF emp_obj;
    Thanks

    First of all, do not use term PL/SQL record in this context. Record type in PL/SQL is completely different from object type. Secondly, there are 2 states of a nested table:
    1. Unintialized:
    SQL> create or replace
      2    type emp_obj_type as object(enum number, ename varchar2(10));
      3  /
    Type created.
    SQL> create or replace
      2    type emp_tbl_type as table of emp_obj_type
      3  /
    Type created.
    SQL> declare
      2      v_emp_tbl emp_tbl_type;
      3  begin
      4      v_emp_tbl.extend;
      5  end;
      6  /
    declare
    ERROR at line 1:
    ORA-06531: Reference to uninitialized collection
    ORA-06512: at line 4
    SQL> 2 Empty:
    SQL> set serveroutput on
    SQL> declare
      2      v_emp_tbl emp_tbl_type := emp_tbl_type();
      3  begin
      4      dbms_output.put_line('Nested table v_emp_tbl has ' || v_emp_tbl.count || ' element(s).');
      5  end;
      6  /
    Nested table v_emp_tbl has 0 element(s).
    PL/SQL procedure successfully completed.
    SQL> NULL aplies to nested table element, not to nested table itself:
    SQL> declare
      2      v_emp_tbl emp_tbl_type := emp_tbl_type();
      3  begin
      4      v_emp_tbl.extend;
      5      if v_emp_tbl(1) is null
      6        then
      7          dbms_output.put_line('Nested table v_emp_tbl first element is NULL.');
      8      end if;
      9  end;
    10  /
    Nested table v_emp_tbl first element is NULL.
    PL/SQL procedure successfully completed.
    SQL> SY.

  • Using Execute Immediate in PLSQL block Vs Stand alone procedure

    I am facing very unusual ( atleast unusual to me ) with usage of "Execute Immediate" statement.
    I have a table dynamic_sql with one column plsql_block as VARCHAR2(4000);
    I have stored some PLSQL blocks ('DECLARE ..... BEGIN.... END.... ) in this column .
    Now I want to execute these PLSQL blocks one after other depending on certain conditions .
    In order to archive this I wrote a PLSQL block as below
    DECLARE
    Cursor c1 is
    select plsql_block from dynamic_sql
    begin
    for irec in c1
    loop
    <<< Condition >>>
    begin
    execute_immediate(irec.plsql_block);
    exception
    when others then
    raise_application_error(-20001,'error ' ||irec.plsql_block||' '||sqlerrm);
    end loop ;
    end ;
    With above PLSQL block , "execute immediate" is executing PLSQL block successfully without any error
    But When I converted above PLSQL block into standalone procedure as shown below , I am getting error .
    CREATE OR REPLACE procedure test AS
    Cursor c1 is
    select plsql_block from dynamic_sql
    begin
    for irec in c1
    loop
    <<< Condition >>>
    begin
    execute_immediate(irec.plsql_block);
    exception
    when others then
    raise_application_error(-20001,'error ' ||irec.plsql_block||' '||sqlerrm);
    end loop ;
    end ;
    BEGIN
    test;
    end ;
    It is showing the value of irec.plsql_block but not showing sqlerrm...
    I found this is very unusual as I am able to execute "execute immediate" statement with PLSQL block but not with similar procedure .
    can anybody explain me why this is happening?
    Thanks in Advance
    Amit

    Hello,
    It doesn't make any sense to add SQLERRM for user defined exception, unless you want to raise application error for already defined error (e.g NOT_DATA_FOUND, ..)
    Check following piece of code and its output,
    CREATE OR REPLACE PROCEDURE myinsert1
    AS
       v_count   NUMBER;
       v_sql     VARCHAR2 (300);
    BEGIN
       v_sql :=
          'INSERT INTO ENTITY_EMPLOYEE VALUES(0,''TIM'',''LASTNAME'',10000)';
       BEGIN
          EXECUTE IMMEDIATE v_sql;
          COMMIT;
       EXCEPTION
          WHEN OTHERS
          THEN
             DBMS_OUTPUT.PUT_LINE (SUBSTR (SQLERRM, 1, 300));
             RAISE_APPLICATION_ERROR (-20002, 'My Error ' || SQLERRM, TRUE);
             RAISE;
       END;
    END;
    Output._
    ORA-20002: My Error ORA-00001: unique constraint (ENTITY_EMPLOYEE_PK) violated
    ORA-06512: at "MYINSERT1", line 21
    ORA-00001: unique constraint (ENTITY_EMPLOYEE_PK) violated
    ORA-06512: at line 2
    Regrds

  • Master-Detail Relation- Detail records not displaying

    Hi All,
    I am working forms(10g) customization for an oracle applications. our requirement is to develop a new window(screen) which should display all the related child records for the master record in the main form on a button press.
    i have developed a new database block based on a vew and provided the relation with master block, and done the required customization.
    But, when i run the form, and clicked on button, it is giving an error
    FRM-40350 Query caused no records to be retrieved.below is the code that i have written on button click
    BEGIN
              IF event = 'WHEN-BUTTON-PRESSED'
              THEN
              SHOW_VIEW('XXSCP_GBL_CUST_PEGGING_CON');
              SHOW_VIEW('XXSCP_GBL_CUST_PEGGING_STK');
              app_window.set_window_position('XXSCP_GBL_CUST_PEGGING_WIN',
                                             'CASCADE',
                                             'XXSCP_GBL_EXCEP_DETAILS_WIN');
          SET_BLOCK_PROPERTY('XXSCP_GBL_EXP_DETAIL_V',NEXT_NAVIGATION_BLOCK,'XXSCP_GBL_CUST_PEG_V');                                        
          GO_BLOCK('XXSCP_GBL_CUST_PEG_V');
         -- fnd_message.DEBUG('before execute');
          EXECUTE_QUERY;
          :parameter.p_excep_detail := 'FALSE';
              ELSE
                   NULL;
              END IF;
              EXCEPTION
                   WHEN OTHERS
                   THEN
                   fnd_message.DEBUG('other error at button press'||SQLERRM);
              --     NULL;
    END;I am able to query records in my view from database, but not working when i run the form.
    ANy suggestion will be helpful.
    Thanks in advance,
    pavan

    Duplicate post -- Re: Master-Detail Relation- Detail records not displaying

  • Why is my  CLEAR_BLOCK(no_validate) not committing to the database?

    What I need is when the alert button 1 is selected fo to the detail block(ADM) and just delete everything for the current master id. When I click on the button it deletes for a split second and all the data comes back.Quite confused..
    IF Id_Null(al_id) THEN
    Message('Alert does not exist');
    RAISE Form_Trigger_Failure;
    ELSE
    al_button := Show_Alert(al_id);
    IF al_button = ALERT_BUTTON1 THEN
         :global.cl_blk := 'Y';
         go_block('ADM');
         CLEAR_BLOCK(no_validate);
         synchronize;
         go_item('adm.dci_name');
         execute_query;
    else
              :global.cl_blk := 'N';
    GO_ITEM('AM.MAPPING_LEVEL');
    END IF;
    END IF;

    Why is my CLEAR_BLOCK(no_validate) not committing to the database?Better read the Clear_Block on-line help. I think you are mistaking the No_Validate parameter with the Do_Commit parameter.
    The No_Validate parameter "*+Form Builder flushes the current block without validating the changes, committing the changes, or prompting the end user.+*"
    With No_Validate, your changes are discarded, and NOT committed.

  • Trigger changes are not committing to the database

    I have 9iAS and 9i DB both on my laptop.
    I am having a problem in which a trigger run off a WHEN_BUTTON_PRESSED function is not committing the changes to the database. In the trigger I have:
    1 record insert into table A.
    1 record update to table B.
    1 record insert into table C.
    1 delete from table D.
    None of the data is related.
    I have tried various combinations of the below to get the changes to commit:
    POST;
    COMMIT_FORM;
    Exit_Form(NO_COMMIT, NO_ROLLBACK);
    MESSAGE('Got past COMMIT');
    COMMIT;
    CLEAR_FORM(NO_COMMIT);
    ENTER_QUERY;     
    I am getting varying amounts of "FRM: 40508 Oracle Error: Unable to INSERT record" statements. Even so, many times the form would act as if the changes had been properly applied. But when I did a separate DB verification, I would see that the changes are not being committed. Also, most of the time the changes would also be reflected in the calling form queries, but when I exit, all changes are rolled back no matter how many commit stmts are in the trigger.
    I have finally gotten the form to do what I want to do (the 4 steps noted above), but I had to add a FORMS_DDL('COMMIT'); stmt and I am still getting a FRM 40508, but at least the changes are appearing in the db.
    Any ideas on why so many troubles in getting the changes to commit??? I have spent a ton of hours trying "what ifs" to see what might work. Also, this trigger is the only real "code" in the forms.
    Kim

    Brett -
    You're probably right about the intention, but this is a place where people can come and share styles, ideas, and coding tricks, I don't understand why someone would say that. Additionally, I had a professor who was a complete momo that said that all the time (consequently, his lax attitude towards teaching crippled the IS program where I graduated and most likely will cause it to no longer be available). It's a personal peeve of mine, just to let you know where I was coming from.
    Secondly, the problem I'm having may have to do with what you said, however I can't be sure. To give a better description of my scenerio, I created a form that allows the user to load information about an employee by querying a SSN. Most of this information is for display only. Six fields are available to be updated and I wrote a DML UPDATE statement that I placed inside a WHEN-BUTTON-PRESSED trigger. However, these changes won't be written to the DB because Forms is attempting to write my entire datablock, instead of just following the specified DML statements. I'm at a loss as to why this would happen, but for simplicity's sake, I would listen to ideas of how to suppress this from happening so only my statements are used when updating the DB. If you can help, thank you, if not, then thank you for your time.
    Steve

  • Record not updating into table helpme

    in the following functionmodule record is not commiting into table is there any wrong please hep me.
    FUNCTION Z_MZPR_DETAILS.
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(ZPRHEADER) TYPE  BAPIMEREQHEADER OPTIONAL
    *"     VALUE(ZPRHEADERX) TYPE  BAPIMEREQHEADERX OPTIONAL
    *"  EXPORTING
    *"     VALUE(ZNUMBER) TYPE  BAPIMEREQHEADER-PREQ_NO
    *"     VALUE(RETURN) LIKE  BAPIRET2 STRUCTURE  BAPIRET2
    *"  TABLES
    *"      ZPRITEM STRUCTURE  BAPIMEREQITEMIMP
    *"      ZPRITEMX STRUCTURE  BAPIMEREQITEMX OPTIONAL
    *"      ZPRACCOUNT STRUCTURE  BAPIMEREQACCOUNT OPTIONAL
    *"      ZPRACCOUNTX STRUCTURE  BAPIMEREQACCOUNTX OPTIONAL
    DATA:ITAB LIKE TABLE OF ZPRDETAILS WITH HEADER LINE,
         ZRETURN LIKE TABLE OF RETURN WITH HEADER LINE.
    CALL FUNCTION 'BAPI_PR_CREATE'
    EXPORTING
       PRHEADER                    = ZPRHEADER
       PRHEADERX                   = ZPRHEADERX
      TESTRUN                     =
    IMPORTING
       NUMBER                      = ZNUMBER
      PRHEADEREXP                 =
      TABLES
       RETURN                      = ZRETURN
       PRITEM                      = ZPRITEM
       PRITEMX                     = ZPRITEMX
      PRITEMEXP                   =
      PRITEMSOURCE                =
       PRACCOUNT                   = ZPRACCOUNT
      PRACCOUNTPROITSEGMENT       =
       PRACCOUNTX                  = ZPRACCOUNTX.
      PRADDRDELIVERY              =
      PRITEMTEXT                  =
      PRHEADERTEXT                =
      EXTENSIONIN                 =
      EXTENSIONOUT                =
      PRVERSION                   =
      PRVERSIONX                  =
      ALLVERSIONS                 =
    ITAB-BANFN = ZNUMBER.
    APPEND ITAB.
    IF ZRETURN-NUMBER = '000'.
    UPDATE ZPRDETAILS from TABLE ITAB.
    COMMIT WORK.
    ENDFUNCTION.

    HI,
    IF ZRETURN-NUMBER = '000'.
    <b>MODIFY ZPRDETAILS from TABLE ITAB.</b>
    COMMIT WORK.
    <b>ENDIF.</b>
    Best regards,
    Prashant

  • Calling plsql block in java

    Hi
    Needs some help, urgently.
    i have to call/execute a plsql block in java program.
    block is similar to this
    declare
    CURSOR l_csr IS
    select empname, empid, empdate from emp
    order by empid;
    l_empid NUMBER;
    l_empdate DATE;
    l_empname varchar2(30);
    o_dateProfileId NUMBER;
    o_dayofweekprofileid NUMBER;
    begin
    open l_csr;
    loop
    FETCH l_csr INTO l_empid , l_empname , l_empdate;
    EXIT WHEN l_csr%NOTFOUND;
    DETERMINEEMPPROFILE(l_empdate,o_dateProfileId,o_dayofweekprofileid,l_empid ,FALSE);
    IF(o_dateProfileId IS NOT NULL) THEN
    SELECT totaljobs INTO l_max1 FROM dateprofile WHERE dateprofileid = o_dateprofileid;               
    ELSE
    SELECT totaljobs INTO l_max1 FROM dayofweekprofile WHERE dayofweekprofileid = o_dayofweekprofileid;
    END IF;
    END LOOP;
    EXCEPTION
    WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('SQLCODE = ' || SQLCODE);
    END;
    i need to call this in java program and take the results of l_max1.
    can someone provide an example of hot to do this or sample code
    appreciate any help

    I'm assuming this is for Oracle. Take a look at this article [url=http://www.enterprisedt.com/publications/oracle/result_set.html
    ]here for an example of how to use java to parse a result set from an Oracle procedure.

  • Unable to insert row in object table from plsql block

    I have table called test based on an object type. When I issue an insert statement from sqlplus, the row is inserted. The exact same sql statement in a plsql block gives the error below. Any ideas? (it is not a constraint problem).
    SQL> insert into test values( 3,2,1,1,'asp',1,'mach' );
    1 row created.
    SQL> begin
    2 insert into test values( 3,2,1,1,'asp',1,'mach' );
    3 end;
    4 /
    insert into test values( 3,2,1,1,'asp',1,'mach' );
    ERROR at line 2:
    ORA-06550: line 2, column 16:
    PL/SQL: ORA-06552: PL/SQL: Compilation unit analysis terminated
    ORA-06553: PLS-302: component 'DOCUMENT' must be declared
    ORA-06550: line 2, column 4:
    PL/SQL: SQL Statement ignored
    (ddl)
    CREATE OR REPLACE type document as object
    DOC_ID NUMBER (38),
    BATCH_ID NUMBER (38),
    STATE NUMBER (2),
    TRANSIENT NUMBER (2),
    ASP VARCHAR2 (20),
    USER_ID NUMBER (6),
    MACHINE VARCHAR2 (30),
    MEMBER PROCEDURE setState,
    MEMBER function getState RETURN NUMBER
    ) not final;
    create table test of document;

    Hi Adam
    You need to instantiate your object type in your insert statement(while doing through PL/SQL block), so try like this
    Insert into test values(document(1,2,'CO',55,'xyz','kkk','PENTIUM'));
    The reason you were successful through SQLPLUS was that, SQLPLUS automatically instantiate the values into object type.
    Qurashi

  • Updated content for multi-level record structure in PLSQL

    Hi All,
    please help me
    Need a FUNCTION which would take PERSON_id as the INPUT PARAMETER and RETURN the FULL DETAILS in a multi-level record structure in PLSQL.
    CREATE TABLE people(
    name VARCHAR2(5),
    person_id number
    INSERT INTO people(name,person_id) VALUES ('n1',1);
    INSERT INTO people(name,person_id) VALUES ('n2',2);
    INSERT INTO people(name,person_id) VALUES ('n3',3);
    INSERT INTO people(name,person_id) VALUES ('n4',4);
    INSERT INTO people(name,person_id) VALUES ('n5',5);
    INSERT INTO people(name,person_id) VALUES ('n6',6);
    A person can be assigned many tasks. Below,we can see person_id =1 has 2 tasks 10,20
    CREATE TABLE tasks(
    task_id number,              --->PK
    task_name VARCHAR2(5),
    person_id number          -->FK to People
    INSERT INTO tasks(task_id,task_name,person_id) VALUES (10, 'cleaning',1);
    INSERT INTO tasks(task_id,task_name,person_id) VALUES (20', 'washing',1);
    INSERT INTO tasks(task_id,task_name,person_id) VALUES (30, 'sweeping',2);
    INSERT INTO tasks(task_id,task_name,person_id) VALUES (40, 'ironing',3);
    Each TASK has many ACTIVTIES as below. Below,we can see task_id =10 ---->3 ACTIVITIES of activity_id of 100,200,300
    CREATE TABLE activities(
    activity_id number,
    activity_name VARCHAR2(50),
    task_id number,              --->FK  to task table
    INSERT INTO activities(activity_id,activity_name,task_id)VALUES (100, 'Clean home',10);
    INSERT INTO activities(activity_id,activity_name,task_id)VALUES (200, 'Clean Garden',10);
    INSERT INTO activities(activity_id,activity_name,task_id)VALUES (300, 'Clean clothes,10');
    INSERT INTO activities(activity_id,activity_name,task_id)VALUES (400, 'Wash car',20);
    Write a FUNCTION which would take PERSON_id as the INPUT PARAMETER and RETURN the FULL DETAILS in a multi-level record structure in PLSQL.
    Meaning We would get
    First ,person_details for a person-->next level is TASKS-->Activities_list in a NESTED RECORD SET
    create or replace function person_details(person_id NUMBER)
    RETURNs a
    PERSON_DETAILS RECORD structure as shown below.A person -->Tasks--> all activities
    record PERSON_DETAILS[1]
         person_id,
         name
         TASKS_DETAILS[1]          ---->2nd level
                     task_id[1],
               task_name[1]
                   ACTIVITIES[1]----->3rd level
                        activity_id[1],
                        activity_name[1]     
                      ACTIVITIES[2]
                        activity_id[2],
                        activity_name[2]                    
                   ACTIVITIES[3]
                        activity_id[3],
                        activity_name[3]
    *(1)--Most important part is how do i DEFINE AND DECLARE the RESULT RECORD SET in my FUNCTION?
      (2)--HOW DO WE DYNAMICALLY ALOCATE MEMORY for the record structure based on the no. of rows by each SELECT?
       (3)Access the nested levels and FILL in the DATA in the above record seperately USING SELECT statements.
    */*SELECT 1 ---Find and fill Person*/*
    *select person_id,name from people where person_id =1*
    *-->From this SELECT fill the OUTER record PERSON_DETAILS[no. of records] -->person_id,name*
    */**SELECT 2 ---I want to FIND all TASKS for THE ABOVE PERSON and fill the next part */*
    *select task_id,name from tasks where person_id = PERSON_DETAILS[1].person_id*
    *We get three TASK_ids,*
    *-->From this, HOW TO fill DATA for each TASK,how to  PERSON_DETAILS[1]->TASKS_DETAILS[1st record].task_id -->person_id,name*
    */**SELECT 3 ---I want to FIND all ACTIVITIES for THE ABOVE TASKS and fill the next part */*
    *for EACH of the TASKS found,we need to LOOP and*
    *select activity_id,name from activities where task_id = PERSON_DETAILS[1].-->TASKS_DETAILS[1st record]--->ACTIVITY_DETAILS[1].activity_id*
    I have tried my best to explain with the tables and the relationships.I just hope its not confusing now.Edited by: user_7000011 on 01-Apr-2009 12:46

    try this one.
    Learned something new today.
    CREATE TABLE temp_clob_tab(result CLOB);
    CREATE or replace TYPE task_t AS OBJECT("@task_id"   NUMBER,
                                last_name        VARCHAR2(20),
                                 activitylist     activity_tab
    create or replace type activity_t as object("@activity_id" number, activity_name varchar2(20));
    CREATE or replace  TYPE tasklist_t AS TABLE OF task_t;
    create or replace type activity_tab as table of activity_t;
    CREATE or replace TYPE people_t AS OBJECT("@people_id" NUMBER,
                                 task_name  VARCHAR2(20),
                                 task_t          tasklist_t
    DECLARE
      qryCtx DBMS_XMLGEN.ctxHandle;
      result CLOB;
    BEGIN
      DBMS_XMLGEN.setRowTag(qryCtx, NULL);
      qryCtx := DBMS_XMLGEN.newContext
        ('SELECT people_t(person_id,
                        name,
                        CAST(MULTISET
                               (SELECT e.task_id, e.task_name,cast(multiset
                                        (select activity_id,activity_name from activities a
                                            where a.task_id = e.task_id) as activity_tab)
                                  FROM tasks e
                                  WHERE e.person_id= d.person_id)
                             AS tasklist_t))
            AS peoplexml
            FROM people d
            where person_id = 1');
      -- now get the result
      result := DBMS_XMLGEN.getXML(qryCtx);
      INSERT INTO temp_clob_tab VALUES (result);
      -- close context
      DBMS_XMLGEN.closeContext(qryCtx);
    END;
    select * from          temp_clob_tab ;output
    <?xml version="1.0"?>
    <ROWSET>
    <ROW>
      <PEOPLEXML people_id="1">
       <TASK_NAME>n1</TASK_NAME>
       <TASK_T>
        <TASK_T task_id="10">
         <LAST_NAME>cleaning</LAST_NAME>
         <ACTIVITYLIST>
          <ACTIVITY_T activity_id="100">
           <ACTIVITY_NAME>Clean home</ACTIVITY_NAME>
          </ACTIVITY_T>
          <ACTIVITY_T activity_id="200">
           <ACTIVITY_NAME>Clean Garden</ACTIVITY_NAME>
          </ACTIVITY_T>
          <ACTIVITY_T activity_id="300">
           <ACTIVITY_NAME>Clean clothes</ACTIVITY_NAME>
          </ACTIVITY_T>
         </ACTIVITYLIST>
        </TASK_T>
        <TASK_T task_id="20">
         <LAST_NAME>washing</LAST_NAME>
         <ACTIVITYLIST>
          <ACTIVITY_T activity_id="400">
           <ACTIVITY_NAME>Wash car</ACTIVITY_NAME>
          </ACTIVITY_T>
         </ACTIVITYLIST>
        </TASK_T>
       </TASK_T>
      </PEOPLEXML>
    </ROW>
    </ROWSET>

Maybe you are looking for

  • How do I find the apps tab in iTunes on my ipad2?

    I Need to find the apps tab in iTunes on my iPad to setup file sharing to a book reading aloud app on my iPad. I can't see this tab?

  • Transferring data from iphone 3G to 3GS + something that makes this complex

    My father passed away this past week, and gave me his new iPhone 3GS to replace my current 3G model. Once I have AT&T switch me over to the 3GS phone, then I know I need to perform a restore back-up to transfer all of my data over. Hopefully that wil

  • Error while executing dbms_resource_manager_privs

    Hi, The user SCE has been granted execute on DBMS_RESOURCE_MANAGER and DBMS_RESOURCE_MANGER_PRIVS. However, I get the following error while using it. SQL> SELECT USER FROM DUAL; USER SCE SQL> select GRANTEE,PRIVILEGE,TABLE_NAME from dba_tab_privs whe

  • Trouble with connecting to iMessage

    My iMessage isn't working. I go to sign in under settings and it says it's not connected and please check me network connection. What do i do?

  • Web Dynpro for ABAP and Floor Plan Manager

    Hi. How can I integrate an ABAP Web Dynpro application in the Java Web Dynpro based Floor Plan Manager (FPM) framework? I'm thinking of the "General Information" page in the MSS Business Package (com.sap.pct.erp.mss.general_information), where the ma