Plsql procedure containing select statement to fill page items

I would like to fill items :P200_A and :P200_B and so on
with the result of a SELECT which depends on the different values of many select lists.
E.G. :P200_list_alpha with the list of values
STATIC:less than 10;less,equal than 10;equal,above 10;above,indifferent;indiff
:P200_list_beta with the list of values
STATIC:active;active,passiv;passiv,excluded;excluded
How do I write the select statement ? I think it has to be executed in an anonymous PLSQL Procedure (after submit).
What is a convenient way to write the select statement ?
I could imagine to use lots of IF , ELSIF, ELSE statements and in each branch (here 12 ) the whole/complet SELECT statement is written.
How to solve this problem in an elegant way ?
In my opinion the CASE statement could be helpful, but how to use it in the WHERE clause with this nested conditions ?

I think I got it:
SELECT col1, col2, col3, ...
INTO :P200_A , :P200_B , ....
FROM mytable_1, mytable_2
WHERE mytable_1.col1 = mytable_2.col1
AND (
CASE
WHEN :P200_LIST_ALPHA = 'less' AND NVL(TO_COL_WITH_ALPHA, 0) < 10 THEN 1
WHEN :P200_LIST_ALPHA = 'equal' AND NVL(TO_COL_WITH_ALPHA, 0) = 10 THEN 1
WHEN :P200_LIST_ALPHA = 'above' AND NVL(TO_COL_WITH_ALPHA, 0) > 10 THEN 1
WHEN :P200_LIST_ALPHA = 'indiff' THEN 1
ELSE 0
END = 1 )
AND
( CASE
WHEN :P200_LIST_BETA = 'active' AND TO_COL_WITH_BETA IN ( 'a', 'A', 'akt', 'AKT' ) THEN 1
WHEN :P200_LIST_BETA = 'passive' AND TO_COL_WITH_BETA IN ( 'p', 'P' ) THEN 1
WHEN :P200_LIST_BETA = 'excluded' AND TO_COL_WITH_BETA = 'X' THEN 1
ELSE 0
END = 1 )
;Edited by: wucis on Oct 24, 2011 4:09 PM

Similar Messages

  • Assigning NULL in a select statement to a page item that doesn't exist? 2.2

    Hi all,
    Should the following raise an exception or cause an error? It does not in APEX 2.2.0. This is in a PL/SQL region at the "After Header" render point.
    Using a value other that NULL causes an error.
    Thanks!
    BEGIN
        SELECT
            NULL
        INTO
            :NOT_AN_ITEM
        FROM
            DUAL;
    END;

    It probably should but it doesn't in any version. It's because before it tries to update session state it compares the old and new values. If they're the same it skips the update. Since v('NOT_AN_ITEM') is null and the bound value is null, no update is attempted and no exception is raised.
    Scott

  • Can we call a procedure in select statement?

    Can we call a procedure in select statement?

    Hi,
    Raghu_appsdba wrote:
    Can we call a procedure in select statement?No. You can call functions, but not procedures.
    If the procedure does not change the database state (for example, it doesn't update any tables), then you can wrap it in a function, or re-write it as a function.
    Here's an example of wrapping.
    CREATE OR REPLACE FUNCTION fun_x (in_txt IN VARCHAR2)
    RETURN  VARCHAR2
    IS
    BEGIN
            proc_y (in_txt);
            RETURN  in_txt
    END     fun_x;

  • Using plsql tables in select statement of report query

    Hi
    Anyone have experience to use plsql table to select statement to create a report. In otherwords, How to run report using flat file (xx.txt) information like 10 records in flat files and use this 10 records to the report and run pdf files.
    thanks in advance
    suresh

    hi,
    u can use the utl_file package to do that using a ref cursor query in the data model and u can have this code to read data from a flat file
    declare
    ur_file utl_file.file_type;
    my_result varchar2(250);
    begin
    ur_file := UTL_FILE.FOPEN ('&directory', '&filename', 'r') ;
    utl_file.get_line(ur_file, my_result);
    dbms_output.put_line(my_result);
    utl_file.fclose(ur_file);
    end;
    make sure u have an entry in ur init.ora saying that your
    utl_file_dir = '\your directory where ur files reside'
    cheers!
    [email protected]

  • Error by using database procedure in select statement

    hi ,
    I have built a database procedure having one parameter with in out varchar type. that return value with some addition.
    i am using it with some column in select statement only for display purpuses but i am facing error by doing that in select statement. that procedure is working well with bind variable but not with select statement.
    plz help me how i can use a procedure in select statement. or can i do it or not.

    plz help me how i can use a procedure in select statement. or can i do it or not.A workaround could be to create a wrapper function for your procedure. One that only passes the input parameters and returns the output parameter.
    The simply call this function in your select which internally calls the procedure.

  • Why I Can't use procedure in select statement

    Why I Can't use procedure in select statement

    We can use function in select statement but we couldn't use procedure with one out parameters in select statement... You can use Function because they are designed for this but procedure are not. Functions can return value (without OUT parameter) which can be used in SELECT whereas procedures do not have such concept. As you can see in the above post you can not call even functions also if it has any out parameter.
    I have just trying to use procedure in select statement ..for this I require technical answer..The technical answer is because conceptually procedure is for doing set of operation, performning DMLs on the tables , whereas functions are for processing and producing a single result. Functions are basically for not using INSERT/UPDATE/DELETE in it. That is the reason they are allowed to be used in SELECT because conceptually they are not supposed to do any data changes.
    Regards,
    Avinash

  • How can I call a Page Process from the Select statement for Report Page

    I'm able to call a javascript using the below:
    img src="#IMAGE_PREFIX#add2.gif" border="0" alt="Icon 4" onClick="javascript:add_connect1('||CPORT.ID||')"
    But Now,
    I'd like to accomplish (2) New things:
    1. instead of using,....... onClick="javascript:add_connect1,
    I'd like to call a Page Process, onClick=
    2. I'd like to be able to call two different processes onClick.
    a. onClick="javascript:passBack('||ID||')"
    b. onClick= <Please see my question #1 above>
    Can someone please help me with the syntax for this,
    If indeed it can even be done?
    Thanks- Gary

    Greg.
    It seems that my situation is the one you describe in you second paragraph, where you mention:
    you could then add the ID column value as a parameter to the javascript functionBut,
    I do not know how to reference the variable in my javascript nor how to use it in my on-demand process.
    If you can hellp me past this last little bump, then I think I will be able to use these skills in Sooo many different areas of my design.
    Here's what I've got so far:
    A. In the select statement I identify the javascript as:
    onClick="javascript:connect_port('<font color=blue>''||ID||''</font>')";
    B. In my javascript I have this:
    <script language="JavaScript" type="text/javascript">
    function connect_port(ID)
    var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=CONNECT_PORT',0);
    gReturn = get.get();
    get = null;
    </script>
    C. In my on demand function I have this:
    BEGIN
    INSERT INTO CCONNECTIONS_B
    BLDG_ID,CLST_ID,PORT_ID,STRAND_ID
    ) VALUES
    :P2004_BLDG_ID,:P2004_CLST_ID,:P2004_PORT_ID,:P2004_STRAND_ID1
    END;
    You can see that I dont know how to use the value for 'ID' in either the javascript or the On-Process function.
    If you can help me out with this one, Then I can imitate it for the rest.
    -Gary
    Edited by: garyNboston on Apr 3, 2009 6:44 AM
    Edited by: garyNboston on Apr 3, 2009 6:44 AM
    Edited by: garyNboston on Apr 3, 2009 6:45 AM
    Edited by: garyNboston on Apr 3, 2009 6:47 AM

  • JDBC Sender MSSQL Stored Procedure - Multiple Select Statements

    Hello all,
    I will proceed to tell you my problem, for which solution I request your kind advice:
    Im working in a project for a retailer, which consists in sending the information from erp and sql server to pos thru XI interfaces.
    One of the interfaces is about sending items from sql server to a file so the pos can load it into the system. For doing so I have devloped an stored procedure which function is to return several select statements as many stores the retailer might have, so they can have a different file per store along with its corresponding items in it. 
    The thing is that XI just gets the first select statement and creates the corresponding file, but it seems to ignore the remaining responses as I'm neither getting any file nor an error afterwards.
    So, my question is: is XI capable of handling multiple select responses from an Stored Procedure in graphical mapping??? Or am I just wasting my time trying?
    Thanks in advice for your help.
    Regards.

    Hello Ramkumar,
    After 5 days trying, I finally made it work out applying your advice. Below the short explanation of what I did:
    My Source structure is: Main Node->Row->Records (Material Number, StoreNum, Price, Status)
    My Target structure is: Main Node->File Node->Record Node->Records ( Material Number, Price, Status)
    The key was to make all the occurrences happen against StoreNum node. So, based on what you adviced these two where the key mappings:
    1) The Mapping that will create a new file for each different store that comes in the query (In my case, query was already sort by store using an sql "order by" function, if not you can also use xi node function "sort" as Ramkumar suggested)
    StoreNum->RemoveContext->SplitbyValue (Value Changed)->Collapse Contexts->File Node
    2) The Mapping that will create each record in its corresponding store file:
    StoreNum->RemoveContext->SplitbyValue (Value Changed)->Record Node
    And Voilá !!! It worked.
    Thanks very much Ramkumar.
    Regards.

  • Using procedure in SELECT statement

    I have a select statement that currently uses 4 functions to receive necessary values. All the functions are recursive and returns values from the same row.
    What I would like to do is replace these for function calls with 1 procedure. Does anybody know if it possible to use a procedure in this way inside a select statement?
    If so, do you have the syntax for doing this?
    E.g
    SELECT
    Mdbrd_Pkg.calculate_fixed_charge_fn(in_rc_id, ap.CONFIGSET_ID) AS FIXED_CHARGE,
    Mdbrd_Pkg.calculate_charge_rate_fn(in_rc_id, ap.CONFIGSET_ID) AS CHARGE_RATE,
    Mdbrd_Pkg.tax_liable_fn(in_rc_id, ap.CONFIGSET_ID) AS TAX_LIABLE,
    Mdbrd_Pkg.charge_unit_fn( in_rc_id, ap.CONFIGSET_ID) AS CHARGEUNIT_ID
    FROM .....

    This cannot be done. The part of the function used in the SELECT statement is the return value: procedures don't have return values (that's what makes tham procedures and not functions).
    Obviously I don't know what your code does, but you should consider putting them into a single function that returns a TYPE with four attributes and then using the TABLE() function to cast them into something you could reference in the FROM clause of a correlated sub-query. Sounds a bit messy though.
    Do these functions actually select data? Where does the recursion fit in?
    Cheers, APC

  • Passing values to OnDemandProcess from Select Statement on Reports Page

    I think I'm just missing some of the proper syntax, Can somebody please help me.
    As I've come to understand this process of passing the values,
    I recognize it as (3) steps.
    1. Referencing the "javascript" in the Select Statement of the Reports Page.
    2. Including the "javascript" in the Page Header region.
    3. Defining the Process as an OnDemand Application Process.
    My problem is:
    a. I can't seem to get the Value passed to the Application Process.
    b. I don't know how to reference the Value passed once I get it passed.
    Here's what I've got done so far:
    1. (The Select Statement)
       onClick="javascript:ORDER_CONNECT_SEQUENCE('||ID||')
    {code}
    2. (The javascript)
    {code}
    function ORDER_CONNECT_SEQUENCE('+ID+')
    var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=ORDER_CONNECT_SEQUENCE',0);
    get.add('+ID+');
    gReturn = get.get('+ID+');
    {code}
    3. (The Application Process)
    {code}
       BEGIN
       Select '+ID+' into THIS_CIRCUIT from dual;
    {code}
    I Know that the Application Process is being referenced and that the OnClick routine is working properly,
    because if I plug a Value into the Application Process, instead of using '+ID+',
    Then I get all of my desired results.
    Any help you can give me here is greatly appreciated.
    Thanks- Gary                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Dimitri, Thanks for your efforts here, but its still not working for me.
    Here's what I understand from your suggestions:
    1. (changes to the javascipt)
       a. replace function ORDER_CONNECT_SEQUENCE('+ID+')
           with
           function ORDER_CONNECT_SEQUENCE(pId)
       b. replace get.add('+ID+')
           with
           get.addParam('x01',pId)
       c. replace getReturn = get.get('+ID+')
          with
          getReturn = get.get()
          get = null2. (chages to the Application Process)
       a. add l_value varchar2(4000) to my list of declarations
       b. add l_value := wwv_flow.g_x01 below the begin statement
       c. I guess then I would reference the l_value like this:
           Select l_value into THIS_CIRCUIT from dual* Also, You didn't mention any changes in my Select statement in the Reports region of the page.
    FYI.
      onClick="javascript:ORDER_CONNECT_SEQUENCE('||ID||')
    {code}
      The 'ID' which I'm referencing here is an ID from the table which I'm querying.
    Am I misunderstanding you somewhere?
    Thanks- gary                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • SQL Insert and Select statements on same page

    Newbie here.
    Is it possible to insert data from a form to a database and then get data from the database using "select" from the same page.
    I have a form that submits the authors details to an Access database but I need to get the AuthorID (which is an autonumber in the table) to show on the same page.
    <%@ page language="java" contentType="text/html" import="java.sql.*" %>
    <html>
    <head>
    <title>Confirm Details Submission</title>
    </head>
    </body>
    <%
    String title = request.getParameter("title");
    String surname = request.getParameter("surname");
    surname = surname.replaceAll("'", "''");
    String forename = request.getParameter("forename");
    forename = forename.replaceAll("'", "''");
    String address = request.getParameter("address");
    address = address.replaceAll("'", "''");
    String address2 = request.getParameter("address2");
    address2 = address2.replaceAll("'", "''");
    String town = request.getParameter("town");
    town = town.replaceAll("'", "''");
    String postcode = request.getParameter("postcode");
    String email = request.getParameter("email");
    email = email.replaceAll("'", "''");
    String dob = request.getParameter("dob");
    String telephone = request.getParameter("telephone");
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection Conn = DriverManager.getConnection("jdbc:odbc:Novbase","","");
    Statement Stmt = Conn.createStatement();
    String Query = ("INSERT INTO Author (Title, Surname, Forename, Address, Address2, Town, Postcode, EMail, DOB, TelNo) VALUES ('" + title + "', '" + surname + "', '" + forename + "', '" + address + "', '" + address2 + "', '" + town + "', '" + postcode + "', '" + email + "', '" + dob + "', '" + telephone +"')");
    //Stmt.executeUpdate(Query) is where the records are inserted.
    int SQLStatus = Stmt.executeUpdate(Query);
         if(SQLStatus != 0)
    %>
    Thank you. Your Author ID number is ??
    <%
    else
    %>
    Error - Your details have not been submitted</font></h4>
    <br>
    Please click back on your browser and try again. If you experience further difficulties please go to our <a href ="help.html">help</a> pages.<br>
    <%
    Stmt.close(); Conn.close();
    %>
    </body>
    </html>

    Hi,
    You could execute queries as many times as you want using the same connection.
    For ex;
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection Conn = DriverManager.getConnection("jdbc:odbc:Novbase","","");
    Statement Stmt = Conn.createStatement();
    String Query = ("INSERT INTO Author (Title, Surname, Forename, Address, Address2, Town, Postcode, EMail, DOB, TelNo) VALUES ('" + title + "', '" + surname + "', '" + forename + "', '" + address + "', '" + address2 + "', '" + town + "', '" + postcode + "', '" + email + "', '" + dob + "', '" + telephone +"')");
    //Stmt.executeUpdate(Query) is where the records are inserted.
    int SQLStatus = Stmt.executeUpdate(Query);
    if(SQLStatus != 0)
    Query = "SELECT Forname FROM Author;";
    ResultSet name = stmt.executeQuery(Query);
    //Now name will have all the Forname fields in the database. You could retrieve that using the get methods.
    %>
    Thank you. Your Author ID number is ??
    <%
    else
    %>
    Error - Your details have not been submitted</font></h4>
    <br>
    Please click back on your browser and try again. If you experience further difficulties please go to our <a href ="help.html">help</a> pages.<br>
    <%
    Stmt.close(); Conn.close();
    %>
    I hope that can help you.
    Rajesh

  • MySql select statement in jsp page

    Ok,
    I need help with this select statement.
    <%
    // Determine what option is set to.
    if(option == null || "".equals(option) || "Verify1".equals(option)){
      if("Verify1".equals(option)){
      // Retrive query specific to submitted form.
      try {
          Class.forName("org.gjt.mm.mysql.Driver").newInstance();
          conn = DriverManager.getConnection("jdbc:mysql://" + mysql_host + ":3306/" + mysql_database, mysql_login, mysql_password);
          st = conn.createStatement();
          rs= st.executeQuery("SELECT organization FROM tblevent_approval WHERE MAX (keyid))";
          // Get query results.
          while(rs.next()){
            organization = rs.getString("organization");
      finally {
            if(rs != null){
              rs.close();
            if(st != null){
              st.close()
            if(conn != null){
              conn.close();
    %>THE ERROR I AM GETTING
    Syntax error, insert ")" to complete Expression

    This line has the closing bracket inside the closing quote for the statement...
    >       rs= st.executeQuery("SELECT organization FROM tblevent_approval WHERE MAX (keyid))";It should be:
    rs= st.executeQuery("SELECT organization FROM tblevent_approval WHERE MAX (keyid)");A simple typo ;-)
    Hope this helps...

  • Redo log contains select statement ??

    If i do a select command will that be stored in redolog file?
    If it gets storeed there then during recovery will that select statement will also run and use time in recovery?

    When either more then 1 MB of changes or 1/3 buffer
    if full or other reasons.
    Means uncommited data also get flush to online redo
    log file.
    But ssome persons says only commited sql command gets
    store in log buffer...
    Few other , including my oracle facluty says only
    commited changes are flush from redo log buffer to
    online redo log file.......
    Any one 100% Surety ......I know reading document is not your cup of tea, unfortunately it's most reliable source of information concerning Oracle.
    Oracle Concept mentioned
    Note:
    Sometimes, if more buffer space is needed, LGWR writes redo log entries before a transaction is committed. These entries become permanent only if the transaction is later committed.

  • How to get notified when ever I select any frame (any page item) ?

    I have added a observer class in my plugin which derives from ActiveSelectionObserver.
    But my observer constructor is not getting called when i select a page item. (In short, I am not getting notified about the selection)
    below is my code:
    class CSDTSelectionObserverImpl : public ActiveSelectionObserver
    public:
      CSDTSelectionObserverImpl(IPMUnknown *boss);
       virtual ~CSDTSelectionObserverImpl();
    protected:
       virtual void    HandleSelectionChanged (const ISelectionMessage*);
       virtual void HandleSelectionAttributeChanged(const ISelectionMessage* selectionMessage);
    CREATE_PMINTERFACE(CSDTSelectionObserverImpl, kCSDTSelectionObserverImpl)
    CSDTSelectionObserverImpl::CSDTSelectionObserverImpl(IPMUnknown *boss) : ActiveSelectionObserver(boss,IID_ICSDTSELECTIONOBSERVER) { }
    CSDTSelectionObserverImpl::~CSDTSelectionObserverImpl() { }
    void CSDTSelectionObserverImpl::HandleSelectionChanged(const ISelectionMessage* selectionMessage) { }
    void CSDTSelectionObserverImpl::HandleSelectionAttributeChanged(const ISelectionMessage* selectionMessage) {  
    if (selectionMessage && selectionMessage->WasSuiteAffected(IID_ILAYOUTSELECTION_ISUITE))
    Also, In my .fr file, I have added below:
    AddIn
      kDocBoss,
      kInvalidClass,
        IID_ICSDTSELECTIONOBSERVER, kCSDTSelectionObserverImpl,
    Do I need to implement the ILayoutSelectionSuite as well to get the notification on page item selection or implementing Observer via ActiveSelectionObserver is sufficient?
    Please help.

    I tried below in debug mode , but it gave me error while execution (when the line of code was called by in-design)
    InterfacePtr<ILayoutSelectionSuite> iLayoutSelectionSuite(fCurrentSelection, UseDefaultIID());
            if (iLayoutSelectionSuite == nil)
                break;
    iLayoutSelectionSuite->SelectPageItems(selection,Selection::kReplace,Selection::kDontScrollLayoutSelection); // Error
    So I was not able to get the UIDList of the selected page items, hence I used below code and this is working.
      InterfacePtr<const IIntegratorTarget> iIntegratorTarget(iLayoutSelectionSuite, UseDefaultIID());
            std::auto_ptr<IIntegratorTarget::TargetSuiteCollection> selectionSuites(iIntegratorTarget->GetTarget(ILayoutTarget::kDefaultIID));
            for(IIntegratorTarget::TargetSuiteCollection::size_type i = 0; i < selectionSuites->size(); i++)
                ILayoutTarget* target = (ILayoutTarget*)selectionSuites->at(i).get();
                if(!target)
                    continue;
                selection = target->GetUIDList(kDontStripStandoffs);
    But it would have been much easier and logical if I can get it using IlayoutSelectionSuite or if there is some better approach ?
    Please let me know.
    ileleLayoutSelectio
    Let me

  • Invoking stored procedures containing DML statements

    Hi, I'm invoking a stored procedure that inserts the form record into the base tables, however I do not want to insert duplicates and if I try to do a count on that record from forms I get 0 records until the session is commited. I assume the insert was done in another session? is there a way around this? Thanks.

    thanks, I found that the reason I was getting 0 records is because I'm calling a db package to insert the record using the on-insert trigger.. forms is only populating the table once I try to commit all the records bypassing my when-validate-record trigger.. so I now call my check_unique procedure from the insert procedure and raise an application exception from the db procedure...seems to work.

Maybe you are looking for

  • 2.0 bios and video lag

    I flashed the BIOS on my 875P NEO-FIS2R (old 1.x version Neo) to 2.0 and now all my games have significatly lower frame rates.  I've tried installing the latest drivers for EVERYTHING in my computer and nothing seems to help.  Is there a setting in t

  • BDC FOR MM02

    Hi Friends, i want to write a BDC FOR MM02 T.CODE AT PLANT LEVEL AND METERIAL LEVEL. I WANT UPLOAD THE BELOW FEILDS DATA : THE FIELDS THAT I WANT UPLOAD IS EISBE(SAFETY STOCK) , MAABC(ABC INDICATOR) AND WZEIT(LEAD TIME).....AT PLANT LEVEL AND METERIA

  • How to filter xml using dtd and create a new xml document

    Good morning my name is Antonio and I'm an italian programmer. I need an help about the follow question. I want to filter the contents of a XML document using a DTD to allow only the valid elements and attributes as specified in the DTD to be passed

  • HT201317 I am now on I Cloud. How do I keep my photos on my I Pad?

    I Am now on I Cloud, how do I keep my photos on my I Cloud?

  • Changing Media Kind To Podcast

    Hi, I have downloaded some free podcasts from Soundcloud but they are not going into my podcast tab in iTunes. I have clicked 'Get Info" and changed media kind to Podcast but it just disappears from my library and seems to go missing. It still plays