Reading old values in a forms pl/sql block

In a pl/sql block, in a form.
Lets say I want to loop through...
cursor c1 is
select description
from students
where student_id = 1000;
loop
open c1;
fetch c1 into v_description
--step1
update students
set description = new description
where student_id = 1000
--step2
select description into v_old_description where student_id = 1000;
end loop;
In step2 when I am reading the record I am getting the new description which is expected.
My question is how can I get the old description. i-s the value of description which was before step1.
Thanks

No, you perform an update, so the old value is overwritten in the database.
If you really want to use sql, and I don't see why in your example, you can try [flashback query|http://www.oracle.com/technology/deploy/availability/htdocs/Flashback_Overview.htm] .

Similar Messages

  • Form Values in "On Successful Submission of Form" PL/SQL Block

    I am having trouble capturing the form values in the "On Successful Submission" PL/SQL block.
    p_session is not directly recognized by this block as a global variable.
    I created a local p_session variable. It passes NULL values.
    I am using Portal 3.0.7.
    Thanks,
    James

    James,
    To answer your questions:
    DOMAIN and SUBDOMAIN can be any names of your choosing, but they must be consistent between the put and the get. They are not implicit.
    Here is what I chose to do...
    ON THE INSERT BUTTON:
    declare
    session portal30.wwsto_api_session;
    begin
    session :=
    portal30.wwsto_api_session.load_session('LLNL','LCAMS');
    session.set_attribute('buttonType','Insert');
    session.save_session;
    end;
    doInsert;--- This is the default handler
    So, in my case, the Domain is LLNL and the Subdomain is LCAMS.
    IN THE "ON SUCCESSFUL SUBMISSION OF FORM...":
    declare
    v_user_key_id lcams_db.user_token_link.user_key_id%TYPE;
    v_tkn_ser_no lcams_db.user_token_link.tkn_ser_no%TYPE;
    v_actv_ind lcams_db.user_token_link.utl_actv_ind%TYPE;
    v_event VARCHAR2(10);
    blk varchar2(10):='DEFAULT';
    my_url VARCHAR2(200);
    return_url VARCHAR2(200);
    session portal30.wwsto_api_session;
    begin
    v_user_key_id:=p_session.get_value_as_number(
    p_block_name=>blk, p_attribute_name=>'A_USER_KEY_ID');
    v_tkn_ser_no:=p_session.get_value_as_varchar2(
    p_block_name=>blk, p_attribute_name=>'A_TKN_SER_NO');
    v_actv_ind:=p_session.get_value_as_varchar2(
    p_block_name=>blk, p_attribute_name=>'A_UTL_ACTV_IND');
    session :=
    portal30.wwsto_api_session.load_session('LLNL','LCAMS');
    v_event := session.get_attribute_as_varchar2('buttonType');
    my_url := 'lcams_db.otp.otp_utl' | |
    '?p_event=' | | v_event | |
    '&p_user_key_id=' | | TO_CHAR(v_user_key_id) | |
    '&p_tkn_ser_no=' | | v_tkn_ser_no | |
    '&p_actv_ind=' | | v_actv_ind;
    call(my_url,return_url);
    end;
    The 'A_...' references are actual fields on the form, which are based on columns in my table.
    I use the get_value_as_... calls to get the values the end user entered and I pass them to a procedure in a package that I had previously defined.
    lcams_db is the schema, otp is the package and otp_utl is the procedure. The p_... names are the actual names of the parameters in the procedure.
    Let me know if you need additional clarification.
    Rene'

  • Hide new/old value of bind variable in SQL*Plus

    Hi,
    I have a SQL*Plus script to create a new user. It asks for username & password and then passes these values to a SP to do some checks and finally create the user.
    The output is currently the following :
    New user will be created in ORCL LAB
    Enter the requested username : fleet2
    Enter the password for fleet2 : *****
    Re-enter the password for fleet2 : *****
    old 2: labadmin_cr_user('&username', '&pswd', '&pswd2');
    new 2: labadmin_cr_user('fleet2', 'fleet', 'fleet');
    The requested username is already in use in the database. Please choose another username.
    As you can see the passwords are now exposed when the procedure is called. This is not what I want off course. I cannot do termout off as the serveroutput is not shown as well in that case. I use dbms_output to show error messages to users. (see example above in case of an existing user).
    Can anybody tell me how to hide these 2 lines (old 2, new 2) without hiding my dbms_output.
    Thanks!
    Kris

    set verify offhttp://download-uk.oracle.com/docs/cd/B10501_01/server.920/a90842/ch13.htm#1013382

  • Reading a value from PL/SQL region

    Hello,
    I hope to receive help from you!
    I have a PL/SQL dynamic region in which I create several items using htmldb_item.text function.
    e.g.
    htp.p(htmldb_item.text(1,'AAA',40,2000));
    Then I want to read the values of these items from another PL/SQL region. If I write
    htp.p(htmldb_application.g_f01(1));
    I get an error.
    If I try to read the value of an item from an After Submit Process, everything is OK.
    Is it possible to receive a value of an item in a PL/SQL region?
    Thanks,
    Nadja

    The other PL/SQL region should read the information from the source (table or view). If I understand your right, you are trying to "read" the information from your first PL/SQL block on load?
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • How to check old value in form personalization.

    Hi All,
    Could anybody please tell me how to check the old value in oracle forms using form personalization if someone is updating to someother value.
    For example.
    My Vendor Site Alternate name is XYZ
    and someone has changed it to ABC, How could i check the old values before or after doing updates.
    I don't want to write trigger for this.
    Thanks & Regards,
    Vishwas

    Pl see if the solution in this thread can help - Re: Capture who changed data using Forms Personalization & changed to what
    If not, pl see old threads that discuss forms personalization
    http://forums.oracle.com/forums/search.jspa?threadID=&q=forms+AND+personalization&objID=c3&dateRange=last90days&userID=&numResults=15
    HTH
    Srini

  • Some "formula" interpreter or returning value from unnamed PL/Sql blocks

    Hello,
    My company is developing Payroll and HR software and we use Oracle 10G Database. For a new module we are looking for a system were the end user (power user) can put in some kind of "formula's" to define what info/figures he wants for certain calculations done by de module (the budget module calculations will be done in PL/SQL stored proc written by us).
    Example: item "MonthlySalaryCost" = (BaseYearSal + TotalBonus)/12
    Where BaseYearSal and TotalBonus are functions that exist our will exist in or database. The idea is that a PL/SQL proc (which will be the same for all our customers), at runtime will execute that "formula" and use the result in its further calculations. The "formulas" will be stored in a table. (I foresee of course a "formula" validation to prevent dangerous sql-injection).
    My idea was to use Execute Immediate in the proc to execute the formula's and work with the results. In this approach we have to write (and foresee) all possible functions to access the data the user wants to use.
    Another (more powerful) solution I think about, is seeing these "formula's" as unnamed PL/SQL blocks (stored in a table), were the end user (or consultant) can use the full power of PL/SQL (if then else, select into ..., etc..) to obtain the result he wants to return into the item.
    My problem here is : how to return a value from a unnamed PL/SQL block that is executed via Execute Immediate in a stored proc ?
    And a general question: what do you think of this approach ? are there others possibilities to do this ?
    Thanks in advance,
    Philippe.

    Hi,
    Welcome to the forum!
    This is a simple example:
    Some functions to test:
    CREATE OR REPLACE FUNCTION f_test1 RETURN NUMBER IS
       RESULT NUMBER;
    BEGIN
       RESULT := 12;
       RETURN(RESULT);
    END f_test1;
    CREATE OR REPLACE FUNCTION f_test2 RETURN NUMBER IS
       RESULT NUMBER;
    BEGIN
       RESULT := 10;
       RETURN(RESULT);
    END f_test2;
    CREATE OR REPLACE PACKAGE pack_test_functions IS
       PROCEDURE proc_test;
    END pack_test_functions;
    CREATE OR REPLACE PACKAGE BODY pack_test_functions IS
       PROCEDURE proc_test IS
          v_sql    VARCHAR2(4000);
          v_result NUMBER;
       BEGIN
          v_sql := 'SELECT F_TEST1() + F_TEST2() FROM DUAL';
          EXECUTE IMMEDIATE v_sql
             INTO v_result;
          dbms_output.put_line(v_result);
       END proc_test;
    END pack_test_functions;
    /into v_result you have the result of the operation.
    Regards,

  • Oracle pl/sql  block in java

    Hi,
    Everybody I just want to know how we execute the pl/sql (oracle9i)block(not store Procedure)
    in java that have explicit cursor and how we print or display the value in cursor..
    pl/sql block declare
    v_id number;
    cursor cv1 IS
    select request_id from requests where sys_id = 3
    begin\n
    open cv1;
    loop
    fetch cv1 into v_id;
    exit when cv1%notfound;
    dbms_output.put_line(v_id);
    end loop; \n"
    end;;
    i try it like simple sql query
    Connection conn = null;
    Statement stmt = null;
    ResultSet rs = null;
    conn = DriverManager.getConnection(url, name, pass);
    stmt = conn.createStatement();
    rs = stmt.executeQuery(pl/sql block);
    I want display the value store in cursor............in java....
    kindly help me........
    regard's
    paritosh tomar

    Paritosh,
    You can execute anonymous PL/SQL blocks in JDBC.
    I suggest searching this forum's archives for the word "anonymous".
    If I remember correctly, there should be a relevant post from David Rolfe from a few years ago.
    Good Luck,
    Avi.

  • Get back old values into Form Building Application

    I have a database trigger that raised an error message when a record is no allowed to change/update. I would like to know how I go back to the old values and reflect these into my application.
    I use Oracle Forms Building Version 9.0.2.10.1 (Production) under Window XP system. Below is the database trigger code:
    CREATE OR REPLACE TRIGGER "DBDSCHM".AAPT_REVIEWS_BUR
    BEFORE UPDATE ON AAPT_REVIEWS
    REFERENCING OLD AS OLD NEW AS NEW
    FOR EACH ROW
    DECLARE
    Aaap_approved          EXCEPTION;
    BEGIN
    IF (Aapfn_List_Items_Desc(:OLD.AREV_STATUS) = 'APPROVED' AND
    :OLD.AREV_CREATED_BY = 'AAPTRF' AND
                   :OLD.AREV_MODIFIED_BY = 'AAPTRF') THEN
    RAISE Aaap_approved;
    END IF;
    EXCEPTION
    WHEN Aaap_approved     THEN                                                            RAISE_APPLICATION_ERROR(40509,'This Review cannot be modified. '||
         'AAP Approved prior to Conversion');
    END aapt_review_bur;
    SHOW ERROR

    Thanks John, but the proposed of this trigger is to prevent any user to update the records that were loader prior to the Data Loader. That is the reason that this trigger has a condition to compare the old value with the new value. Please, see the syntaxes below:
    CREATE OR REPLACE TRIGGER "DBDSCHM".AAPT_REVIEWS_BUR
    BEFORE UPDATE ON AAPT_REVIEWS
    REFERENCING OLD AS OLD NEW AS NEW
    FOR EACH ROW
    /* This trigger prevents to modify any AAP review */
    /* that was already approved PRIOR TO THE Conversion.*/
    BEGIN
    IF (Aapfn_List_Items_Desc(:OLD.AREV_STATUS) = 'APPROVED' AND
    (:OLD.AREV_CREATED_BY = 'AAPTRF') AND (:OLD.AREV_MODIFIED_BY = 'AAPTRF')) THEN
    RAISE_APPLICATION_ERROR(-20090,'This Review cannot be modified. AAP Approved prior to Conversion');
    END IF;
    END aapt_review_bur;
    What I really want is that when the above trigger fire and the user receive the raise application message meaning that the user could not updated the record. But the wrong value still show on the form and it will keep getting this error until you put back the previous value. What I really want is to be able to raise the application error and to show back any values that were tried to modify.

  • Passing multiple character values from parameter form to PL/SQL

    Hi,
    I am passing multiple character values from parametr form into
    the report query and a PL/SQL procedure. It works fine with the
    query, when I use &variable. But, it doesn't compile in PL/SQL,
    so I just used the :variable, but not getting any records in the
    PL/SQL procedure. Any suggestions?
    sincerely,
    gj

    gj / Fedro,
    Only using the &referecne, you can pas a string / multiple character values and this would work for query only.
    The bind parameter in PL/SQL wouls support only single value
    Thanks
    The Oracle Reports Team

  • Using dynamic sql in triggers with :OLD values

    i need to record all deleted rows from an entire schema in a single table. for that matter i created a function that receives a table name and generate an insert command according to it's primary key columns. i call this function in the table triggers. in order to insert the old values before the delete i use :OLD with "execute immediate" as followed :
    create or replace trigger trg_some_tbl_bd
    before delete on some_tbl
    for each row is
    declare
    v_sql varchar2(4000);
    begin
    v_sql := generate_insert_command('some_table');
    execute immediate v_sql;
    end;
    the return value from "generate_insert_command" function is the string:
    insert into deleted_table (table_name , date , pk1 , pk2) values
    ('some_table' , sysdate , :OLD.pk1 , :OLD.pk2)
    the execute immediate command notice the :OLD and looks for bind variables.
    i need to know i can i bypass that. i tried looking for escape characters but couldent find any...
    i would appriciate any help , it's kynda urgent
    Thanks !

    I don't believe this is going to work. Even if you could get around the fact that :old looks like a bind variable, the :old values are not visible to the dynamic SQL statement, they're like local variables in that respect.
    If you wanted to pass old values in, those values would have to be passed in as bind variables, i.e.
    EXECUTE IMMEDIATE v_sql USING :old.pk1, :old.pk2which defeats the purpose of using dynamic SQL.
    Since you have to create a trigger for each table, I don't see why you would bother with dynamic SQL inside the trigger-- your table structure is fixed when the trigger is created. You could write dynamic SQL that generated the triggers in the first place, but the code inside the trigger should be dynamic.
    As an aside, you realize that logging every audit record into a single table creates rather massive contention issues, right? And have you considered how painful it is to query this sort of table? Have you considered other options for maintaining history like Workspace Manager? Or at least separate history tables for each table?
    Justin

  • Passing values from a form to a page containing forms.

    I would like to pass a value from a form to a page containing two forms (one of the forms is in a tab).Once the value is passed, I want the two forms to be executed with the value passed. Can this be done and how? Any help would be appreciated. Thanks.

    Yes, this is possible.
    I will give you a brief outline.
    From the 1st form, you need to save the value, you want to pass to the 2 other forms, using the wwsto_api_session apis.
    Then, using go() or call() from the Successful submission section, you need to go/call the page containing the 2 forms.
    You need to write some pl/sql code in the 2 forms (on the page) to retrieve the value saved and perform the action you desire. The saved value can be retrieved using the wwsto_api_session apis.
    However, both forms will not get executed at the same time unless both of them are in the same tab i.e. unless both forms are visible at the same time.
    If the forms are on different tabs, they will get executed when they are being displayed.
    But, there are ways to execute both the forms, if it really necessary, even if they are not on the same tab.
    I will be posting the an example soon in this thread.

  • Using select list as default value in tabular form.

    Hi,
    I am using Application Express 4.1.0.00.32. I have two questions that are related.
    I have a Select item *'P1_SELECT'* and a tabular form My Items.
    Question 1. The My Items tabular form col1 Attributes are set Display As Text Field, and the Tabular Form Attributes are set Default Type = item(application or page item name), Default = P1_SELECT. I have checked the session state value is set on P1_SELECT ie. Fred. What I need to know is, why, when adding a row to the tabular form My Items does col1 not display 'Fred' as the default value from the select item P1_SELECT? I can change col1 of the Tabular form to be Display as Text (save state) and this will work. However that leads me on to:
    Question 2. After adding say 3 rows to the form, I then change the select P1_SELECT value to Bob and Bob is now set in session state on the P1_SELECT item, but when I again add row to the form the value Fred is still the value not Bob. It seems that the tabular form keeps the default value as Fred and not Bob. How can I get this to look or work like:
    col1_
    Fred
    Fred
    Fred
    Bob
    Your help is needed.
    Thanks.

    Howard (DBA in Training) wrote:
    Do you submit the page or set the value after changing the selection? If not, the display value seems to be Bob but the working value is still Fred. That's what you are seeing right? In the "Settings" section, what do you have for "Page Action when Value Changed". I've been using "Redirect and Set Value" because I was staying on the same page after the selection.
    Additional info which might be helpful (or NOT). ====================
    NOTE: I am just a novice's novice with APEX and I had much agony with Select Lists. It was challenging to have the Select List value displayed because there seem to be so many different sources of the Select List value, namely:
    1) the current value in the session state
    2) the value you can specify in "Source value or expression" in the "Source" section of the Select List item
    3) the value you can specify in the "Post Calculation Compution" in the "Source" section of the Select List item
    4) the value you can specify in the "Default value" of the "Default" section of the Select List item
    [Now, if I've misdescribed any of these, remember, this is from a novice's perspective.]
    It's like putting a clock (back) together. Get any of the pieces wrong and it will probably not work right.
    I had an addiitonal challenge in that I wanted the same Select List displayed on multiple pages and for the currently selected value (from the former page) to already be set on the new page when it was displayed. What fun!
    To see what I did here: http://apex.oracle.com/pls/apex/f?p=43250:101 login Dever/Ima9Dever
    Remember, I'm doing many things you will likely not need to do. I iniitalized the Select List for the first time it displayed. I copied the Select List value from old page to new page by storing it in an application item F217_SYS_NIC_NM.
    Best wishes,
    HowardHi Howard,
    You don't have submit the page for just setting one item's session state. you can use a Dynamic Action OR use Page Items to Submit property if available (this is available in various places such as sql region,chart region etc)
    In context to this question you don't have to do any of those..just see my example above
    Thanks

  • NLS_LANG value that suits Forms 10G and Database 11G wanted !

    I can't believe how bad is to install Oracle Database and Oracle Forms on the same Windows Vista machine!
    I had a problem in Oracle Forms 10g that prevents many items in the Form Builder menu from appearing in English Language and also prevents anything in the web-based forms runtime from appearing in English. I searched the forum for a solution and found that I have to set a NLS_LANG value in the environment variables equal to the following: AMERICAN_AMERICA.WE8MSWIN1256.
    I did this and my Forms builder looked great. Everything in english with no problems. But now what ?! The Oracle Database itself refused to connect from all clients! It refused to connect from Forms Builder, SQL Deeveloper, and even from SQL PLUS! The error given is: ORA-12705: Cannot access NLS data files or invalid environment specified.
    It seems that what I exactly need is a NLS_LANG value that will satisfy both Oracle Forms 10G and Oracle Database 11G that both are installed on the same Vista machine. The question is: What could this NLS_LANG value be?!
    Thank you in advance

    If you have connected to the database on which the form is based, prior to running the form from the Builder, the uname and password will automatically be passed in at startup and you will not be prompted.
    If you would rather hard code a username and password, enter it in formsweb.cfg. For example:
    SYNTAX:
    userid=<USERNAME>/<PASSWORD>@<DB NAME>
    EXAMPLE:
    userid=scott/tiger@orcl
    Remember that this change will only impact runtime and have no effect on the Builder.

  • Resolved: Use value from select list in pl/sql block

    Hello,
    I have a form with a select list: P18_BONUSTYPE, the values of which come from a LOV.
    When the user clicks a button, a page process is used to insert a row into a table.
    When I use the :P18_BONUSTYPE bind variable in my insert statement I get an error "Invalid number" I get an "Invalid number" error. I assume that APEX is using the displayed text in that bind variable, not its actual (html option) value.
    I checked the HTML of the page, and the correct values are in the select list.
    Can someone tell me how to get the value into a bind variable that can be used in a pl/sql block for a page process?
    Thanks
    Message was edited by:
    Neeko
    Issue was a value in another item.

    Did you tried changing the value using "to_number"? (i.e. to_number(:P18_BONUSTYPE)).
    Max.

  • How to change the dynamically  LOV value to old value if it errors out

    We have an use case like when a value is selected from LOV, some validations(EO validations) occur on that and if the validation fails we are throwing exception.But the new value is appearing in LOV text box. We need to display the old value in the LOV if the validation fails. Can you please let me know if there is any way to do that?

    After thinking about this, I wondered if I had mis-read the use-case....so I added #2
    Please state your Jdeveloper version, and elaborate on your use-case:
    *1. Are you saying that the LOV contains incorrect values that the user has chosen?*
    If so you should restrict the LOV values to what is acceptable for the row (based on what other values are in the row)
    By restricting the values in the LOV the wrong value can no longer be selected, you would not need to build in functionality to revert back to previous values.
    I woud start by creating a view criteria for the view object the LOV is based on. The form values would send the binding variables to the view criteria, and that would then execute the query (invoking the view criteriea). The LOV would then contain some information on only acceptable values.
    You may be able to adapt some of the ideas presented in this video (on cascading list boxes) to make your LOV work properly. http://youtu.be/WTevRnXq04o
    This video shows some ways to manipulate view criteria: http://youtu.be/dX93fiBCxEg
    *2. Are you saying that the user has selected other fields in the form -- validation on those fields fails, and you want to revert back, but the LOV still contains the values selected?*
    In that case, you need to clear the values in the form and re-execute the view object -- and refreshing to the correct value.
    Stuart
    Edited by: Stuart Fleming on Sep 12, 2012 12:04 PM
    Edited by: Stuart Fleming on Sep 12, 2012 6:52 PM
    Edited by: Stuart Fleming on Sep 12, 2012 6:52 PM

Maybe you are looking for

  • Keyboard not disabling past 180 Degrees (Yoga 13)

    The keyboard on my Yoga 13 is (apparently ouf of the blue) not disabling when I open the Yoga passed 180 degrees.  It doesn't shut off until the Yoga is nearly fully folded back on itself (tablet mode).  This is a big problem for me as I love using t

  • Replaced Hard Drive and Trying to Bring in Purchased Items from iPod

    The MacGenius I talked to yesterday said that I could do this, and made it sound like it would be automatic, but I have found (with the replacement of my hard drive) that sometimes these guys forget to mention a step. Right now, when I sync my iPod,

  • Pdf to Word conversion problems

    I just tried to convert a pdf (in Italian) to Word.  What came out was a page of senseless symbols.  I tried converting to doc, docx, and rtf, and nothing worked.  What to do?

  • How do you install the JMicron drivers for IDE compatibility on a p965 Platinum?

    I can plainly see I've got the same issue as many others with regard to using my IDE devices on the p965 board. In short, I can't. I have to install the JMicron drivers. I know this has been covered elsewhere, but frankly I can't find it and I want i

  • Iphoto Versions for 10.6.8

    I have an Imac desktop late 2006 running Snow Leopard 10.6.8, which it seems is not suitable for upgrading to Lion. What is the latest version Iphoto that will run on my Imac and where can I get it please?  (It currently has Version 6.0.6) I can only