Select List value as Query variable

Hi, l have a Select List and l need to put its return value inside a query to define a column.
Select List items are "name" and "id" and l would that when l select "name" the query is:
SELECT ...
FROM ...
WHERE "TAB1"."NAME" = :VAR;
and when l select "id" the query is:
SELECT ...
FROM ...
WHERE "TAB1"."ID" = :VAR;
Is it possible to do that ??? In which way ???
(it's several hours I'm trying but without positive solution)
THANKS

Assuming there is no correlation between name and id you could have just one item say P1_SEARCH and use it like this
select ...
from tab1
where upper(name) = upper('%'||:P1_SEARCH||'%')
or id = :P1_SEARCH
That also has wildcard and is case insensitive. so if you entered smit in the search box you would find Smith or SMIT etc. The id must be an exact match.
Do try the original idea you could try creating a SQL region on a function returning a query.
declare
v_sql varchar2(1000) := '';
begin
v_sql := 'select * from tab1 ';
if v('P1_SELECT_LIST') = 'ID' then
v_sql := v_sql || where id = '|| v('VAR');
else
v_sql := v_sql || where name = '|| =v('VAR');
end if;
return v_sql;
end;

Similar Messages

  • Refresh classic report based on select list value selected

    hello,
    can anyone please help me out with this issue. I have a parameterized classic report based on a select list and I want to refresh this report whenever the select list value is changed. I am using oracle apex version 3.2. i just want to have a javascript function onchange event for the select list which refreshes my report whenever a value is selected.
    My select list item is p1_datastore
    select distinct datastore d,datastore r from my_table1 order by 1;
    My classic report query is
    select * from my_table2 where datastore = :p1_datastore order by last_updated_dt desc;
    ****************************************************thanks,
    orton

    can anyone please help me out with this issue.
    thanks,
    orton

  • Tranferring on "select list" value to another "select list" value

    We have a drill through feature in our application where the user clicks on a value on page 1 and is taken to page 2. (e.g. the user drills on EUROPE in the REGION column on page 1 and is taken to page 2 where they see a report by countries in EUROPE.)
    We also have identical SELECT LISTS on page 1 and on page 2 for REGION (EUROPE, NORTH AMERICA, ASIA). How do we program our application so that when the user clicks on EUROPE on page 1 and is taken to page 2 the value of EUROPE from the REGION SELECT LIST on page 1 is chosen in the REGION SELECT LIST on page 2?
    We tried embedding this in the url for the drill through but the REGION SELECT LIST value on page 2 didn't change.
    In the below link shouldn't the value of the REGION SELECT LIST named P2_REGION be assigned the current value of the REGION SELECT LIST called P1_REGION? (in this case 'EUROPE')
    Thanks for help on this. John Wisnieff
    f?p=&APP_ID.:102:#APP_SESSION#::::P102_PRG1_LINK:#P1CAMP_NAME#,P2_REGION:&P1_REGION

    It would be great to get quick reply on this as we have a project due soon. I just need an answer to the below question:
    In the below link shouldn't the value of the REGION SELECT LIST named P2_REGION be assigned the current value of the REGION SELECT LIST called P1_REGION? (in this case the value is 'EUROPE')
    f?p=&APP_ID.:102:#APP_SESSION#::::P102_PRG1_LINK:#P1CAMP_NAME#,P2_REGION:&P1_REGION

  • Setting current values in Multiple Select List in SQL Query based Report

    Hi,
    I have a report based on a sql query that contains a multiple select list. Unfortunately I cannot get the multiple select list to display the current values (p_value) correctly. I have created a page item, :p311_current_versions, that is set using a pre-header process and it returns a value with a colon delimited format e.g. '10.1.2.1.0:10.1.2.2.0'. Then this item is used in the sql query to set the current value (p_value) of the apex_item.select_list_from_query function. However when the table is displayed, instead of having two entries, 10.1.2.1.0 and 10.1.2.2.0 selected, it has an extra entry '10.1.2.1.0:10.1.2.2.0' selected.
    Here is my code:
    select distinct a.product, a.version from (
    select distinct
    apex_item.display_and_save(2,product)||apex_item.hidden(1,env_product_id) PRODUCT,
    APEX_ITEM.SELECT_LIST_FROM_QUERY(3,decode(product, 'HTTP Server' , :p311_current_versions, version), 'SELECT distinct version d, version r FROM ebs_tech_stack where
    product ='''||PRODUCT||'''',
    decode(PRODUCT, 'HTTP Server' ,'multiple="multiple" style="width:170px"','style="width:170px"'),
    'NO') as version
    from ebs_environment_tech_stack
    where environment_id = :p311_umgebung_id) a order by a.product
    If anyone can help me figure out how to set the current values correctly I'd be really grateful!!
    Thanks in advance,
    Jean

    Jean,
    I don't think this is possible using the apex_item package. The select_list_from_query function accepts only a single value for the second parameter.
    Scott

  • Need to use Select List value as column name

    I want to have a WHERE ? IS BETWEEN ? AND ? clause.
    I am using the PL/SQL Query returning a SQL Query as a report. This uses bind variables for items I had set on my form..... If I hardcode something like:
    'WHERE STARTDATE IS BETWEEN '||
    'TO_DATE(:P1_START,''dd-MON-YYYY HH24:MI'') AND '||
    'TO_DATE(:P2_END,''dd-MON-YYYY HH24:MI'')';
    I have no problem, but I have 2 date columns, STARTDATE and ENDDATE, and would like to use the value in a select list and not have to hardcode "STARTDATE" in there. I have not been able to do this, does anyone know how to use a bind variable as a column name? From reading some posts I think it might not be possible.

    Heather,
    You're on the right track, just glue in the column name so that it becomes part of the returned query string from the function (...'WHERE '||:COLNAME||' IS BETWEEN '|| ...).
    Note that the bind variable is not part of the returned query string, but the column name obtained from the bind variable when the function executes does become part of the query string.
    Scott

  • Refresh PL/SQL Report Region (not Page) using Select List value

    Hi,
    I've got a report region based on a 'PL/SQL function body returning a SQL query'which gets generated on selecting a value from a Select list item, The Select List action is 'Redirect and Set value' but this causes the whole page to refresh rather than just the report region. I've tried to refresh the report only using a dynamic action on the Select List item (Action now reset to  'None') but now the report is not appearing on choosing from the List. Can anyone suggest a solution that will allow me to refresh this report without refreshing the page? I am using APEX 4.2.2 and the report syntax is as follows:
    DECLARE
      v_statement VARCHAR2(500);
    BEGIN
      SELECT query_text
        INTO v_statement
       FROM sql_queries
       WHERE query_id = :P2_QUERY ;
       RETURN v_statement ;
    END ;
    where P2_QUERY is Select List Item,
    regards,
    Kevin.

    KevinFitz wrote:
    The report region being displayed is conditional on P2_QUERY item being NOT NULL. I assume the region not appearing is because the Action for the Select List Item is set to None and so P2_QUERY is always NULL.
    No, the region is not appearing because it is conditional on P2_QUERY being NOT NULL. This means that the report region never exists on the page shown in the browser, so it can't be dynamically refreshed. (Dynamic refresh doesn't evaluate region conditions, and it only re-renders the report content, not the entire region.)
    Remove the condition on the report region, check the refresh is working, then reconsider exactly what the requirements here are. If you want the region to appear only when P2_QUERY has a value, and you want it to be refreshed without submitting and re-rendering the page, then the region needs to be hidden rather than conditionally rendered, and shown via a dynamic action when P2_QUERY gets a value.
    I tried adding an additional Set Value True Action for the DA event but got an error as listed above,
    All irrelevant if Page Items to Submit on the region is used properly.

  • How to use a select list value in a PL/SQL function body returning SQLquery

    Hi Friends,
    I have a select list P6_TEST with values 'nav' anf 'jyo'. I am trying to create a report using "SQL Query (PL/SQL
    function body returning SQL query)". In my report query can i check if P6_TEST='nav' and do something like the
    code shown below.How can i do that.
    DECLARE
    v_sql VARCHAR2(3000);
    BEGIN
    IF :P6_TEST = 'nav' THEN
    v_sql :=
    'SELECT
    * from department';
    ........................Thanks,
    Nav

    Nav:
    What you have should work. Give it a go. Post back if you run into issues.
    Varad

  • Using Multi Select List in SQL Query

    Hi all,
    I am trying to using a Multi Select list for filtering of a report. I have :P2_RISK_SEVERITY which has has the possibility of values Very Low:Low:Medium:High:Very High. How do I use this Multi Select in the where section of a SQL query?
    I need to say something along the lines of:
    Select RISK_SEVERITY from TBL_RMD_RISKS where RISK_SEVERITY = (one of the options selected in the multi select)
    Thanks for the help.

    Hi there,
    The above suggestion will work perfectly as long as the table you're querying is relatively small, but keep in mind that applying the INSTR to the left side of the WHERE clause will always result in a full table scan. This means that if your table is large and RISK_SEVERITY is indexed, the index will never be used. Here is another approach (credit to AskTom) that converts your colon-delimited string of selected values to a list that can be used in an "IN(...)" clause, which will use an index on RISK_SEVERITY as long as the optimizer otherwise deems it appropriate:
    -- creates a type to hold a list of varchars
    CREATE OR REPLACE TYPE vc2_list_type as table of varchar2(4000);
    -- converts a colon-delimited string of values to a list of varchars
    CREATE OR REPLACE FUNCTION vc2_list(p_string in varchar2)
       return vc2_list_type is
       l_string       long default p_string || ':';
       l_data         vc2_list_type := vc2_list_type();
       n              pls_integer;
    begin
       loop
          exit when l_string is null;
          n := instr(l_string, ':');
          l_data.extend;
          l_data(l_data.count) := ltrim(rtrim(substr(l_string, 1, n - 1)));
          l_string := substr(l_string, n + 1);
       end loop;
       return l_data;
    end vc2_list;
    -- your WHERE clause
    where risk_severity in(
             select *
               from the(select cast(vc2_list(:P2_RISK_SEVERITY) as vc2_list_type)
                          from dual))
    ...Hope this helps,
    John

  • Using select list value as column name in SQL

    Folks,
    Thanks in advance for any help with this
    I have a select list with two values (Instance and Username) created by
    STATIC2:Username;USERNAME,Instance;INSTANCE
    I am trying to pass the value of this (:P2_SELECT) and use it as a column name in a SQL query as below
    select USERNAME,
    INSTANCE
    from table_name
    where :P2_SELECT like '%'||:P2_TEXTSEARCH||'%'
    When I substitue the :P2_SELECT for one of the values (either instance or username) this works fine
    I suspect it is due to how Application Express interprets the value of :P2_SELECT
    Any help would be much appreciated!
    Gareth

    Thanks Munky that worked a treat!
    The next hurdle I have now is that because I have changed the region type to "PL/SQL Function(returning SQL Query)" there is no longer the option to add sorting to the columns as I have had to change the Source option to "Use Generic Column Names (parse query at runtime only)"
    I will have a scout around and see how I can get around this
    Gareth

  • Get Apex Select List value

    Hello,
    I've used APEX_ITEM.SELECT_LIST_FROM_QUERY in one of my dynamically built report.
    SELECT 'Add' "Add",(SELECT APEX_ITEM.SELECT_LIST_FROM_QUERY (1,ENAME,'SELECT DISTINCT ENAME,EMPNO FROM EMP') FROM EMP WHERE ROWNUM=1) "SELECT",A.* FROM ('||OBJ_SQL||') A ORDER BY 2;
    OBJ_SQL we get from a table which contains a query. The query is different for each of the selection made in another region. Probably a select list with different countries and clicking on each country, the below dynamic report should be built. Each country will be having different columns. So we store all the countries and respective queries in a table. The report should appear as :
    Add is a link.
    Select is a select list with Employee Names.
    Some Other columns from the query corresponding to the country.
    My requirement is Whenever I click on Add link for any row, the different columns in each row should be inserted into a table. I tried using a javascript call to a function passing all the values like #COL2#,#COL3# etc. But for the select list, though I select SCOTT, the whole string (all employees are concatenated) is being sent.
    Is there a way we can pass only the selected value to the javascript function? How can we achieve this? Please help.
    The select list gets displayed perfectly.

    Hey.
    Somebody help me please.
    I have to get value from APEX_ITEM.SELECT_LIST_FROM_QUERY - column on a report.
    SELECT DISTINCT ROLE AS GET_ROLE,
    JOB AS GET_JOB,
    APEX_ITEM.SELECT_LIST_FROM_QUERY
    ( 1, '%', 'SELECT DISTINCT CODE c,
    MODE m
    FROM T2
    WHERE ROLE = ' || ROLE
    ) AS GET_CODE
    FROM T1
    WHERE AGE >30 AND
    SEX = 'M' ;
    I was trying to use javascript :
    for (var i = 0; i < selectlist_name.options.length; i++)
    if (selectlist_name.options[ i ].selected)
    result=selectlist_name.options;
    but I don't know what is the name of this APEX_ITEM.SELECT_LIST_FROM_QUERY and what "selectlist_name" must be there.

  • Using Select List value for building report

    I have an interactive report form. I have a "After Header" (LOAD) process that run sql commands that will populate a table with the data that the report needs for a given week.
    I have a Select List item that is run as a "Before Header" that gets a list of dates from a table. The dates only contain the first day of the week for the past two years. It is called "WEEK_OF" table and the column is called "WEEK_OF_DATE".
    The default value for the Select List is the first day of the current week. And then all of the first day of the week from the WEEK_OF table.
    I would like the LOAD process to use the value in the Select List. So at start up I would like the List to show the current week and report to begin with data from the current week.
    So I have tried to use the variable :WEEK_OF_DATE (Item name) as the beginning date for the report. However :WEEK_OF_DATE is null.
    Also, after I have the report displayed, I would like to select a new date from the list and have the report automatically refresh with that new data.
    Any Ideas what I am doing wrong?

    Hi Lyle,
    When setting a default value for a select list that is to be used to filter a report, I have found it best to do that using a computation, conditional on the item being NULL and running Before Header. If other computations rely on this value, then it should have the lowest sequence number to ensure that the value is available for those.
    Andy

  • Automatically update text field depending on the in select list value

    I have got 2 tables. Table A (Employee Personal Detail), Table B (Employee Academic detail). Employee no is common field between two tables).
    I have created interactive report with form on table b using in-built templates. I have added text box on form to display employee name which is stored in table A. I want to automatically display employee name depending upon value in employee no field on form. I know I can write query to get value in employee name field. It gives me error when employee no is blank. How to handle error?

    Sagar,
    For the employee name value to change according to the emp_no, your page needs to get submitted. can you use a select list with submit for emp_no? And then use the PL/SQL mentioned above to run on page submit?
    I'm not sure but I guess you can also achieve this in Ajax. May be someone expert in that could help.

  • Return all data without selecting any value in query filter

    Hi,
    I created a document with query filters(prompt, LOV). But sometimes users don't want to select any value and just want to return all data in the report.
    I can't find a way to achieve this. Does anyone know how to implement this ?
    Thanks.

    Hi,
    you can modify the "select" statement for your LOV and add an additionaly keyword like "ALL" in your list of values. Then you can modify your where-clause to handle the "ALL" keyword.
    E.g. (<your condition>=@prompt(....) or 'ALL'=@prompt(......) )
    Regards,
    Stratos

  • Dynamic Action based on Interactive Report Select List Value

    I'd like to perform a Dynamic Action when a user selects one of 3 options from a Select List within an Interactive Report:
    select APEX_ITEM.SELECT_LIST(
    p_idx => 3,
    --p_value         =>   deptno,
    p_list_values => 'Copy;Copy,Delete;Delete,Export to PDF;Export to PDF',
    --p_attributes    =>   'style="color:red;"',
    p_show_null => 'YES',
    p_null_value => NULL,
    p_null_text => '--Select--',
    --p_item_id       =>   'f03_#ROWNUM#',
    p_item_id => 'P6_IR_SELECT_LIST',
    p_item_label => 'Label for f03_#ROWNUM#',
    p_show_extra => 'YES') "Actions"
    from dual;
    When building the Dynamic Action, I chose the following values from the Advanced wizard
    Event: Select
    Selection Type: DOM Object
    DOM Object: P6_IR_SELECT_LIST
    Condition: Equal to
    Value: "Delete"
    True Action: Execute Javascript Code: Alert('Here');
    Doesn't seem to be firing...can anyone help?
    Thanks in advance,
    John

    Hi,
    I am not sure if the "equal to" condition applies to a DOM object... after all, a DOM object can be anything (any HTML element) not only a field.
    Try using a javascript expression instead, like this:
    $v('P6_IR_SELECT_LIST')=='Delete'UPDATE: Sorry, I just tested and "equal to" condition works for DOM objects... should have tested before posting!
    Luis
    Edited by: Luis Cabral on Feb 29, 2012 4:45 PM

  • Pass Select list value to URL as a parameter

    I am trying to pass the selected value from a select list via a button to a URL.
    &P_VALUE=&P_VALUE.
    P_VALUE is set to USER SESSION.
    It shows as prevous session value. If I show the the session value is not set to the selected value.
    If I call a PDF report via a button, it displays the correct value and the session values is correct.
    If I select the button for the URL again, is shows the previous value.
    When I go back to the form and call select the button again, the correct parameter is passed to the URL.
    Any Ideas?
    Thanks,
    Jerry

    If you use substitution at the time, the button gets generated, you don't have the new value - the button is generated with the rest of the page, and then later the user changes value of the select list. You have two choices:
    1)Use Select list with submit - and transfer the user to second page using branch (which get's calculated after submit when select list has already the new value)
    2)Use Javascript to catch the onChange/onClick event of SelectList, read the current value and do the redirect from JavaScript.

Maybe you are looking for

  • Problem while setting PF_status in ALV Grid Display

    Hi, i have a final internal table with first field as a check box. I have delete button on application tool-bar, with usercommand and pf status defined for it. Once the output is displayed  i should have the option of checking the line (check box) an

  • Error WHen trying to print a crystal report

    I am trying to print a system crystal report and it is giving me the following error: "Error during printing; ensure all parameters are defined". And it prints the first page, but none of the consecutive pages if there are more than 1. Is there some

  • Errors in web dynpro

    Hi ,All, There is an error occured when i use service call to program in web dynpro. that is  "Exception NO_ENTRY_FOUND that Is Not Class-Based Occurred ". can someone tell me what i should do to modify it? Thank you very much.

  • Frm-41380 error - cannot set the blocks query data source

    Fairly new forms so bare with me. I am creating a form based on one table. This table has one column that is a nested table. table name: szrtime table columns: szrtime_code, szrtime_styp_list szrtime_styp_list is a table of varchar2(1). main block is

  • Third party extension in Jdeveloper 11.1.2.0.0

    Hi All, Now Jdev 11.1.2.0.0 is supports for third party extension(PMD rules) ?. Thanks, Vass Lee.