Using item values in a pl/sql block or sql query in a process

Hi,
I am new to apex. Developing my first application.
I have created a form with 2 items. Based on the values in these items, when I click a button, want to execute a
query.
eg: emp_name(item1), deptno(item2). When I clock on find button, I want to fetch the record and disply the resultant
columns in other created items like sal,comm etc.
How can I do this?
I tried the following pl/sql block in a process
begin
select sal,comm into p1_sal,p1_comm from emp where name=p1_name and deptno=deptno;
end;
But it is not accepting the page items in the block.
How to achieve this?
Thanks,
Kavitha

We have many OBEs, tutorials, etc. Please visit the <a hef="http://www.oracle.com/technetwork/developer-tools/apex/learnmore/index.html" target="_window">Learn More</a> tab of our otn site.
This is the section of the User's Guide that discusses session state -
-- Sharon

Similar Messages

  • Using item values in the query

    Hi,
    Is there a way I can use item values in the query...?
    as an example, something like this
    select a.*, :P20_CUST_NAME as CUSTOMER_NAME
    from
    table TEMP a;
    haven't tried it yet but want to get the feedback first before making an attempt...
    Thanks

    Yes, as long as that item has a value in session state..
    Thank you,
    Tony Miller
    Webster, TX

  • Pl/sql block returning sql query.

    Hello,
    I am using oracle 10g apex 3.2 version.
    I am using the following return statement inside my report which is pl/sql block returning sql query.
    declare
    pid varchar2(100);
    begin
    return 'select patient_id_code from t_files_data_exp where patient_id_code not in pid';
    end;
    How am i suppose to mention the pid inside the return stmt i mean with any quotes or anything? because the above return stmt gives error
    "1 error has occurred
    Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the ''generic columns'' checkbox below the region source to proceed without parsing. The query can not be parsed, the cursor is not yet open or a function returning a SQL query returned without a value."
    Thanks

    Hello,
    I did exactly the way u told
    declare
    pid varchar2(100) := '(61092,61093)';
    begin
    return 'select patient_id_code from t_files_data_exp where patient_id_code not in ' || pid;
    end;
    patient_id_code is varchar2(100) only in table.
    For this i am getting "invalid number error".
    Thanks

  • How to use Item value in chart query

    Hi Folks,
    I am looking to use calander item value in sql query used to populate flash chart. I tried with following query where P2_DATE1 is the calander item name. This says no data found. I am not sure if I am missing some thing with BUTTON settings which I am using to put data into chart.
    Select null "link",to_date(entry_date,'dd-mon-yy hh:mi:ss') "Time in GMT", to_number(load_avg_5,'99.99') "Load Avg 5 Min" from oracle_ocm.top_load_avg --where trunc(entry_date)=:P2_DATE1
    I am new to APEX
    Please help

    Here are few things for you to try:
    Hardcode the value and see if it works. "where trunc(entry_date) = to_date('01-May-2010', 'dd-Mon-yyyy')". If it works, then click Session link at the bottom of the page, and check the value of the item P2_DATE1. If null, then you have a problem. If not null, please ensure that you use TO_DATE function as shown above with proper format mask.
    Good luck.
    Ravi A

  • Duplicate item value in a Multi-Record Block

    Is there a way to chek duplicate value entered in multi record block?
    I have seen some solutions in this forum however nothing has worked for me till now. (using the formula, creating hidden items & creating group etc)
    Thanks in advance,

    To see if there are any other records in the block with the same value, use Kevin Clark's famous function to trap duplicates. You can find Kevin's function write up here:
    Re: checking for same rows in a tabular
    From Kevin's post:
    Create a field PK_COPY in a control block.
    Create program unit function COMPARE to compare two input params returning 1 if they match else 0.
    Create a field in the datablock PK_MATCH, calculation property formula, formula COMPARE(:DATA_PK, :PK_COPY)
    Create a field in the control block NO_OF_MATCHES, calculation property summary, summary type SUM, summarised
    item PK_MATCH.
    Also, your control block requires the Single Record property set to yes, and the base table block requires the Query All Records property set to yes.
    WHEN-VALIDATE-ITEM on DATA_PK
    :CONTROL.PK_COPY := :DATA_PK;
    if :NO_OF_MATCHES > 1 then
      message('You have already used that one');
      Raise form_trigger_failure;
    end if;

  • PL/SQL block to sql case

    Hello,
    I have a newbie sql question:
    I have the following pl/sql block that I want to transform in sql case code:
                 IF Num_WholesaleNonDiscountValue > 0.0 THEN
                      UsageStatus := 'CHARGE';
                      if Num_WholesaleNonDiscountValue < 1.0 then
                          WholesaleNonDiscountValue := '0' || TO_CHAR(Num_WholesaleNonDiscountValue);
                        else
                          WholesaleNonDiscountValue := TO_CHAR(Num_WholesaleNonDiscountValue);
                      end if;
                  ELSE
                      UsageStatus := 'FREE';
                      WholesaleNonDiscountValue := TO_CHAR(Num_WholesaleNonDiscountValue);
                  END IF;All I do is the following code:
    select (case when Num_WholesaleNonDiscountValue > 0.0 then
                              (case Num_WholesaleNonDiscountValue < 1.0 then  '0' || TO_CHAR(Num_WholesaleNonDiscountValue
                               else TO_CHAR(Num_WholesaleNonDiscountValue))
             else TO_CHAR(Num_WholesaleNonDiscountValue)) from table_name;I do not know how to evaluate the UsageStatus variable, where to put it in the select statement.
    This is for my learning process.
    Thanks in advanced,
    Dan
    Edited by: danut68 on Jan 13, 2010 5:52 AM

    Hi, Dan,
    I think you want something like this:
    SELECT     CASE
              WHEN  Num_WholesaleNonDiscountValue > 0
              THEN  'CHARGE'
              ELSE  'FREE'
         END                              AS UsageStatus
    ,     CASE
              WHEN  Num_WholesaleNonDiscountValue > 0
              AND   Num_WholesaleNonDiscountValue < 1
              THEN  '0'
         END || TO_CHAR (Num_WholesaleNonDiscountValue)     AS WholesaleNonDiscountValue
    FROM     table_x
    ;A CASE expression returns one value.
    In PL/SQL, you can do two or more completely separate things (set two different variables, for example) in the same IF-THEN-ELSE block.
    To get the same results in SQL requires a completely different approach.
    The clearest is to use a different CASE expression for each of the things you're trying to do, as I did above. The WHEN clauses of those CASE statements may be very similar, even identical.
    Sometimes you can factor out some of the logic (using a sub-query, perhaps) so that the logic that has to be repeated in each CASE expression is very simple.
    Another option for setting two variables is to have a single CASE expression that returns a string wihich is the concatenation of two different varibales, which you later parse into two separate variables. I would do this only as a last resort.

  • Debugging PL/SQL blocks in SQL Developer

    Is there any way to debug blocks of PL/SQL in SQL Developer by setting breakpoints in the code? I'm using SQL Developer.
    I'm trying to debug some fairly complex PL/SQL blocks - they are not procedures or functions and so I'm unable to run them in debug mode.
    p.s. Apologies should have posted this in the database forum really.
    Edited by: Antilles on Sep 10, 2008 1:12 AM

    Hello,
    Sure you can, take a look at the following two links -
    http://sueharper.blogspot.com/2006/07/remote-debugging-with-sql-developer_13.html
    http://www.oracle.com/technology/oramag/oracle/08-may/o38browser.html
    Hope this helps,
    John.
    http://jes.blogs.shellprompt.net
    http://www.apex-evangelists.com

  • How exit for a script having set of pl/sql blocks and sql queries

    HI,
    I have set of blocks and sql queries in a script.
    In some cases I want to stop the excution of next statements and blocks.
    As in pl/sql block We can use return , in case of loop we can use exit, so what is to be use in case if sql script which contain set of blocks and sql queries.
    Thanks and Regards in Advance,

    Hi,
    how to exit from the script if confirm_to_continue is set to 'N'.
    i.e in this case I want the preceding statements not to be excuted.
    Please suggest.
    script:
    declare /*BLOCK NO1*/
    begin
    IF &&confirm_to_continue = 'N'
    THEN
    ---exit from from whole script
    RETURN; -- this will only exit from this block
    END IF;
    end;
    host IF EXIST &file_name (del &file_name) ELSE (echo missing)
    declare /*BLOCK NO 2*/
    begin
    end;
    /

  • How come the item value does not come thru via PL/SQL anonymous block?

    Hi,
    It's a Form with 3 tables -
    1) ClinicianProfileTb (with about 40 columns, insert/update via DML),
    2) PeopleTb (with about 7 columns, insert/update via PL/SQL anonymous block) and
    3) ClinicianPracticeTb (with about 10 columns, insert/update via PL/SQL anonymous block) for after-submit-processes.
    So I have several After-Submit-Processes. For some reason, it appears that PeopleId which is supposed to come thru via the 2nd After-Submit-Process (ie: Insert/Update PeopleTb) does not do the way it's supposed to. And when I press "Create" button at the bottom, I got the following error msg:
    ORA-01400: cannot insert NULL into ("TEST_0712"."CLINICIANPRACTICETB"."PEOPLEID")
    I tried the "debug" mode (via edit page link), but to no avail. (I'm newbie, trying to learn and deliver at the same time :)).
    I uploaded the app to apex.oracle.com, if someone could kindly take a look and let me know what goes wrong, it'd be greatly appreciated.
    workspace: test_0712
    app: 43408 - TEST
    user: demo
    pswd: demoPswd
    Page#21 -> look at the After-Submit-Processes -> in "Insert/Update PeopleTb" it appears that PeopeId does not come thru; thus it cannot be updated to ClinicianProfileTb.PeopleId (allows null) -> and thus cannot be inserted into ClincianPracticeTb.PeopleId (which does NOT allow null). Basically my logic is that in order to create ANY row in ClinicianPracticeTb, BOTH PracticeId AND PeopleId must be present.
    Acutally I should have used the PeopeTb as DML (as the driving table) to enforce that PeopleId must be present in order to insert ClinicianProfileTb and ClinicianPracticeTb, but it'd be lots of codes to write to insert/update in ClinicianProfileTb (40 columns).
    In addition, does ApEx consider EVERY SINGLE after-submit-process are in ONE transaction for commit/rollback? It appears that it treats all PL/SQL anonymous blocks are in ONE transaction, while Automatic Row Processing (DML) is commited/rolled back on its own?
    Thanks much,
    Helen

    All blocks that do not commit in one of the ways I detailed (and which do not explicitly commit using a commit statement) are part of the transaction started with > the first DML statement issued in any of the page processes and continuing until a commit is issued.Say, there are the following processes in the After-Submit-Processes:
    1. Process1 -> Automatic Row Processing (DML)
    2. Process2 -> PL/SQL anonymous block
    3. Process3 -> PL/SQL anonymous block
    Based on what you describe, in the event that if there is no explicit "commit" issued in any of these processes, then an implicit "commit" will be issued at the end of Process3?
    Thanks, Scott.
    Doreen

  • Having problems reading checkbox using $(item).value

    Is this the correct way to get the value of a checkbox using javascript
    var rem = 'P525_REMOVE_TEST';
    var isRem = $x(rem).value;
    alert(isRem);
    The checkbox return value is 'YES'
    I am getting undefined. What am I doing wrong?
    Howard

    Hi,
    Check box will return data only if it is checked otherwise it will return null.
    Put this code in "HTML Form Element Attributes" of your check box
    onchange="if (this.checked ) { alert(this.value);} else {alert('not checked')};"Regards,
    Manish

  • Exit from a pl/sql block

    Hi all. I'm on oracle 9i.
    I have a problem: I launch my sql file, which has a part made of some SQL commands and then inside it there is a part that is a PL/SQL block.
    What I want is that if a certain if condition is verified it must exit from PL/SQL block and also it must exit from all the file!
    Here is a part of code:
    drop table test1;
    create table test1
    as select * from test2;
    create table prova_test1
    as select * from test_1
    where 1=2;
    DECLARE
    conta number := 0;
    valore number := 0;
    contap number := 0;
    valorep number := 0;
    istruzione varchar2(2000) := null;
    BEGIN
    select count(1), sum(val) into contap,valorep
    from prova_test1;
    select count(1), sum(val) into conta,valore
    from test_1;
    if conta <> contap or valore <> valorep then
    istruzione := 'exit';
    execute immediate istruzione;
    else
    others sql statements.....
    end if;
    end;
    So what I want is that if the condition is verified it must exit from pl/sql block and also from all the process.
    How can I achieve that??
    Thanks for collaboration,
    Fabrizio

    Fabrizio Delli Priscoli wrote:
    whenever sqlerror exit 99
    whenever oserror exit 98
    Number 99 or 98, are SQLCODE returned from my exception?No, they are NOT SQLCODE.
    SQLCODE is an oracle database error code.
    Now,
    sqlerror is how 'Sql*Plus' (the one that is calling the pl/sql block) would handle ANY SQL ERROR coming out of pl/sql block OR other parts of the sql you are running within the SQL*Plus construct.
    99 and 98 are the error numbers that SQL*Plus is returning to the script or code that is calling SQL*Plus. In this case, probably the 'shell script' that calls this SQL*Plus construct.
    So, you would handle that error in the shell script.
    Maybe something like this: (this is the shell script that is calling a sqlplus session).
    1>>$LOGFILE 2>>$LOGFILE sqlplus -s $DBCONN <<EOF
    whenever sqlerror exit 99
    whenever oserror exit 98
    set serveroutput on
    set feedback off
    BEGIN
    some_code;
    END;
    exit
    EOF
    ret_value=$(echo $?)
    case "$ret_value" in
        99) mail -s "Error: Some sqlerror on the script on $(date)" $SOME_EMAIL <$LOGFILE ;;
        98) mail -s "Error: Some oserror on the script on $(date)" $SOME_EMAIL <$LOGFILE ;;
    esac

  • 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.

  • Item data using PL/SQL block region

    hello community,
    I have searched the whole forum using Pl/SQL but couldn't find an answer for this.
    I have a PL/SQL Anonymous block region, containing database items fetched by a process and custom items getting set by the Pl/SQL source.
    based on the ID I am getting the records i.e.
    Region Source (PL/SQL Anonymous block)
    declare
    CURSOR cpc_cur is SELECT "PRODUCT", "APPCODE", "COMCODE", "DESCRIPTION" from cp2 where "ID" = :P4_ID;
    begin
    for cpc_rec in cpc_cur
    loop
    :P4_P_NAME := cpc_rec.product;
    end loop;
    end;
    The custom item is text field with source Item.
    The item value is not filled in for the first time after login, but it shows the value in the session state as with status 'I', but from then onwards it works fine.
    Why is the value not fetched the first time?
    even I tried the postcalculation using nvl and it sets it to null.
    Also set_session state doesn't work.
    If I make the custom Item as Pl/SQL function, and write the query then it works fine, but gives problem as while inserting a new record the query has no ID to refer.
    Thanks in advance.
    Piyush

    Thanks Scott!!
    1) I am using PL/SQL region to get the data for few items on the form region which is based on a table, all table attributes are database items and additional Items whose data I am fetching from the PL/SQL are Custom items.
    2) Yes the loop executes only once per page view, Is their a better query?
    3) Well its very dumb to have a item source as item pointing to itself, but since the values are in session with status 'I' I thought this could do the trick!
    4) As the item source type used is [only..], the first time user logs in it doesn't displays the value, need to refresh the page, but the second time its gets the values form the session.
    5) If I make the Item source as PL/SQL function, I just fetch the records individually, same as in the query which works fine, but the items are also used for insertion (add new) and I clear the cache, so it gives error as it cannot execute the pl/sql function(no ID while addition)
    I hope I have answered your questions! If you have patience you can read the detail description.
    test application on oracle server
    http://apex.oracle.com/pls/otn/f?p=24296:1:3544773135949858:::::
    login/password test/test
    Application name :Test
    The page has 2 regions. when clicking on SN the values are transfered to form, except for 'Appcode'.
    Detail Description:
    I have a page with 2 regions.
    One region is a report region showing fewer details from a view. The other region is a PL/SQL(form region), which shows all the details and is linked to the report region.
    While linking I pass the ID from report and autofetch the data in form region.
    But some Items are not related to that database, so I created few items on form region (Custom Items). To fill in these values I did these things.
    1) Pass them through script (but passing 7 parameters through script is not good)
    2) Made another autofetch process to fetch the remaining Items, but it seems that its not possible to have 2 autofetch process on one form region.
    3) Changed the form type from HTML to PL/SQL, to assign the custom items values through code.
    for cpc_rec in cpc_cur
    loop
    :P_custom_item := cpc_rec.data;
    end loop;
    Either make source type static or Item (the same item P_custom_item).
    This pl/sql code do assign them the values, In the session state their status is 'I', but are not displayed on the page for the first login, need to refresh the page, as the source used is (only when..) it gets the value the second time.
    4) Made the item source as PL/SQL function and assign them the value. It works fine, but the same item is also used displaying description while insertion(gives error while insertion), so made a conditional process, even that gives the same error.
    I have a questions.
    If an Item status is 'I' in the session state, why is it not displaying the value on page.
    Thanking you in anticipation
    Piyush
    Message was edited by:
    user523112

  • Using PL/SQL Block how do you check if the character string value is aA-zZ

    I have a pl/sql block that I prompt the user for password and I load the string into an array and interrogate each index(entry) to see if it is "aA-zZ".
    How can I check if the value entered is Alpha.
    I need to do the same for number and Special character. Please advise. Thanks

    Thanks to All of you. The desired solution to verify complex password that enforces desired security policies. An example that I am using is the following:
    IF NOT (regexp_like(sz_complex_pw,'[[:digit:]]') AND regexp_like(sz_complex_pw,'[[:alpha:]]') AND regexp_like(sz_complex_pw,'[[:punct:]]') AND regexp_like(sz_complex_pw,'[[:upper:]]'))
    THEN
    --dbms_output.put_line('Password is not complex...');
    RAISE sz_err_pw_complex; -- Complex Password is not compliant
    END IF;
    DBMS_OUTPUT.PUT_LINE('Complex Password is in Compliance...');
    EXCEPTION
    This was helpful to me and I trust others will find helpful.
    Edited by: yakub21 on Oct 16, 2010 9:05 PM

  • How to set item values without using fields in branch's ACTION block?

    Okay, I will try to say this in a easy way so it is not weird.
    I have created a button, SAVE, that has a Branch of branch type: Branch To Function Returning A Page. This is my code for the branch:
    if :P2008_NAP_SUPPORTING_MATERIALS = 'Yes' then
    return '2092';
    else
    return '2040';
    end if;
    The code for this type of branch is stored in the ACTION block of the Branch page. The ACTION block for a Branch of branch type: Branch To Function Returning A Page is different than the ACTION block for a Branch of branch type: Branch To Page Or URL.
    I need to set some item values with some specific values, which I can do with a branch type: Branch To Page Or URL. This is not possible with the branch type: Branch To Function Returning A Page. The ACTION block is totally different.
    How can I set some values on say Page 2040 from Page 2008 without using fields in the branch's ACTION block?
    Thank you in advance,
    Maggie

    Andy and Scott,
    I love seeing different perspectives in solving problems, it opens my eyes to new ways of looking at/using the tools (reserved words and 'Function returning a Page', etc.).
    One of my pet peeves has been that on branches I was limited to only 10 variables to be passed (I know, who would want more - but there was an instance where I had to pass more), and an even more frustrating time when using report Column Linking, which limits me to 3 variables.
    At least with the Branch linking I can use your suggestion Andy and add the variable setting statements into the function. I am assuming of course (and I should be able to) that I will be able to set more that 10 variables in a IF condition prior to the RETURN statement. This method will be much more understandable, for me, when looking through the branch at a later time to see what is happening, than an URL link where all the variable are strung out 'in a line' so to speak.
    I will still need to use URL Target branching on Links contained within a Column Attribute when I need to pass more than 3 variables, of which I have several places where I do this.
    Thomas

Maybe you are looking for

  • Special character issue with Adobe Reader 11.03 Hyperlink path

    Adobe Reader changes a [ character in a hyperlink path to a % sign, thus changing the path and destroying the link,when opened in version 11.03.  This does not happen with 11.01. I have also seen this with Acrobat X, but not sure which update. This i

  • Adobe X Pro vs Adobe X Standard and Javascripts

    Hi, I'm running into a problem.  I have Adobe Acrobat X Pro on my computer at work, however, I'm finding that my field personnel have Adobe Acrobat X Standard.  I've written some javascripts on a form to automatically calculate when a number is enter

  • Single source Multiple Target Messages

    Hi All, I have one Source DataType and 3 TargetDataTypes I did Mappping and IterfaceMapping successfully while Iam going to Activate the Objects, the follwoing error is showing. Help me to this run successfully, Error is Activation of the change list

  • New version of Itunes won't download on windows

    I am using windows 7 and tried to download the newest versian of Itunes onto my computer, however, I keep getting the following error message: APS DAEMON.EXE error. MSVCR80.dll missing I am not able to download Itunes. Any advice? Thank you!

  • HT5007 why isn't this available in canada?

    It's not like the movies are especially different...