IN CLAUSE query

My report query has IN CLAUSE which takes parameter like 1,2,16,17 when i run the report with this parameter it gives me an error ORA-01722 Invalid Number. How can i resolve it.

which takes parameter like 1,2,16,17That parameter is a char parameter, not a number parameter (1,2,16,17 is not a number).
So, your query is trying to do this:
select ...
from ...
where num_column in ('1,2,16,17')You can solve this with a lexical parameter.
select ...
from ...
&p_whereIn the after parameter form trigger you set the lexical, but you have to do some plsql coding to split the parameter in individual numbers first.

Similar Messages

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

  • WITH Clause query doesn't work in Oracle Reports.

    Hi Gurus,
    I'm using a WITH clause query and need to build a report using the same query.
    But when i'm trying to build a report, query is giving error as "WITH clause table or view doesn't exists".
    But the same query perfectly works in sql prompt.
    Oracle Reports doesn't supports WITH clause query?
    Please suggest.
    Thanks,
    Onkar

    I ran into a similar problem before and worked around it by moving the query to a pipelined function in the database as described at WITH clause unexpectedly causes ORA-00942 in Reports Builder
    Hope this helps.

  • How to use "with clause query" in DBadapter

    Hi all,
    I need to implement a "with clause" query in oracle soa 11g bpel. When i put the query in db adapter in pure sql, the schema is not getting generated properly. Can any one suggest a solution to my problem.
    Regards,
    Kaushik

    Pure SQL won't work because it is expecting the first word in the SQL to be SELECT (or INSERT,UPDATE,DELETE).
    If your query is WITH ... SELECT ...
    try this:
    delete everything before SELECT. Copy and paste the generated XSD to another window. The SQL test may fail, but that will just mean that it couldn't fill in the types of the columns in the SELECT ... FROM list. You can always do that yourself by hand editing the XSD (including in the wizard before you hit next). Then put back the WITH ... clause before the remaining SELECT .... If the XSD gets overwritten, copy the version you saved in the other window and paste it over top. Then hit next and the runtime should still work.
    Keep in mind that SQL is very complex and hard to fully parse in the UI. However the minimum information the DbAdapter needs is quite limited; basically just the name and number of columns that are coming back. The XSD is meant to be editable in the wizard if the SQL is too complex.
    Thanks
    Steve

  • Using FROM clause query in block

    I have a block using a FROM clause query instead of a table. I have two items in the block that correspond to the select statement. Here's the SQL statement I've entered:
    SELECT BEZEICHNUNG, ZEIT_TYP_NR
    FROM ZEIT_TYPE
    WHERE ZEIT_TYP_NR IN
    (SELECT ZEIT_TYP_NR
    FROM PROM_ZEIT_TYP
    WHERE PROM_TYP_NR = :GLOBAL.PROM_TYP_NR)
    When I run forms, it ADDS to my SQL statement!! Here's what it does:
    SELECT BEZEICHNUNG,ZEIT_TYP_NR
    FROM (SELECT BEZEICHNUNG, ZEIT_TYP_NR FROM ZEIT_TYPE) WHERE ZEIT_TYP_NR IN
    (SELECT ZEIT_TYP_NR
    FROM PROM_ZEIT_TYP
    WHERE PROM_TYP_NR = :1)
    can anyone tell me why it's adding this first line to my select statement??

    "a from clause query" is the rather strange name forms uses for what is generally known as in an in-line view.
    Your in-line view is being treated by forms the same way as it would a table, it sticks a SELECT, a list of columns determined from the database items in the block and a FROM on the beginning. If the user specifies query criteria in enter-query mode it will quite correctly apply the where clause to the outer select rather than to the in-line view.

  • From Clause query with form variables

    forms 9.0.4 rdbms 9.2
    Is it possible to create a From Clause query with form variables generated from another block (but in the same form)? I am not having any success.
    I searched Metalink. It appears that according to DOC ID # 69884.1, in Forms 6i, this is not possible. Metalink suggest in DOC ID 104771.1 implementating a dynamic From Clause, but when I duplicate the example on my system, I receive an Oracle error. Further investigation from the web form (DISPLAY ERROR) indicates that the system does not see the dynamic value.
    Has anyone else run into this error? Has this been fixed in forms 9.0.4 and I am just missing something? Does a dynamic from clause query work? Can anyone point me to an example or post an example or offer any advise.
    thanks in advance

    As far as I know it is not possible to use block items in a from clause query in forms 9.0.4. Here is my solution for a From-Clause-Query via the 'Query-Data-Source-Name-Property':
    To use the values of the block items in my from clause query I implemented a database package with getter and setter routines for the block item values I needed for the query.
    In the Key-Exeqry-Trigger of the From-Clause-Query-Block I set the global package variables with values of the block-items I am interested in. In the From-Clause-Query I used the values in the where-clause via package functions which return the global package variables.
    Hope my solution will work for your problem.

  • SET_BLOCK_PROPERTY('QUERY_DATA_SOURCE_NAME') with FROM clause query data block

    Two block :
    - Block A based on table
    - Block B based on FROM clause query
    In WHEN-NEW-RECORD-INSTANCE of block A, I perform a SET_BLOCK_PROPERTY('BLOCK_B','QUERY_DATA_SOURCE_NAME','(...)'); and then query block B (... depends on value taken by 'code' column in block A).
    At runtime it works till 'code' does not change (query_data_source_name does not change) but when I navigate to a record having a different 'code', it got the folowing message :
    41380 - Cannot set the blocks query data source.
    Any idea or suggestion ?

    Hello all i m trying dynamically change query_data_source_name but its not working.
    i did the followings
    Forms(10g2) block level:Query_data_source_type
    Query_data_source_name:SELECT 1,2,3,4,5 FROM dual;
    in control Block:
    when_button_press my code is
    GO_BLOCK('blk_query');
    Clear_Block(No_Validate);
    set_block_property('blk_query',query_data_source_name,
    'SELECT col1,col2,col3,col4,col5 FROM mytable');
    execute_query;
    same result:unable to query error.
    any one can help me regarding this issue.

  • Master detail with from clause query

    Hi!
    I have 2 blocks: master and detail. The master block is based on a from clause query. Since I have to insert, update and delete on this block I have created the on-insert, on-update, on-delete and on-lock triggers (and the respective procedures).
    In this block I have on-populate-details and pre-delete triggers created by the master-detail relation.
    Now I have a problem!
    Since I only want to commit to db when I click the "ok" button and I want to insert and delete records from these 2 blocks, when I insert records into the detail block (and master too), it forces me to save changes if I change the focus of the current record of de master block to another record within the same block.
    How can I do this in order to insert records saving changes only when I click the button?
    Thanks!
    Ana

    I think that it is intended behaviour: when detail records are populated and there are uncommited changes so Forms asks if user wants to save changes.

  • FROM CLAUSE QUERY, how to construct?

    Have always used the data block wizard so am probably missing something quiet simple. I have created a new form and am manually creating a simple test block. What i've done so far:
    Block Properties
    Database Data block: No
    Enforce Primary Key: Yes
    Query allowed: Yes
    Query data source type: FROM clause query
    Query data source name: select department_id, department_name from departments
    Query data source columns: department_id (number), department_name (varchar2)
    Created a canvas with and put two items, department_id (set as Primary key) and department_name on it.
    When i run the form i get... FRM-41003 This function cannot be performed here.
    What am i doing wrong and what steps should i be taking?
    Gus
    Oracle 10g

    first of all you should set the DATABASE DATA BLOCK property to YES, not NO.
    it is a database block though not based on a TABLE, rather on a FROM CLAUSE QUERY, but it is a database block.
    another thing, when you run the form, what function you are trying to perform when you get the error: "FRM-41003 This function cannot be performed here."
    i guess you are trying to query the data. if its same, then that should be resolved once you set the DATABASE DATA BLOCK to YES.

  • From Clause Query

    Designer Version 6.5.95.4.8
    Configuration: 4.0.12
    Release 4.10
    Database 10g
    Forms [32 Bit] Version 6.0.8.25.2 (Production)
    Can someone help me with From Clause query in Designer?
    Designer Help files do not seem to cover this in depth.
    Here is what I did so far.
    1. Created module component
    2. Set Datasource Type to Query
    3. Code to set the query at run time:
          GO_BLOCK('LINK_DTL');
          CLEAR_BLOCK(NO_VALIDATE);
          vFromClauseQuery := '(SELECT DISTINCT p_code, e_code '||
                               'FROM code_table '||
                               'WHERE L_YEAR = '||:LINK.l_year||' AND L_SEQ = '''||:LINK.l_seq||''')';
          SET_BLOCK_PROPERTY('LINK_DTL',QUERY_DATA_SOURCE_NAME,vFromClauseQuery);
          DO_QUERY;   
    Also I created unbound columns :p_code and :e_code for the block, to receive the results from the query (is that the correct way to do it?)
    When I run the form, my block is empty, and if I open the form in form builder, the block that I had set to have datasource of "query" has datasource type of "table" ???
    Thanks

    Bind variables cannot be referenced in from clause query (this is a bug/enhancement 767062).
    But, in PRE-QUERY trigger we can write built-in
    SET_BLOCK_PROPERTY (block_name, QUERY_DATA_SOURCE_NAME, value);
    For example:
    DECLARE
    l_deptno dept.deptno%TYPE := 50;
    l_from_clause VARCHAR2 (1000);
    BEGIN
    l_from_clause :=
    '(SELECT deptno, dname, loc FROM dept WHERE deptno < ' || l_deptno || ')';
    SET_BLOCK_PROPERTY (:SYSTEM.TRIGGER_BLOCK, QUERY_DATA_SOURCE_NAME, l_from_clause);
    END;
    Regards,
    Zlatko Sirotic

  • FROM Clause Query and Invisible records :(

    HI:
    My form has a block based on a FROM clause query (QUERY DATA SOURCE TYPE).
    This works fine with no errors. Count hits suggests that it is retrieving records but my Item is not displaying the records. I have nine records in total but all fields are blank even though I can 'scroll' through the nine (invisible) records.
    Strange, any ideas people ?
    thanks.
    N.

    Thanks you for the reply but its not the cause of the 'probem'. My items are in a multi record block ( I have tried single item bock / No Items displayed 1 etc..) but to no avail.
    The strange thing about it is that I can Message(:blk.item) and the value displays on the Message bar but there are no values displayed in the Canvas Item at runtime ????? Very strange or does someone know something I dont.
    I can even scroll to the end of the record set ( 9 recs).
    I have never caome across this before has anyone else ?
    Thanks
    N.

  • From clause query works ok in form designer,  gets an ORA-01422 ran on web

    I am using forms 6i patch 9 with 10g database.
    I have two ‘FROM clause queries’ fired via a block/key-exeqry trigger in a if/elsif.
    The first/top SET BLOCK PROPERTY works perfect and populates the block.
    But the bottom/second SET BLOCK PROPERTY select (after the elsif)
    Is also based on a user entered field value and generates a ora-01422 error.
    The problem is that both top and bottom set block properties
    work fine when ran in forms designer,
    But when I compile it on the app_server and run the web version
    1. the top all ‘FROM clause query’ works fine
    2. the bottom ‘FROM clause query’ works fine if only one record to return.
    3. the bottom ‘FROM clause query’: gets the ora-01422 if > 1 record to return.
    FRM-40735: KEY–EXEQRY trigger raised unhandled exception ORA-01422
    The ORA-01422: ‘Exact fetch returned more than the exact number of rows’.
    Both set block property selects ‘share’ a block property/where clause of FAC_ID = :FACILITIES.ID
    The entered value in the entry field should populate 1 to many associated records
    in the bottom (elsif) set block property (and does so correctly when ran in forms designer)
    The block’s key-exeqry code:
    –-query all records associated with fac_id only
    if (:emission_stacks.stack_id_num is null) then
         SET_BLOCK_PROPERTY('EMISSION_STACKS',QUERY_DATA_SOURCE_NAME,
         '(SELECT C.ID, A.ID EP_ID,A.FAC_ID,A.NUM,A.DESCRIPTION,C.PARENT_MODE_ID,
    C.STACK_ID, C.CAPTURE_PERCENT, C.CAPTURE_METHOD, C.DATE_TESTED
    FROM EMISSION_POINTS A,
    EP_MODES B,
    CAPTURING_DEVICES C
    WHERE A.ID = B.EP_ID AND
    B.ID = C.PARENT_MODE_ID AND
    C.CD_ID IS NULL AND
    C.PARENT_MODE_ID IS NOT NULL AND
    C.STACK_ID IS NOT NULL)');
    EXECUTE_QUERY;
    elsif
    (:emission_stacks.stack_id_num is not null) then
    –-(query all records associated with fac_id and the entry field value)
    SET_BLOCK_PROPERTY('EMISSION_STACKS',QUERY_DATA_SOURCE_NAME,
         '(SELECT C.ID, A.ID EP_ID, A.FAC_ID, A.NUM, A.DESCRIPTION, C.PARENT_MODE_ID,
    C.STACK_ID, C.CAPTURE_PERCENT, C.CAPTURE_METHOD, C.DATE_TESTED
    FROM EMISSION_POINTS A,
    EP_MODES B,
    CAPTURING_DEVICES C,
    STACKS S
    WHERE A.ID = B.EP_ID AND
    B.ID = C.PARENT_MODE_ID AND
    C.STACK_ID = S.ID AND
    C.CD_ID IS NULL AND
    C.PARENT_MODE_ID IS NOT NULL AND
    C.STACK_ID IS NOT NULL AND
    S.NUM = '''||:emission_stacks.stack_id_num||''')');
    EXECUTE_QUERY;
    ** I have multiple database items in the block.
    Data block properties:
    Database/
    Data Base Block = Yes
    Query Allowed= Yes
    Is there a way to overcome the ora-01422?
    And populate the block with multiple rows(records)?
    Any suggestions appreciated.

    Sorry, false alarm, I made a mistake
    the form is working fine the way it should,
    without error. (No ora-01422 errror is occurring now.)
    I just got a new version of humming bird,
    which I used to compile the form with
    and did not have the binary switch on:
    --long story short, a new fmx was not created
    and I was not seeing the current version of screen
    at runtime.
    Thank you.

  • Block based on "From clause query" and substitution variable

    Hi Folks,
    I have a "From clause query" block type, which is based on query that uses a substitution variable (:BLOCK.COLUMN) from previous block. When I run a query, then I obtain an error: ORA-01008: not all variables bound.
    My query looks like:
    select seq_no, prod_code, descr, curr_code,
           max(decode(sched_type_code,'ROLLOVER',amt,0)) OUTSTD_DRAW,
           max(decode(sched_type_code,'INTCHG',amt,decode(sched_type_code,'FEEREC',amt,0))) OUTSTD_INTEREST_FEE
    from
        select r.fac_no, r.prod_code, f.descr, r.prod_seq_no seq_no, r.curr_code, r.sched_type_code,sum(nvl(rep_amt,0)) amt
          from repay_scheds r,
               fac_prods f
         where r.fac_no = f.fac_no
           and r.prod_code = f.prd_code
           and r.prod_seq_no = f.seq_no
           and r.fac_no = :B2.FAC_NO
           and r.trans_ref_from is not null
           and r.status         <> 'P'
        group by r.fac_no, r.prod_code, f.descr, r.prod_seq_no, r.curr_code, r.sched_type_code 
    group by seq_no, prod_code, descr, curr_code
    having max(decode(sched_type_code,'ROLLOVER',amt,0)) >0 or max(decode(sched_type_code,'INTCHG',amt,decode(sched_type_code,'FEEREC',amt,0))) > 0Once I replace that substitution variable in query condition with some exact test number then it works fine.
    select seq_no, prod_code, descr, curr_code,
           max(decode(sched_type_code,'ROLLOVER',amt,0)) OUTSTD_DRAW,
           max(decode(sched_type_code,'INTCHG',amt,decode(sched_type_code,'FEEREC',amt,0))) OUTSTD_INTEREST_FEE
    from
        select r.fac_no, r.prod_code, f.descr, r.prod_seq_no seq_no, r.curr_code, r.sched_type_code,sum(nvl(rep_amt,0)) amt
          from repay_scheds r,
               fac_prods f
         where r.fac_no = f.fac_no
           and r.prod_code = f.prd_code
           and r.prod_seq_no = f.seq_no
           and r.fac_no = 2012500
           and r.trans_ref_from is not null
           and r.status         <> 'P'
        group by r.fac_no, r.prod_code, f.descr, r.prod_seq_no, r.curr_code, r.sched_type_code 
    group by seq_no, prod_code, descr, curr_code
    having max(decode(sched_type_code,'ROLLOVER',amt,0)) >0 or max(decode(sched_type_code,'INTCHG',amt,decode(sched_type_code,'FEEREC',amt,0))) > 0How can I use substitution variable within query for "From clause query" block type? Or any other way how to get the same result?
    Thanks for your reply.
    Tomas

    I have a solution:
    Before entering block I'm calling function, that populates my block:
    PROCEDURE POP_<<MY_BLOCK>>_BLOCK IS
      query_txt varchar2(2000);
    BEGIN
       query_txt := '(select seq_no, prod_code, descr, curr_code,
                            max(decode(sched_type_code,''ROLLOVER'',amt,0)) OUTSTD_DRAW,
                            max(decode(sched_type_code,''INTCHG'',amt,decode(sched_type_code,''FEEREC'',amt,0))) OUTSTD_INTEREST_FEE
                                                  from
                                                     select r.fac_no, r.prod_code, f.descr, r.prod_seq_no seq_no, r.curr_code, r.sched_type_code,sum(nvl(rep_amt,0)) amt
                                                       from repay_scheds r,
                                                            fac_prods f
                                                      where r.fac_no = f.fac_no
                                                        and r.prod_code = f.prd_code
                                                        and r.prod_seq_no = f.seq_no
                                                        and r.fac_no = '||:B2.FAC_NO||'
                                                        and r.trans_ref_from is not null
                                                        and r.status         <> ''P''
                                                     group by r.fac_no, r.prod_code, f.descr, r.prod_seq_no, r.curr_code, r.sched_type_code 
                                                 group by seq_no, prod_code, descr, curr_code
                                                 having max(decode(sched_type_code,''ROLLOVER'',amt,0)) >0 or max(decode(sched_type_code,''INTCHG'',amt,decode(sched_type_code,''FEEREC'',amt,0))) > 0)';
       Go_Block('<<MY_BLOCK>>' );
       Clear_Block ;
       Set_Block_Property( '<<MY_BLOCK>>', QUERY_DATA_SOURCE_NAME, query_txt) ;
       -- populate my  block --
       Execute_Query ;
    END;Thanks,
    Tomas

  • Block based on from clause query

    Hi all...
    I am using forms 10g .....
    When I wanted block based on from clause query...
    I used this query ( SELECT * FROM exit INNER JOIN enter ON exit.ent_num = enter.ent_num where enter.depart=1)...
    When I run form .....
    frm-40505 oracle error unable to perform query
    Thank you
    Edited by: osa3_12 on Dec 10, 2009 4:33 AM

    hi
    try something like this.
      1* select empno,ename from emp where empno=empno order by 1
    SQL> /
         EMPNO ENAME
          7000 Sarah
          7369 SMITH
          7499 ALLEN
          7521 WARD
          7566 JONES
          7654 MARTIN
          7698 BLAKE
          7782 CLARK
          7788 SCOTT
          7839 KING
          7844 TURNER
         EMPNO ENAME
          7876 ADAMS
          7900 JAMES
          7902 FORD
          7934 MILLER
          8898 Sheela
    16 rows selected.
      1* select empno,ename from emp where empno=7000
    SQL> /
         EMPNO ENAME
          7000 Sarah
    SQL> sarah

  • Form blows up when clicked in data block using a FROM clause query

    Hi,
    I have a form that has two blocks. The detail block is based on a "FROM query clause" in the 'Query Data Source Type' in the block Properties.
    I have a simple select in the 'Query Data Source Name'.
    I made sure the select is enclosed in parenthesis and the alias names in the SELECT are the same as the ITEMS defined in the block
    The data needs to be displayed in a tabular fashion.
    When I run the form, the data is displayed correctly..but when I click the mouse on any item of this block or try to scroll down, everything just blows up and it closes my form.
    I have made sure both blocks have the same properties. But, this seems to happen no matter what.
    Any help in regard is greatly appreciated.
    Thanks much,
    Vijji

    This is how I set the relationship for the detail block say BLOCK2.
    1. I first do this:
    Database Data Block = YES
    Query Allowed = YES
    Query Data Source Type = FROM clause query Query Data Source Name = ( select jio.order_header_id order_header_id, jii.item_code item_code, SUM(jii.item_qty) item_qty from joe_indv_items jii, joe_indv_orders jio where jii.indv_order_id = jio.indv_order_id group by jio.order_header_id, jii.item_code )
    The master and detail need to be tied by the order_header_id which I can get from the header block.
    2. In the WHEN-NEW_BLOCK-INSTANCE trigger for BLOCK2, I wrote the following where I dynamically pass the order_header_id:
    DECLARE
    q varchar2(1000);
    BEGIN
         q := '(SELECT jio.order_header_id order_header_id,
         jii.item_code item_code,
         SUM(jii.item_qty) item_qty
         FROM joe_indv_items jii, joe_indv_orders jio
         WHERE jio.order_header_id = ' || :HEADERS.order_header_id||'
         AND jii.indv_order_id = jio.indv_order_id
         GROUP BY jio.order_header_id, jii.item_code )';
         CLEAR_BLOCK;
    SET_BLOCK_PROPERTY('BLOCK1', QUERY_DATA_SOURCE_NAME, q);
    EXECUTE_QUERY;
    END;
    I am not sure if I should write the exact select statement in the Query Data Source Name or not.
    Please advice.
    Thanks much,
    Vijji

  • KEY-EXEQRY trigger and FROM CLAUSE QUERY problem

    Hi,
    I have a form designed in Oracle Forms6i. I have two block on it, BlockA and BlockB.
    When BlockA is queried with some data to search, I need to build the FROM CLAUSE QUERY for BlockB. It uses the same WHERE condition as I used to search BlockA.
    I am building the FROM CLAUSE QUERY and executing query for BlockB on KEY-EXEQRY trigger of BlockA.
    It works fine, if first time, I query the BlockA without any specific data. But it gives me error 'ORA-01008: not all variables bound' if I query the BlockA with specific data very first time.
    Please advise.
    Thanx
    Zaaf

    No, I am not using any substitution variables. To get the LAST_QUERY for BlockA, I am using Get_Block_Property.
    But now I switched it to :system.LAST_QUERY and it worked.
    Thank you!

Maybe you are looking for