Return Query based on conditon

Hi,
I there are two queries i need to return them conditinally but i am getting a error please let me know where this error is comming from
DECLARE
q VARCHAR2(2000);
BEGIN
if :app_user like 'sudhir' then //Here :app_user is a bind variable
q:=' SELECT
APEX_ITEM.TEXT(1,null,10,10) "Enable"
from dual ';
RETURN q;
End if;
END;
Error returned like this
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.
Please suggest me how to modify
Thanks
Sudhir

Is this an Apps problem?
Then i think this is not the ideal place to post this kind of problem.
This is a PL/SQL forum.
Regards.
Satyaki De.

Similar Messages

  • Return query based on condition

    I'm trying to create a report region that returns results based on which table the data is stored. I'm using the type SQL Query(PL/SQL function body returning SQL query). I do a select to the first set of tables if the data is not there then it will do a select on the other set of tables. Each query will work find alone. But one query will not work when I use the condition IF Else return query.
    Does anybody know how I can accomplish this?
    Here is the Query:
    declare
    v_cnt number;
    begin
    select count(*) into v_cnt from image_repo_images im, image_repo_lookup il
    where im.document_id_type = il.lookup_code
    and il.lookup_type = 'DOCUMENT_TYPE'
    and il.lookup_code = 1
    and im.document_id = :P1_FILE_DLN;
    if v_cnt > 0 then
    return 'select distinct il.meaning, im.document_id, im.system_entry_date,im.batch_type,im.document_id_type
    from image_repo_images im, image_repo_lookup il
    where im.document_id = :P1_FILE_DLN
    and im.document_id_type = il.lookup_code
    and il.lookup_type = ''DOCUMENT_TYPE''
    and il.lookup_code = 1;';
    else
    return 'select ''DLN'', dln, null e_date,null bt,null tp from income_tax_return_images where dln = :P1_FILE_DLN';
    end if;
    end;
    Looks rather straight forward to me.
    I get this error:
    report error:
    ORA-20001: Error fetching column value: ORA-01403: no data found
    Any help will be appreciated.

    Does this work for you:
    DECLARE
       v_cnt     NUMBER;
       v_query   VARCHAR2 (4000);
    BEGIN
       SELECT COUNT (*)
         INTO v_cnt
         FROM image_repo_images im, image_repo_lookup il
        WHERE im.document_id_type = il.lookup_code
          AND il.lookup_type = 'DOCUMENT_TYPE'
          AND il.lookup_code = 1
          AND im.document_id = :p1_file_dln;
       IF v_cnt > 0
       THEN
          v_query :=
                v_query
             || 'SELECT DISTINCT il.meaning, im.document_id,'
             || ' im.system_entry_date,im.batch_type,im.document_id_type'
             || ' FROM image_repo_images im, image_repo_lookup il'
             || ' WHERE im.document_id = :P1_FILE_DLN'
             || ' AND im.document_id_type = il.lookup_code'
             || ' AND il.lookup_type = ''DOCUMENT_TYPE'''
             || ' AND il.lookup_code = 1';
       ELSE
          v_query :=
                v_query
             || 'SELECT ''DLN'', dln, null e_date,null bt,null tp '
             || ' FROM income_tax_return_images WHERE dln = :P1_FILE_DLN';
       END IF;
       RETURN v_query;
    END;I think you have a semicolon too much at "...il.lookup_code = 1;"
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Function returning query takes more time to run in Apex4.0

    Hi All,
    I created a report using function returning query. The function returns query based the parameters which returns dynamic columns. When I run the query in sql developer the query generates and returns the result in 3mins. But in apex it takes maximum of 35mins to return.
    The query will return around 10000 rows.
    Is it a performance issue in the query or in Apex?can anyone please help
    Regards
    Raj

    RajEndiran wrote:
    Hi Roel,
    Thanks much for your suggestion. I run in TOAD and got the result as
    Row 1 of 500 fetched so far in 3.31 minutes which means it queried for 500 records alone ? is that not the actual time taken to run the fulll query?That reflects the time to return the first 500 records...
    Please suggest.With all the best will in the world, if I was your user and I had to wait 3 minutes for the page to refresh, I'd steadily lose the will to live!
    As this is primarily an SQL tuning question, have a look at this message in the FAQ thread in the {forum:id=75} forum:
    {message:id=9360003}
    That should give you some pointers on the right approach.

  • Select List (query based LOV) in a wizard created report form

    I have created an updatable report form with 3 columns:
    app_id
    user_id
    group_id
    Each app_id has multiple group_id's associated with it, and I want to show the group_id field as a Select List (query based LOV) that contains the groups associated with the app_id.
    My query for the select list needs to be similar to the following:
    SELECT DISPLAY_NAME, GROUP_ID
    FROM APPLICATION_GROUPS
    WHERE APP_ID = ?????
    ORDER BY 1
    The problem is, I don't know how to reference the app_id from the main report to replace the ?????.
    In other words, if my report returns 2 rows of data like this:
    app_id----------user_id----------group_id
    1-----------------24------------------3
    2-----------------24------------------15
    Then how do I get the group_id column to be a select list of possible groups for each application? If app_id 1 has 3 groups associated with it, 3, 4, & 5 and app_id 2 has 2 groups associated with it, 15 & 16, then those each of the select lists should be based on the app_id.
    Hopefully I explained this clearly.
    Thanks,
    Kris

    Leo,
    Thanks for the response, but I don't think you quite understand my problem. If I go to the Column Attributes screen for the group_id field, I have the "Display As" drop down set to "Select List (query based LOV)", not "Select List (named LOV)". This requires that the sql query be written in the "List of values definition" text area below. Within that text area I have the following query:
    SELECT DISPLAY_NAME, GROUP_ID
    FROM APPLICATION_GROUPS
    WHERE APP_ID = ?????
    ORDER BY 1
    The APP_ID that I need to reference is for the current row of data that is being processed. Therefore, I can't use a :PNNN_APP_ID variable, because that field does not exist on the page.
    Hopefully this explains it a little better.
    Thanks,
    Kris

  • SOURCING10: Passing parameters to a Query Based webservice using JAVA

    Hi Experts,
    I have been working on consuming a Query based webservice published in Souricng10 in a simple JAVA class. The query has a filter parameter which is not mandatory. I am able to consume the webservice using the GET method and display the content of the webservice. But when i try to POST a value to the filter parameter of the query i am getting the following error:
    java.io.IOException : Server returned HTTP response code: 415 for URL: http://sapcild9.web.bc:55000/sourcing/ngservices/rest/query/Z_TEST_WS_QUERY/execute/
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    Following is the code which i have used:
       URL url = new URL("http://sapcild9.web.bc:55000/sourcing/ngservices/rest/query/Z_TEST_WS_QUERY/execute/");
       HttpURLConnection connection = (HttpURLConnection)url.openConnection();
       connection.setRequestProperty("Authorization", "Basic " + authStringEnc);
       connection.setRequestProperty("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
       connection.setRequestProperty("Content-Length", "" +Integer.toString(urlParameters.getBytes().length));
       connection.setRequestProperty("Content-Language", "en-US");
       connection.setUseCaches (false);
       connection.setDoInput(true);
       connection.setDoOutput(true);
       connection.setAllowUserInteraction(true);
       connection.setInstanceFollowRedirects(false);
       connection.setRequestMethod("POST");
       connection.connect();
       //Send request
       OutputStream out = connection.getOutputStream();
       OutputStreamWriter wr= new OutputStreamWriter(out, "UTF-8");
       wr.write("EXTERNAL_ID");
       wr.write("=");
       wr.write(URLEncoder.encode("temp","UTF-8"));
       wr.close();
       out.close();
       is = connection.getInputStream();
       isr =new InputStreamReader(is);
       BufferedReader bufferReader = new BufferedReader(isr);
       String str; StringBuffer stringBuffer = new StringBuffer();
       while ((str = bufferReader.readLine()) != null) {
       stringBuffer.append(str);
       stringBuffer.append("\n");
       System.out.println(stringBuffer.toString());
       connection.disconnect();
       is.close();
    Please Advise how to proceed on this isssue?
    Thanks in advance.
    Srikanth Emani

    Hi Gael,
    your URL is made up of :
    [ProcedureName]?[parameter1]=[value1]&[parameter2]=[value2]
    creating URLs like this can have problems especially with spaces and punctuation.
    the answer is a FORM
    the following will create a hidden form :
    FORM ACTION="[ProcedureName]" METHOD="POST" name="F1"
    INPUT type="HIDDEN" name="[parameter1]" value="[value1]"
    INPUT type="HIDDEN" name="[parameter2]" value="[value2]"
    /FORM
    you can set the values in the form using:
    document.F1.[parameter1].value="abc123%%&&$$!";
    document.F1.submit();
    will submit the form and the PL/SQL procedure should receive the text as it was contained in the form.
    the only characters that can now cause problems are :
    " as it delimits the field.
    ' as it may cause problems in PL/SQL.
    \ as it is a special character.
    Regards Michael

  • Query based on dynamic url paramter

    I am displaying all the results of a simple select statement on one page in an html table. One of these colums displays the unique ID of every row returned from the query. I want to make the ID field an active link, whereupon when the user clicks it, they are taken to seperate page where information for just that row is displayed. I'd imagine you have to pass the ID for that specific row to the next page via the URL, and run another query based on that specific ID to retrieve the information. I just don't know how to have the URL variable equal the ID for each row. All I can find is static examples such as 'www.gotopage.jsp?ID=1234'.

    while displaying the result in html table,
    form the href like this
    String id = resultSet.getString("ID");
    <a href="gotopage.jsp?ID=<%= id%"></a><%=id%>.......
    or post your code and we may be able to point it out.

  • Running query based on other query result

    Hi Again Friends.
    first of all i am very much thankful for members who sent me prompt response and been helping for last 2 days.I am again with query,maybe a lame one.
    I want to run a query based on record return from previous query.FOr instance i have query
    Select sum(marks) from studentMarks,student_id where course_Id=4 and student_Id
    IN
    (Select StudentId from Student where dept_id=3)
    the courseID and studentID are being repeated in the above table
    now I want to show Student Names with the marks Obtained and who belong to dept_id=3,i want to run other query to get Name based on StudentId resutned from previous one.
    Is there anyway to do this in oracle to save result in some resultSe and use it later?
    Thankyou

    Do you mean something like:
    Select sum(marks), S.StudentId, S.StudentName
    from StudentMarks M
    ,      Student          S
    where S.course_Id=4
    and  M.Student_id = S.StudentId
    and S.student_Id
    IN
    (Select StudentId from Student where dept_id=3)
    group by StudentId, StudentName

  • Query based on permission

    Does anyone know if there's a way to query for group (or any other object) based on the current user's permission?  For instance, if I wanted to retrieve all of the groups to which the current user has read access?
    If not, is there a way to retrieve the current user's access level for each object in the query?  So for instance, in addition to returning the group name and group id, also return the user's level of access.
    Thanks a lot!

    Read the documentation:
    http://livedocs.macromedia.com/coldfusion/7/htmldocs/00001252.htm
    page1.html
    <form id="form1" name="form1" method="post"
    action="page2.cfm">
    <label>enter id <input type="text" name="textfield"
    />
    </label>
    </form>
    page2.cfm
    <cfquery name="foo" datasource="bar">
    SELECT aField, bField, cField
    FROM aTable
    WHERE aField = <cfqueryParam value="#form.textfield#"
    cfsqltype="cf_sql_varchar">
    </cfquery>
    <cfoutput query="foo">
    #aField# #bField# #cField#
    </cfoutput>
    briankind wrote:
    > query based on a test input box
    >
    > hi
    > i have this html input box and i want to output a query
    based on what i put in
    > the input box. what should i do now.
    >
    > thanks
    >
    >
    > <form id="form1" name="form1" method="post"
    action="">
    > <label>enter id <input type="text"
    name="textfield" />
    > </label>
    > </form>
    >

  • Character string buffer too small (select list query based LOV)

    Hi,
    Using the select list query based LOV with a select witch is too big, you get this error.
    report error:
    ORA-20001: Error fetching column value: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    When using the Popup LOV query based LOV) then it works nice.
    Can that be solved somehow?
    With the Popup LOV the return value is displayed in stead of the description.

    Hi Andy,
    How do I incorporate your suggestion on a report ?
    Example : I have
    select apex_item.display_and_save(1,column1,5) col1,
    apex_item.display_and_save(2,column2,5) col2 ,
    apex_item.popup_from_query(3, emp_name, 'select user_name, name  empname from table2) col3
    Table 2 is a long list , and I'm getting string buffer too small due to this.
    Your suggestion with HTP is good but I'm not sure how to implement it for reports as I'll like the user to change the values with the select_list.
    I'm not using forms as they want mulit-record on the same page.
    Hope to hear back from you soon.
    Thanks very much.

  • Query Based on Ranking

    Hi All,
    I wnat to write a query which will return row based on priority.
    Taking the example of UOM Conversion rate:
    This can be defined in general or can be Item Specific.
    My question is, how can I write a query so that If Item Specific conversion rate exist, then query should return that rate.. otherwise it should return generic rate.
    This is a simplified case, We can extend it to many level. For example,Approver can be defined at Department, Zone, Company level. In this case, If we supply the query with Department, Zone and Company. Then query should return approver based on most closely match criteria. i.e
    If Approver exist for Department, then query should return that approver.
    If Approver doesn't exist for Department then it should look for Zone.
    If can't find for Zone, then It should look for Company.
    At the end, it should return only one approver.
    Can we do this Using SQL ?

    Can this be done in SQL? Maybe, maybe not. Where and how are you storing the approver? How do you link the item and the approver? Create table statements and sample data inserts would help.
    John

  • Running Query Based on Condition

    Hi
    I want to run different query based on a condition. I am not able to execute the following query. is this the right way to run different query based on condition?
    SELECT * FROM (
    CASE WHEN (SELECT COUNT (*) from data1 where ID = 1 AND stype = 'A') > 0 THEN select * from data where ID = 1 AND stype = 'A'
    WHEN (SELECT COUNT (*) from data1 where ID = 1 AND stype = 'B') > 0 THEN select * from data where ID = 1 AND stype = 'B'
    WHEN (SELECT COUNT (*) from data1 where ID = 1 AND stype = 'C') > 0 THEN select * from data where ID = 1 AND stype = 'C'
    END
    ) as a;
    Edited by: user6016744 on 21 Apr, 2011 12:40 AM

    This works for us; hope it helps.
    CREATE OR REPLACE FUNCTION SCHEMA.GET_STEP_COST (loan_number_in in VARCHAR2, step_code_in in VARCHAR2 default null, ws_in in VARCHAR2 default null )
    RETURN VARCHAR2 IS retval  VARCHAR2 (50);
    /*passing in loan number and step code you need the cost for, will return the cost*/
    BEGIN
        CASE ws_in --depending on workstation in is the table select
        WHEN 'F' THEN
            EXECUTE IMMEDIATE 'SELECT '|| step_code_in ||' FROM CLAIMS_FCL_STEPS WHERE LOAN_NUMBER = '|| loan_number_in ||'' INTO retval;
        WHEN 'R' THEN
           EXECUTE IMMEDIATE 'SELECT '|| step_code_in ||' FROM CLAIMS_RS_STEPS  WHERE LOAN_NUMBER = '|| loan_number_in ||'' INTO retval;
        WHEN 'L' THEN
           EXECUTE IMMEDIATE 'SELECT '|| step_code_in ||' FROM CLAIMS_LM_STEPS  WHERE LOAN_NUMBER = '|| loan_number_in ||'' INTO retval;   
        ELSE
            retval := 0;
        END CASE;
      RETURN retval;
    END GET_STEP_COST;
    /

  • Query based taxonomy from scratch gives NoSuchMethodError...

    I'm trying to create a query based taxonomy following the instuctions specified in the help docs: KM Platform -> Admin Guide -> Content Mgmt -> Taxonomies and Classification -> Creating a QBT -> from scratch. I created an index on a newly created (hence empty) folder in the 'documents' repository. So, essentially, the data source points to that folder. Also, I selected 'TREX Classification' on the 'Service' drop-down while creating the index. I left the crwler profile as blank. Then I went on to create a new 'Query Based Taxonomy'. I was able to create it alright, but as soon as I click on it to add folder and the such, I get this error:
    java.lang.NoSuchMethodError
         at com.sapportals.wcm.repository.manager.taxonomy.TaxonomyNamespaceManager.getDocumentTaxRMRids(TaxonomyNamespaceManager.java:1876)
         at com.sapportals.wcm.repository.manager.taxonomy.TaxonomyNamespaceManager.getTaxonomyClassResources(TaxonomyNamespaceManager.java:1831)
         at com.sapportals.wcm.repository.manager.taxonomy.TaxonomyNamespaceManager.addChildDocuments(TaxonomyNamespaceManager.java:1942)
         at com.sapportals.wcm.repository.manager.taxonomy.TaxonomyNamespaceManager.getChildren(TaxonomyNamespaceManager.java:368)
         at com.sapportals.wcm.repository.CollectionImpl.internalGetChildren(CollectionImpl.java:966)
         at com.sapportals.wcm.repository.CollectionImpl.getChildren(CollectionImpl.java:179)
    Any help in solving this is highly apprecaited.
    We run EP6 SP2.
    I did NOT create a 'crawler profile' for this set up.
    thanks,
    Biju.

    Hi Biju,
    re. your NW'04 SP stack 4 migration intention:
    NW'04 is still in ramp-up (SP stack 4 is the current shipment bundle of it) so at the current point in time, only participating ramp-up customers can use it.
    A migration from EP6.0 SP2 to NW'04 will be possible (but not during the ramp-up phase).
    From a Knowledge Management & Collaboration perspective, we will port most of the NW'04 SP stack 4 functions to EP6.0 SP2 as well. These functions will be shipped as EP6.0 SP2 Patch 5 (planned shipment date beginning of Q4 / 2004) so for mid-term, you can also plan to stay on EP6.0 SP2 if you have no other pressing reasons for going to NW'04 (e.g. enhanced Web AS functions).
    This feature porting from NW -> EP6.0 SP2 is an 'only-once' action, however, and NetWeaver will be the release for new features in the future.
    Regards,
    Joerg

  • BEx query based on virtual cube donu00B4t display a valid List of Value (LOV)

    Hello
    I have a problem with an invalid LOV. The scenario is the following; There´s a BEx query based on a virtual cube. The query has an exit variable on caracteristic that is based on 0CALMONTH.
    At Universe Designer I simply create a connection, a universe based on this query and export.
    At Web Intelligence (also at Live Office), when I try to execute de query, the prompt to fill my exit variable display a list of value that doesn´t match with the values of the caracteristic at the cube.
    Actually, the list at the prompt starts with 01.0000 and finishes with 05.0968.
    In Universe Designer, the option to edit the list of values is not available. But I think that editing the LOV is not the correct way.
    I´ve tried creating a new query based on the DSO that is the source of the virtual cube. In this case, I had a valid list. Unfortunately, I can´t use this DSO.
    Did anyone already have this problem?

    Hi James,
    can you explain what you mean with "input length for that filed" ?
    The field in the table is varchar2(120). I coudn't found options for the List of value.
    Thanks for your response
    Carsten
    null

  • Returns PO based on Return sales order - schedule line problem

    Hi,
    We're designing a return to vendors process as the opposite of a purchasing process through a plant. So normally the process is:
    Customer places order
    We buy from the vendor (PO based on sales order)
    Goods arrive at the plant
    We deliver from plant
    The opposite process is:
    Customer wants to return
    We create return delivery
    Goods arrive at the plant (GR)
    We sent the goods to the vendor (return PO based on sales order)
    This all works, but in the second scenario the sales order gets two schedule lines instead of one. So the system confirms based on the planned delivery time instead of just based on the required delivery time. Since this is a returns process, it doesn't make any sense as we're shipping to the vendor at our convenience once the goods arrive.
    Any ideas how to resolve this? Schedule line settings have been changed to all different versions. Basically the relevant customizing is:
    item category - returns item set
    schedule line category - movement type 653, order type NB, item category 0, acct assignment category M
    Many thanks

    There are a few other places to check, but you probably have exhausted those areas.  You can turn of the availability check at the item category also especially if it is specifically for the return order.
    Sales and Distribution => Basic Functions => Availability Check and Transfer of Requirements => Availability Check => Availability check with ATP Logic => Determine Procedure for each delivery item category
    I have also run into issues with APO active and having unintended consequences on the order.  Another avenue to check if there are any customer specific code in a requirements routine or user exit.
    Jeff

  • Include Button that executes PL/SQL procedure to SQL query based region

    I would like to add two columns to a SQL query region.
    These columns would not be sourced from the query, but rather would be used to execute a PL/SQL procedure.
    For example, I would like to have a manager approve or deny adding an additional employee to the department.
    There would be one button for APPROVE. And, one button for DENY.
    The PL/SQL procedure would execute to perform the required DML based upon the selected action (either APPROVE or DENY).
    A sample output would look like this:
    <APPROVE>, <DENY>, John Doe, Accountant
    <APPROVE>, <DENY>, Jane Doe, Accountant
    Is there any way to add a button to a SQL Query based report region where that button executes a stored proc? If so, what is the basic process for doing this?
    Thanks!
    -Reid

    Is there any way to add a button to a SQL Query based report region where that button executes a stored proc? If so, what is the basic process for doing this?Conditional page item? You can associate processes with buttons on a page

Maybe you are looking for

  • Windows - Use system proxy settings not working as expected

    Hi everyone, I have a bit of an issue that I could use some help with. We currently have remote users that utilize an SSTP VPN connection to access our internal network. Once connected, those users are required to use an internal proxy server to conn

  • 32" LCD Monitor and mac mini

    I'm considering building the following home theatre set up: mac mini + EyeTV tuner + 32" LCD Monitor. I'm pretty confident the mac mini will work no stress with the EyeTV tuner. However, I don't know if I will get as much resolution (1366x768) on the

  • Using I-Tune purchases in Window Media Player

    I use Windows Media Player the central location for maitaining my music library. None of my purchases from ITunes end up in WMP, and when I try to open them with WMP, I get an incompatable file message. I am also at a loss when it comes to loading It

  • ImportSecurity.cmd  I get an error when launching

    Wed Mar 23 11:00:57 EDT 2011 :: The length of the string:: 2 Wed Mar 23 11:00:57 EDT 2011 :: USAGE : ImportSecurity.cmd [-f:<passwordFile>] "appname,user,<delimiter(SL_COMMA/SL_SPACE/SL_COLON/SL_SEMI-COLON)>,<run_silent>,<SL_CLEARALL>" Does anyone kn

  • I can't find the iTunes Store on my iPhone 4 (VZW). Help?

    I was trying to find a song on my iPhone to purchase while on the road.  I can't find my iTunes Store.  Anyone know where it could have hidden  Search on the phone couldn't find it either.