Select List Result into Where Clause

I am trying to use a select list with redirect to choose an account and then have a report region update based upon the results of the selection. I've done this previously without any issues. I have since upgraded. In reviewing the code I am using now which is not working, and comparing it to the code from prior to the upgrade, I have not been able to find any differences. Attached is the code that I have been using for the report region. If I leave it as is I get the result set shown below the query. If I add the restricition to business area, I get no Data Found, regardless of Business Area Selected.
SELECT '<img src="#IMAGE_PREFIX#continue.gif"
border="0" alt="Selection">' Selection,
Type_ID,
Problem_Description Description,
Account_ID,
:P720_BUSINESS_AREA
FROM Problem_Types
WHERE Type_ID = NVL(:P270_PROBLEM_TIER1,0)
-- AND Account_ID = :P270_BUSINESS_AREA
UNION
SELECT '' Selection,
Type_ID,
Problem_Description Description,
Account_ID,
:P720_BUSINESS_AREA
FROM Problem_Types
WHERE Type_ID != NVL(:P270_PROBLEM_TIER1,0)
-- AND Account_ID = :P270_BUSINESS_AREA
SELECTION TYPE_ID DESCRIPTION :P720_BUSINESS_AREA
-      8 FIMS 123           
ACCOUNT_ID
123
Any help or ideas are greatly appreciated.

Thank you, I guess I needed another set of eyes. For two days I looked over that and didn't see it. I even recreated the code from scratch, but apparently built in the same bug.
Thanks again Scott

Similar Messages

  • How to insert the select query result into table?

    How to insert the select query result into table?
    SELECT  top 20 creation_time  
            ,last_execution_time 
            ,total_physical_reads
            ,total_logical_reads  
            ,total_logical_writes
            , execution_count 
            , total_worker_time
            , total_elapsed_time 
            , total_elapsed_time / execution_count avg_elapsed_time
            ,SUBSTRING(st.text, (qs.statement_start_offset/2) + 1,
             ((CASE statement_end_offset 
              WHEN -1 THEN DATALENGTH(st.text)
              ELSE qs.statement_end_offset END 
                - qs.statement_start_offset)/2) + 1) AS statement_text
    FROM sys.dm_exec_query_stats AS qs
    CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) st
    ORDER BY total_elapsed_time / execution_count DESC;
    Thanks,
    Tirumala

    1. SELECT INTO
    Below method will create table when data is inserted from one table to another table. Its useful when you need exactly same datatype as source table.
    Use AdventureWorks2008R2;
    Go
    ---Insert data using SELECT INTO
    SELECT AddressLine1, City
    INTO BothellAddresses
    FROM Person.Address
    where City = 'Bothell';
    GO
    ---VERIFY DATA
    Select AddressLine1, City
    FROM BothellAddresses
    ---DROP TABLE
    DROP TABLE BothellAddresses
    GO
    2. INSERT INTO SELECT
    Below method will need table to be created prior to inserting data. Its really useful when table is already created and you want insert data from
    another table.
    Use AdventureWorks2008R2;
    Go
    ---Create Table
    CREATE TABLE BothellAddresses (AddressLine1 NVARCHAR(60), City NVARCHAR(30))
    ---Insert into above table using SELECT
    INSERT INTO BothellAddresses(AddressLine1, City)
    SELECT AddressLine1, City
    FROM Person.Address
    where City = 'Bothell';
    ---VERIFY DATA
    Select AddressLine1, City
    FROM BothellAddresses
    ---DROP TABLE
    DROP TABLE BothellAddresses
    GO
    Regards,
    Vishal Patel
    Blog: http://vspatel.co.uk
    Site: http://lehrity.com

  • Filter not being generated into where clause

    Hi,
    I have a simple mapping that has a source table, a filter, and a target table that is set to DELETE. The source table has many rows, but the filter would narrow down these rows by a lot. When I generate the code, the cursor that gets created SELECTs the whole table then there is an IF statement that is applied to each row with the filter condition. A lot less processing would be required if the filter was implemented as a WHERE clause in the cursor, but I can't get it to generate this way. I realize that deletes automatically generate row-based code but it would still be row-based if the WHERE clause was in the cursor.
    Is there any way to get it to generate the filter as a WHERE clause in the cursor?

    Hi,
    In general, Warehouse Builder gives you a number of different operating modes:
    - set-based: which does everything in (one) SQL statement. This method is most performant, but has some limitations. Warehouse Builder today does not support set-based deletes (arguably, deletes are not the most common operation in a data warehouse).
    - row-based: which is optimal for debugging. In row-based mode, you get as many records as possible and all operations/transformations take place in PL/SQL. This option gives you most debugging capabilities.
    - row-based bulk: which is the previous method fetching rows in bulk (e.g. 100 by 100). Bulk processing speeds up the overall processing.
    - row-based target only: in this mode we push as many of the operations/transformations as possible into the query (cursor). I.e. your filter (in your case) would be implemented as a restriction on the filter.
    - row-based target only in bulk: see previous.
    Warehouse Builder's default operation is set-based fail over to row-based. I.e. because we do not support set-based delete statements, I suspect you fall back to the row-based method of execution, which is not ideal in your case. I suggest you use the row-based target only option in order to get optimal performance for your scenario.
    Note that for the deletes that are common in DW scenarios the row-based bulk deletes that we generate are often faster than set-based deletes. Also note that if you perform a complete delete (or even truncate) followed by an insert that Warehouse Builder does issue one statement for emptying the table.
    Thanks,
    Mark.

  • Pl/sql select distinct in a where clause

    Greedings,
    I am trying to execute some kind of distinct using rowid in where clause but for some reason im not getting the appropriate result. Any guidance is welcome
    SELECT acnt_code,cat,cat_desc,buc FROM so_budgets_cat where
    Trim(buc)='S03'
    and
    NOT exists (SELECT  1
                       from   so_budgets_cat tab2
                       where  (  tab2.cat     =  so_budgets_cat.cat )
                       and    tab2.ROWID  > so_budgets_cat.ROWID
    ORDER BY cat,so_budgets_cat.rowidThanks in advance

    Can you provide some example data and example output to further clarify?
    It might be that you want something like the code below, but it's hard to tell.
    SELECT acnt_code
    ,      cat
    ,      cat_desc
    ,      buc
    FROM
    (SELECT acnt_code
    ,      cat
    ,      cat_desc
    ,      buc
    ,      ROW_NUMBER() OVER (PARTITION BY cat ORDER BY <something>) rn
    FROM   so_budgets_cat
    WHERE  Trim(buc)='S03')
    WHERE rn = 1;

  • Selecting values for query where clause

    hi guys, this is possibly a silly question but not sure if i am approaching the solution in the correct mannor.
    At the top of my form i have text box which the user fills in various values. These values are then used to refine the query results in the block below. I know i can go into the datablock being queried and set the where clause to equal the value of the text boxes above but i dont feel this is the right place to do it.
    If i do it that way when the text box above is blank it returns no reults when infact i want to query everything if the values are left blank. So should i put it in pre query? if so what way should it be done?
    Any help would be greatly appreciated.
    Thanks.

    Hello,
    If i do it that way when the text box above is blank it returns no reults when infact i want to query everything if the values are left blank. So should i put it in pre query? if so what way should it be done?Not really if you use like below in block's where clause...
    db_field_name1=NVL(:form_field_name1,db_field_name1) AND
    db_field_name2=NVL(:form_field_name2,db_field_name2)-Ammad

  • Select List with a Contains clause (oracle text)

    Hi, I am trying to create a dynamic select list, but am running into problems using bind variables.
    I am trying to do this:
    select distinct country d, country r
    from table1
    where contains(:P6_LIST_VALUE,''''|| :P6_NAME||'''');
    I keep getting the error: "LOV query is invalid, a display and return value are needed, the column names need to be different...."
    If I hard code the :P6_LIST_VALUE to be 'NAME' (which is what I named my context index) it works fine:
    where contains(name, ''''||:P6_NAME||'''');
    Is there any way to get around this error?

    anonymous - Please tell us your first name.
    CONTAINS Operator
    Syntax
    CONTAINS(
    [schema.]column,
    text_query VARCHAR2
    [,label       NUMBER])
    RETURN NUMBER;
    So you can't use a bind variable for the column name, just like you can't do "SELECT :COL FROM DUAL".
    Try &P6_LIST_VALUE. (with trailing period). This effects a textual substitution before the SQL is parsed.
    Scott

  • Change JDBC select SQL query's where clause at runtime

    Hi,
    I have one JDBC sender channel with Select SQL Query which helps in fetching data from JDE table. We have defined where clause to fetch some particular records i.e. if ABC = NULL then fetch the record.. and then update query is used to turn that flag to "Y" i.e. ABC ="Y" so that next time the channel don't pick the same records again.
    Now the problem is that if we want to fetch some records again whose flag has been set to "Y" we cannot change the select query again and again in the production environment.
    Is there any way to change the select query of the JDBC channel at runtime e.g. Picking up some flat file where the conditions for the particular records to be picked are defined (ID=123) and changing the WHERE clause of select query in the JDBC channel for those records to be picked without using BPM.
    Thank you!
    With regards,
    Simran

    Hi Simran,
    Yes, it is possible with the help of store procedure. In SQL Server there is a IF-Else Conditional block, which you can use inside store procedure. Create a SP with 2 additional parameter something like FlagReadAgain and KeyField. Pass the flag always as True or False. For the Key field pass the record key which you want to read again if you are passing the Flag as True else pass it as 0 or whatever.
    In the procedure check if the value of flag is True -> If yes, Read the entry with key name specified in where part.
    In the else part put the query which you are using for the normal flow.
    IF (FlagReadAgain) = TRUE
    BEGIN
       SELECT EmpName, EmpAddress
       FROM Employee
       WHERE EmpID = 'E001'
    END
    ELSE
       BEGIN
         SELECT EmpName, EmpAddress
         FROM Employee
         WHERE Status = 'N'
       END
    You may also use the approach which Srini mentioned. Create an application to restore any value to intial stage so that it can be picked up by XI when it poll again.
    Choose any approach which you like.
    Regards,
    Jitender Chauhan

  • To_binary_double written into where clause

    We've just migrated a customer from 9i to 10gR2 and are seeing that queries that include the primary key of the table are doing a full table scan. After investigating using the v$sql_plan view I'm seeing that the access_predicates show that a simple query:
    select * from mytab where pk = :1;
    Is getting parsed as
    select * from mytab where to_binary_double(pk) = :1;
    when coming from a client using ODBC. This is obviously what is causing the full table scan so a quick fix was to building function based index on the pk column.
    My question: Is there any way to tell ODBC or Oracle not to rewrite my query? I noticed that this installation has query_rewrite = true, integrity = trusted. I don't believe there are any materialized views and other than the "stop the bleeding" function based indexes I built there aren't any other function based indexes. Would turning query_rewrite to false prevent this type of rewrite from occurring? We don't have a system right now that I can replicate this problem on and our customer is a 24/7 oltp system so I would rather not change the query_rewrite parameter without knowing it will work before I delete all my "quick fix" indexes.
    Thanks!
    Tina

    I know we have a test system in house that represents this basic configuration (which would be representative of a lot of customers, not just this one) and to my knowledge we have not seen this problem. I'll have to check the amount of data we have in our test system vs. the amount of data this customer has. It could be that the symptom didn't appear because of smaller table sizes. I'll check the v$sql_plan on the test system to make sure it's not really happening but just not noticed. Certainly a full table scan on a table with 1k rows might be overlooked but with a million rows would become evident. Again, I'm new to this group so I'll also check to see if these things have already been looked into.
    I've been doing some reading on ODBC and found a convert function that looks like, if used on the application side, it might cause Oracle to include this to_binary_double function into the parsed sql. Would you agree that usage of convert might cause this?
    Here's the link:
    http://msdn2.microsoft.com/en-us/library/ms715381.aspx
    Let me know if I'm way off in the weeds with this convert function.
    Tina

  • Use of CS operator in SELECT... WHERE clause not allowed

    Hi all gurus,
    quite a dumb question, but since I'm facing the issue... I need to access a standard DB table with some selection criteria , in particular I'd like to extract all the entries where the field NAME contains a specific substring.
    Since the CS operator seems not to be supported as far as the compiler tells, what's the best (efficient/effective) way to perform such a task?
    Thanks,
    M.

    Keshav.T wrote:
    Range table
    Thanks Keshav, I hoped there's an alternative way to do that without using range structures/tables... and also, to overcome the case sensitive problem.
    I'd go for that if no alternative arise.

  • Select query results into excel file

    Hi,
    I want to put the results of a select query in an csv file(tab separated columns). I dont want to spool command for this . Is there any other method to do this.
    Thanks

    To get data from oracle to excel to use odbc driver to achive this.

  • Ora-07445 When tried to select a view using where clause it got disconnectd

    select * from v_my_view;
    plan group_name plan_id
    plan_one group_one 101
    1 row selected.
    when I tried
    select * from v_my_view where plan_id='101';
    It got disconnected and show to end of communication error
    Current verson of database I am working with is 10.2.0.1.0
    Please help, niether i have metalink access nor I have any patch to install.
    Thanks and Regards in advance,

    First don't create Multiple thread I guess you created 3 thread for the same problem.
    Coming back to your problem did you check your Alert log, is your server running in shared/Dedicated mode whats your OS.

  • The mechanics of the WHERE clause

    I’ve been out in industry for over 10 years now doing DB work most of that time. Lately I’ve been doing some work that is starting to challenge my long held assumptions about the internal workings of SQL Server, specifically what exactly is happening when
    I do joins and where clauses.
    I was explaining to someone that when doing a join putting in a where clause limits the amount of records that are available to do the join on thereby making the query faster. My thought was if a table has 100MM records but only 50MM of those meet the WHERE
    criteria then the JOIN clause wouldn’t try matching the 50MM records that don’t meet the WHERE clause.
    I did some work that afternoon and the empirical results didn’t match the expected outcome of a query I had written in terms of execution time. I don’t think my understanding of what goes on during a JOIN is correct. Can someone educate me?

    Here is how a SELECT works in SQL ... at least in theory.  Real products will optimize things, but the code has to produce the same results. 
     a) Effectively materialize the CTEs in the optional WITH clause. CTE's come into existence in the order they are declared so only backward references are
    alllowed. A CTE can be recursive. Think of them as VIEWs that exist only in the scope of the query. In practice, if they are used once then they are implemented as an in-line macro.
     b) Start in the FROM clause and build a working table from all of the joins, unions, intersections, and whatever other table constructors are there.  The <table expression> AS <correlation name> option allows you give a name to this working
    table which you then have to use for the rest of the containing query.  Ther are UNIONB, INTERSECT and EXCEPT set construtors, LATERAL tables, table-valued funcitosn and all kinds of things happening in here. 
     c) Go to the WHERE clause and remove rows that do not pass criteria; that is, that do not test to TRUE (i.e. reject UNKNOWN and FALSE).  The WHERE clause is applied to the working set in the FROM clause.  
     d) Go to the optional GROUP BY clause, partiton the original table into groups and reduce each grouping to a *single* row, replacing the original working table with the new grouped table. The rows of a grouped table must be only group characteristics:
    (1) a grouping column (2) a statistic about the group (i.e. aggregate functions) (3) a function or constant(4) an expression made up of only those three items.  The original table no longer exists and you cannot reference anything in it (this was an error
    in early Sybase products).  
     e) Go to the optional HAVING clause and apply it against the grouped working table; if there was no GROUP BY clause, treat the entire table as one group. 
     f) Go to the SELECT clause and construct the expressions in the list. This means that the scalar subqueries, function calls and expressions in the SELECT are done after all the other clauses are done.  The AS operator can also give names to expressions
    in the SELECT list.  These new names come into existence all at once, but after the WHERE clause, GROUP BY clause and HAVING clause have been executed; you cannot use them in the SELECT list or the WHERE clause for that reason. 
    If there is a SELECT DISTINCT, then redundant duplicate rows are removed.  For purposes of defining a duplicate row, NULLs are treated as matching (just like in the GROUP BY).  
     g) Nested query expressions follow the usual scoping rules you would expect from a block structured language like C, Pascal, Algol, etc.  Namely, the innermost queries can reference columns and tables in the queries in which they are contained.  
     h) The ORDER BY clause is part of a cursor, not a query. The result set is passed to the cursor, which can only see the names in the SELECT clause list, and the sorting is done there.  The ORDER BY clause cannot have expression in it, or references
    to other columns because the result set has been converted into a sequential file structure and that is what is being sorted.  
    As you can see, things happen "all at once" in SQL, not "from left to right" as they would in a sequential file/procedural language model. In those languages, these two statements produce different results:
      READ (a, b, c) FROM File_X;
      READ (c, a, b) FROM File_X;
    while these two statements return the same data:
    SELECT a, b, c FROM Table_X;
    SELECT c, a, b FROM Table_X;
    Think about what a confused mess this statement is in the SQL model.
    SELECT f(c2) AS c1, f(c1) AS c2 FROM Foobar;
    That is why such nonsense is illegal syntax.
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Issue in select query with where clause

    Hi guys,
    I'm facing an issue while using select query with the where clause. When I'm selecting all the data from the table it returns the correct result. But when I'm using the where clause to get the specific rows from the table it returns no rows. But the data I'm trying to fetch using the where condition exists in the table.
    Here is my query which causing the issue,
    select * from mytable where myfield = 'myvalue'
    But if I use the following query it returns the result correctly.
    select * from mytable
    Also the myfield value 'myvalue' exists in the table.
    I have tried by running this query in both SQL Developer and SQL Plus. I have tried this query in mssql as well. It works perfectly and returns correct result sets for both the queries I have mentioned above. I'm unable to predict the issue as I'm new to ORACLE. Please help.
    Thanks,
    Ram.

    Hi Ram,
    I experienced an issue similar to this with a varchar2 field. Some of our records had a hidden newline character at the end of them, which was making queries like the one below fail:
    select * from employees
    where email = '[email protected]'The best way I found to detect this was to use
    select 'XX'||email||'XX' from employeesTo make sure that there were no newlines. But that is just a guess. If you could provide some example table data and the outputs of your selects, it would be helpful.
    Jeff

  • SELECT WHERE clause

    Hi,
    I'm working with Oracle JDeveloper 9.0.5.2 with ADF.
    I have a data page in FindMode. Into the jsp related to this data page, I have some attributes where I could set some values before executing a query on a view object.
    My question is:
    Is it exist a way, at run time, to capture the select string including the WHERE clause just indicated in the jsp page ?
    For example:
    if, into the text box related to "Attribute1", I indicate "abc" and, into the text box related to "Attribute2", I indicate "5", how can I get the WHERE string "Attribute1 LIKE 'abc' AND Attribute2 = 5" ?
    Thanks in advance.
    Kind Regards.
    Massimo

    Dear Brenden Anstey,
    thanks for your prompt reply.
    But, unfortunately, your suggestion does not resolve my problem.
    I'll try to explain better what I want:
    I have a Struts Data Page. The related jsp page is in the Find mode because I have to use it to insert some values for some attributes and just after to choose a submit button in order to execute a query from a view object that respects the values above inserted.
    1) Into my jsp I have the following attributes:
    - “Attribute1” (type: VARCHAR2)
    - “Attribute2” (type: NUMBER)
    2) I insert the following values:
    - “string1” for “Attribute1”
    - “123” for “Attribute2”
    3) Then, I choose the submit button to excute the query on the view object.
    Now, I need to know what is the SQL string that ADF builds at run time to excute the query and to get a records data set from a view object. In the above example, the SQL string should be:
    SELECT * FROM ViewObjectName WHERE Attribute1 LIKE ‘string1’ AND Attribute2 = 123
    I think it should be possible to obtain this, because if, for example, I indicate “a” for the numeric attribute “Attribute2”, it appears a jsp with an error message like this:
    JBO-27122: SQL error during statement preparation. Statement: SELECT * FROM ViewObjectName WHERE ( ( (Attribute2 = a) ) )
    So, it means that the SQL string has to be been registred somewhere.
    Could anyone help me ????
    Thanks in advance
    Best Regards.
    Massimo

  • Does the 'default where clause' query select the ROWID by default ?

    Hi ,
    The query in default where property of a data block is as follows:
    global.prim_lang = :global.user_lang
    and upper(group_name) like upper('%' || :B_apply_inclusions.TI_group_desc || '%')
    UNION ALL
    select g.rowid, g.group_no
    from table1 t,
    table 2 g
    where :global.prim_lang != :global.user_lang
    and upper(g.group_name) = t.key(+)
    and :global.user_lang = t.lang(+)
    and upper(nvl(t.translated_value, g.group_name)) like upper('%' || :B_apply_inclusions.TI_group_desc || '%')
    The g.rowid was added in the UNIONALL portion of the query because the first part of the query was bringing rowid as well.
    We are in 10.1.2.3.0 forms version.
    However for a user in forms verion 10.1.2.0.2, the query is giving an error " Unable to perform query " - due to mismatch in the number of columns selected in the query union.
    because for this user, rowid is not selected as part of default where clause query( 1st part of the query before the unionalll).
    If g.rowid is removed from the 2nd part of the query , it errors out in 10.1.2.3.0 forms version.
    Could you kindly clarify when this rowid will also be selected by the default where clause of a block and why this issue is occuring?Is this issue related to forms version or any other property of the block? Is it is version based, is there a patch available to deal with the same?
    Thanks in Advance.

    You normally change the default_where block property just when you want to chnage the filter conditions for what is selected from a given block data source.
    Querries with union or minus will confuse forms as to the rowid and will no longer be albe to perform the default insert/update/delete, not knowing the rowid and the table to perform the dml on.
    A from clause query will be the best way to change dynamically the tables you select from and also the where. But, by using that, if you wish to insert/update/delete, you will have to use on-insert/update/delete triggers where the processing will have to rely on some primary key columns and not on rowid.
    Or, instead of a from-clause, you may use a view, but that will definitely be less flexible than a from clause query.

Maybe you are looking for

  • LibreOffice can't open files with spaces in the name

    Hi, so I recently installed LibreOffice (from extra) over go-OO. I know the site says it's not for production use but I have heard good things about the stability of the current version so I decided to see if it was in a usable state. In general thin

  • Request suggestions for PDF printing of forms such as paychecks, W2's

    This question is on two levels. I see this as an up and coming project at work, and even there I doubt we will be purchasing BI Publisher as we are in cutback mode. More inportantly, for my own clients who want an application on the cheap. I have see

  • Error code: -107380720​2

    Hi      I am getting the error code -1073807202 when I am controlling HP make 8656B signal generator.can any one sort out this problem. Regards RobinHood Solved! Go to Solution.

  • ITS access with users not defined as dialog users

    Hello , We have a requirement so that the users accessing HR Machine are restricted and only few of them are defined as dialog users . For the users defined as comunication users in the R3 core , we are now installing ESS - MSS services . The ITS is

  • Disk full error message?

    stuff, this site has issues. Okay, what I need to know is why I am getting a "disk full" error message when I try to save photos. This has only started to happen and my disk drives have plenty of space left on them.