Where clause in Data Block

I'm running Forms 6i client/server.
I have defined a where clause in the Property Palette for a Data Block.
What I like to do is to extend the where clause with a subquery, but
how can this be done? I mean, should I put the code in a trigger, which trigger?
Regards
Roar

simple where clause with sub_query
My block has name is dc_gmod. In the where pallete I put the text (and the all is work good!!!):
exists
select 1 from ttt.xxxxx_table v
where (dc_gmod.cd_gmod = v.cd_gmod)
and
(instr(:fst.tmp_nm,cd_place,1) > 0
or
cd_place IN
(select U_UNIT from ttt.xxxxxxxxx_tabe
where RG_U = :QA.RG_UNIT_RUN
AND SID = :QA.SID
AND SERIAL# = :QA.SERIAL
1.The dc_gmod.cd_gmod - is full name my block_name and item_name.
2. The ttt.xxxxx_table is full name of my table what is source for block dc_gmod
3. The cd_place is ITEM of BLOCK dc_gmod

Similar Messages

  • Where Clause in the block not executed

    I have this in the where clause in my block, I want to exclude managers. I have added a flag column IS_MGR to prs_employee_profile and I added this line to query(where IS_MGR <> 2) “ value 2 for true” and but it doesn’t work. prs_amp_profile is the emp table and this block is based on atn_emp_week , emp_id is a foreign key. all the conditions are working except for the one i added and it is still bring the records for the managers. Any body can tell me why the condition is not being forced.
    Original Where Clause
    1=1 AND (emp_id in (select id from prs_employee_profile where
    dpt_id in (select dept_id from prs_user_dept_priv where user_id = :global.usr)
    and emp_id = decode(:global.emp_user_flag, 1, id, :global.emp_id)
    and emp_sts_id in (select id from prs_employment_status where active_flag <> 0))
    OR :GLOBAL.GRP='ATN_ADM')
    After adding
    1=1 AND (emp_id in (select id from prs_employee_profile where IS_MGR <>2
    And dpt_id in (select dept_id from prs_user_dept_priv where user_id = :global.usr)
    and emp_id = decode(:global.emp_user_flag, 1, id, :global.emp_id)
    and emp_sts_id in (select id from prs_employment_status where active_flag <> 0))
    OR :GLOBAL.GRP='ATN_ADM')

         1=1
    AND (    emp_id in (select id
                          from prs_employee_profile
                         where IS_MGR!=2
                           And dpt_id in (select dept_id
                                            from prs_user_dept_priv
                                           where user_id = :global.usr
                           and emp_id = decode(:global.emp_user_flag, 1, id, :global.emp_id)
                           and emp_sts_id in (select id
                                                from prs_employment_status
                                               where active_flag!=0)
          OR :GLOBAL.GRP='ATN_ADM'
        )I don't know your table-structures, one possibility would be that :GLOBAL.GRP is ATN_ADM at testing for this overwrites the other conditions.
    I would try to check the condition in sql*plus, apply it to the block when its working.

  • Function Within a default where clause on a block

    Hi
    Within a forms 6 form I have a data base block I wish to amend the where clause depending on cetain search criteria. To do this I have created a database function to include in the where clause which if I execute using PL/SQL Develops returns the required results, however if I use a set_block_property default where and try to use the function if seems to be ignored and returns all rows not just the ones matching the function value, is there a resrtiction in the default where?
    Any help would be great
    Thanks
    Tina

    Make sure that you are not putting the "and" at the beginning of the query unnecssarily.
    If "lv_def_where" is null then you would not begin your query with "and"
    IF :control.t_primary_whs IS NOT NULL THEN
    . IF lv_def_where IS NULL
    . THEN
    . lv_def_where := lv_def_where ||'sce.find_primary_warehouse ('''||:customers_address.owner_code||''','''||:customers_address.owner_sub_code||''' ,'''||:customers_address.post_code||''',''CP'')= '''||:control.t_primary_whs||'''';
    . ELSE
    . lv_def_where := lv_def_where ||' and sce.find_primary_warehouse('''||:customers_address.owner_code||''','''||:customers_address.owner_sub_code||''' ,'''||:customers_address.post_code||''',''CP'')= '''||:control.t_primary_whs||'''';
    . END IF;
    END IF;
    Is that the case?

  • Where clause and Dates

    I am creating a coditional query for one of my data blocks.
    What I need to do is build a where clause on the fly and pass
    that back to my block using the Set_BLock_Property built in. I
    am able to do this but I am having problems with the fact that I
    don't know how to correctly pass a date back. It seems when
    specifying a date in a where clause it needs to have single
    quotes around this. But when ever I try to embed the quotes in
    the string I am not successful. I have even tried appending the
    quotes using the chr function doing something like.
    Where_Clause := 'Birthday <= '

    Spencer,
    I think chr(39) will give you the correct character. For example,
    Where_Clause := 'Birthday <= '

  • Where-clause for date-string

    Hi specialist's,
    i have a simple question about a select, but I think I do not see the forrest becaus of too many trees ...
    I have a table where timestamps are stored in seconds-since-epoch.
    I select a human readble format with this statement:
    select to_char(DATE '1970-01-01' + TRXTIMESTAMP / (24*3600*1000), 'DD-MM-YYYY HH24:MI:SS')  as timestamp from txlog;
    TIMESTAMP
    19-10-2013 09:31:27
    19-10-2013 09:31:27
    19-10-2013 09:31:27
    Now I want to filter i.e. for dates of 19-01.... 
    My first try was this:
    select to_char(DATE '1970-01-01' + TRXTIMESTAMP / (24*3600*1000), 'DD-MM-YYYY HH24:MI:SS')  as timestamp from txlog
      where timestamp like '19-%'
    Result:
    ORA-00904: "TIMESTAMP": invalid identifier
    My next try was this:
    select to_char(DATE '1970-01-01' + TRXTIMESTAMP / (24*3600*1000), 'DD-MM-YYYY HH24:MI:SS')  as timestamp from txlog
    where 1 like '19%'
    Result: 0 rows!
    If I change this to
    ... where 1 like '%'
    I get all rows.
    What is wrong with my selects ???

    Felix_GG wrote:
    Hi specialist's,
    i have a simple question about a select, but I think I do not see the forrest becaus of too many trees ...
    I have a table where timestamps are stored in seconds-since-epoch.
    I select a human readble format with this statement:
    select to_char(DATE '1970-01-01' + TRXTIMESTAMP / (24*3600*1000), 'DD-MM-YYYY HH24:MI:SS')  as timestamp from txlog;
    TIMESTAMP
    19-10-2013 09:31:27
    19-10-2013 09:31:27
    19-10-2013 09:31:27
    Now I want to filter i.e. for dates of 19-01....
    My first try was this:
    select to_char(DATE '1970-01-01' + TRXTIMESTAMP / (24*3600*1000), 'DD-MM-YYYY HH24:MI:SS')  as timestamp from txlog
      where timestamp like '19-%'
    Result:
    ORA-00904: "TIMESTAMP": invalid identifier
    My next try was this:
    select to_char(DATE '1970-01-01' + TRXTIMESTAMP / (24*3600*1000), 'DD-MM-YYYY HH24:MI:SS')  as timestamp from txlog
    where 1 like '19%'
    Result: 0 rows!
    If I change this to
    ... where 1 like '%'
    I get all rows.
    What is wrong with my selects ???
    Firstly, why not store timestamps as timestamps?
    Anyway, Your first select refers to the alias 'timestamp' which is only accessible in an outer query, not from within the where clause.
    Try
    Select * from (
    select to_char(DATE '1970-01-01' + TRXTIMESTAMP / (24*3600*1000), 'DD-MM-YYYY HH24:MI:SS')  as timestamp from txlog
    where timestamp like '19-%';
    But timestamp is not a good choice for an alias, as it is a keyword.
    Your second select is obvious - the number 1 will never be like '19%', but it will work
    in the third select: as 1 is indeed like '%' (anything).

  • Correct way to do "where " clause on date type column

    Hi,
    I am using a following query in Oracle 10.2.0.3 express edition database to retrieve the rows greater than a certain date.
    select from FLOWS_020100.WWV_FLOW_ACTIVITY_LOG1$ where TIME_STAMP > to_date('31-OCT-12');*
    This query returns all the rows including the rows with TIME_STAMP == '31-OCT-12'.
    This TIME_STAMP column is defined as below in this table:
    COLUMN_NAME     DATA_TYPE     DATA_LENGTH     NULLABLE     CONSTRAINT_TYPE      INDEX_TYPE
    TIME_STAMP     DATE      7     N     C     NORMAL
    Table has 420 rows with '31-OCT-12' being the smallest date and '16-NOV-12' being the biggest.
    Is there anything wrong in my above query?
    Why is ">" returning the rows that include primary key where-clause value also?
    Can you please guide what is the correct syntax for this date comparison?
    Thanks for your time and help.
    Best Regards.

    907882 wrote:
    Hi,
    I am using a following query in Oracle 10.2.0.3 express edition database to retrieve the rows greater than a certain date.
    select from FLOWS_020100.WWV_FLOW_ACTIVITY_LOG1$ where TIME_STAMP > to_date('31-OCT-12');*
    This query returns all the rows including the rows with TIME_STAMP == '31-OCT-12'.
    This TIME_STAMP column is defined as below in this table:
    COLUMN_NAME     DATA_TYPE     DATA_LENGTH     NULLABLE     CONSTRAINT_TYPE      INDEX_TYPE
    TIME_STAMP     DATE      7     N     C     NORMAL
    Table has 420 rows with '31-OCT-12' being the smallest date and '16-NOV-12' being the biggest.
    Is there anything wrong in my above query?
    Why is ">" returning the rows that include primary key where-clause value also?
    Can you please guide what is the correct syntax for this date comparison?
    Thanks for your time and help.
    Best Regards.Remember that a date column also contains a time part. Therefore your query would pick up
    rows with a time_stamp of 31-Oct-12 13:40:09, for example. Now that is greater than 31-Oct-12
    (which is really 31-Oct-12 00:00:00), so it is picked up.
    You probably want >= to_date('1-Nov-2012', 'dd-mon-yyyy')
    Note: always use a format mask in a to_date, otherwise if the default format mask changes, your code will break.
    BTW: please mark your threads as answered, if they have been:
    >
    Handle:      907882
    Status Level:      Newbie
    Registered:      Jan 13, 2012
    Total Posts:      9
    Total Questions:      6 (5 unresolved)
    >
    Edited by: Paul Horth on Nov 27, 2012 9:30 AM

  • ADF Struts UIX - how write where clause whith date in ViewObject

    Hello
    I need to write a search form with two date fields and then query a where clause between to_date('date 1') and to_date('date 2').
    the query may be writed in ViewCriteria class or using Application module method like this
    AssureViewImpl assureView=getAssureView1();
    assureView.applyViewCriteria(null);
    assureView.setWhereClause("NUM_ASSU = :1");
    assureView.setWhereClauseParam(0,numAss);
    thanks a lot for your help

    Does the user always specify both start and end dates?

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

  • Decode in where claus with date comparasion

    hi
    i m using this query can we compare date in decode function in where claue if yes how
    SELECT PPA.START_DATE,
    PPA.END_DATE
    FROM pa_project_assignments PPA,
    PA_CONTROL_ITEMS PCI
    WHERE DECODE(PPA.START_DATE < PCI.ATTRIBUTE1,PCI.ATTRIBUTE1,PPA.START_DATE) BETWEEN (PCI.ATTRIBUTE1) AND (PCI.DATE_REQUIRED)
    AND PPA.END_DATE BETWEEN (PCI.ATTRIBUTE1) AND( PCI.DATE_REQUIRED)
    AND PPA.PROJECT_ID=PCI.PROJECT_ID

    This works.
    SELECT * FROM emp
    WHERE
    CASE WHEN hiredate < SYSDATE THEN
    hiredate
    ELSE SYSDATE
    END BETWEEN SYSDATE-10000 AND SYSDATEIn your CASE
    SELECT PPA.START_DATE,
    PPA.END_DATE
    FROM pa_project_assignments PPA,
    PA_CONTROL_ITEMS PCI
    WHERE
    case when PPA.START_DATE < PCI.ATTRIBUTE1 then
    PCI.ATTRIBUTE1
    else
    PPA.START_DATE
    end  BETWEEN PCI.ATTRIBUTE1 AND PCI.DATE_REQUIRED
    AND PPA.END_DATE BETWEEN  PCI.ATTRIBUTE1 AND PCI.DATE_REQUIRED
    AND PPA.PROJECT_ID=PCI.PROJECT_IDCheers!!!
    Bhushan

  • Where clause with date in db2

    select * from table WHERE column1 = to_date(1998-12-21, 'YYYY-MM-DD')
    the columns has date in the form of 1998-12-21. I am getting the following error
    the error is
    DB2 sql 0171n the datatype, length, or value of argument "1" of routine "to_date" is in correct sql state = 42815

    This is an Oracle forum.
    Please take your DB2 questions elsewhere.

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

  • Dynamic Order by with user defined Where clause...

    Hello!
    I have a block based on a table, with no order by set and no where clause.
    The block is queryable so users can filter the data to be retrieved.
    Each of the columns on the form have a button above which requeries the block, applying the order by (SET_BLOCK_PROPERTY ( 'B12', ORDER_BY, :bc1.h_b12_custom_orderby ); )
    The problem is that each time the block is requeried the user definied filter criteria is lost. Is there any way I can get a handle on this and maintain the filtering?
    GET_BLOCK_PROPERTY(item, DEFAULT_WHERE); only retrieves the query entered while in design mode so this won't work.
    I'm using Oracle Forms 6i, web based. Any suggestions are very much appreciated.
    Thanks in advance,
    Jay

    Many thanks for your response Hedy,
    Below is the procedure I used to achieve this.
    I found GET_BLOCK_PROPERTY ( p_block, LAST_QUERY ) worked better than :SYSTEM.last_query. As the first time it is called within a block :SYSTEM.last_query returned the query made in another block - which I'm sure has it's applications.
    Thanks again,
    Jay
    PROCEDURE set_last_query_where ( p_block IN VARCHAR2
    , p_where IN VARCHAR2 DEFAULT NULL )IS
    l_last_query VARCHAR2(10000);
    l_last_where VARCHAR2(10000);
    BEGIN
    IF p_where IS NULL THEN
    l_last_query := UPPER(GET_BLOCK_PROPERTY ( p_block, LAST_QUERY ));
    l_last_where := SUBSTR ( UPPER ( l_last_query),
    INSTR ( l_last_query, 'WHERE')+6, INSTR(SUBSTR(UPPER(l_last_query), INSTR(l_last_query, 'WHERE')+8), 'ORDER BY'));
    ELSE
    l_last_where := p_where;
    END IF;
    SET_BLOCK_PROPERTY ( p_block, DEFAULT_WHERE, l_last_where );
    EXCEPTION
         WHEN FORM_TRIGGER_FAILURE THEN
         ref_raise_ftf;
         WHEN OTHERS THEN
         ref_others( 'P-SLQW' );
    END;

  • Trying to add a where clause.

    Hi All,
    I am not much aware of View Links.
    I am trying to extend a particular Page.
    The page has an Hgrid, which looks like (Headers -> under that section data of that header -> under it attributes data of that section)
    Header
    Section
    Attributes
    There is a view link between "Headers - Section" & another between "Section - Attributes".
    I want to add a filter at the Sections level. So I added a where clause to the sections VO. But the where clause is not taking any affect. So I wanted to know if this is because of the view link.
    Please Help !
    Regards,
    Bm

    Did you mean something like this,
    i have tried the below code in forms 10g , as the where clause of 'EMP' block there was no problem.
    deptno in (select /*+ ORDERED */ deptno from dept where rownum<2);
    Also tried in SQLPlus like below
    SQL> select * from emp where deptno in (select /*+ ORDERED */ deptno from dept where rownum<2);
    EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
    7782 CLARK MANAGER 7839 09-JUN-81 2450 10
    7839 KING PRESIDENT 17-NOV-81 5000 10
    7934 MILLER CLERK 7782 23-JAN-82 1300 10

  • Dynamic query in where clause while looping in an internal table.

    Hi,
    Had a small question : How can i make a dynamic query for the WHERE clause while looping at an internal table.
    i want to implement a dynamic where clause query for the below example.
    it_cfx_col is an internal table and wa_cfx_col is a work area for it_cfx_col
      DATA :
      i_cfx_col TYPE TABLE OF cfx_col,
      wa_cfx_col LIKE LINE OF i_cfx_col.
    DATA : count TYPE i VALUE 0.
    DATA : l_where_clause TYPE string,
             l_where_clause2 TYPE string,
             l_name type string.
    l_name = 'NANDANOM'.
    l_scenario = 'collaboration'.
    LOOP AT it_cfx_col INTO wa_cfx_col
    WHERE CREATED_BY = l_name
    AND SCENARIO = l_scenario.
    count = count + 1.
    some business logic implemented using the work area wa_cfx_col
    endloop.
    Now i want to write a dynamic query for the where clause.
    DATA : count TYPE i VALUE 0.
      DATA : l_where_clause TYPE string,
             l_where_clause2 TYPE string,
             l_name type string.
    l_name = 'NANDANOM'.
    l_scenario = 'collaboration'.
      l_where_clause = 'CREATED_BY = l_name'.
      l_where_clause2 = 'AND SCENARIO = l_scenario'.
    if l_scenario is not initial.
      CONCATENATE  l_where_clause l_where_clause2
      INTO l_where_clause SEPARATED BY space.
    endif.
    LOOP AT i_cfx_col INTO wa_cfx_col
    WHERE (l_where_clause).
    count = count + 1.
    some business logic implemented using the work area wa_cfx_col
    endloop.
    when i compile this i get an error message as { Statement concluding with "...(l_where_clause)" ended unexpectedly}
    Even i changed the initilization of the variable  l_where_clause2 to [ l_where_clause2 = 'AND SCENARIO = l_scenario.'. ]
    added the end of line demarkation ".", but still i got the same error message.
    Is it a limtation in ABAP that i cannot write a dynamic query for the where clause while looping at an internal table?
    Regards,
    om

    Hi savita,
    there in no such 1 limitaion in abap for dynamic query .. i think the  error meassge is only beacuse of your synatx delcartaion.
    >> LOOP AT i_cfx_col INTO wa_cfx_col
       WHERE (l_where_clause).
       count = count + 1.
    some business logic implemented using the work     area    wa_cfx_col
       endloop.
    afted delclarataion also , in the where statement you should specify both the field name and value bname
       LOOP AT i_cfx_col INTO wa_cfx_col
       WHERE l_where_clause = 'CREATED_BY = l_name' .
       count = count + 1.
    hope it helps.
    regads
    priya.

  • Error when trying to add a hint to inner query in WHERE clause

    I have a form where the WHERE clause in a block starts like:
    where seqno in (select seqno from nddf n, restriction r...
    I need to add a hint to the inner query like following:
    where seqno in (select /*+ ORDERED */ seqno from nddf n, restriction r...
    When the query executes. I gets an error message and when I look at the detail error I see: ORA-01722: invalid number
    Does anybody know the cause for this. Can I not use hints in inner queries?
    Thanks,
    Thomas

    Did you mean something like this,
    i have tried the below code in forms 10g , as the where clause of 'EMP' block there was no problem.
    deptno in (select /*+ ORDERED */ deptno from dept where rownum<2);
    Also tried in SQLPlus like below
    SQL> select * from emp where deptno in (select /*+ ORDERED */ deptno from dept where rownum<2);
    EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
    7782 CLARK MANAGER 7839 09-JUN-81 2450 10
    7839 KING PRESIDENT 17-NOV-81 5000 10
    7934 MILLER CLERK 7782 23-JAN-82 1300 10

Maybe you are looking for

  • Problem with BSP MVC

    Hi all, I had a bsp application which is now running live in the organization. Recently, I got a problem report back from user, which is causing data loss. After the support team check the problem and found out the source of the problem. Let me brief

  • Excessive LDAP Queries from WLS 6.0 SP2 RP3

    We have an application served from WLS 6.0. Our current version of WLS is: Service Pack 2 05/24/2001 11:55:28 #117037 RP3 for 6.0 SP2 02/21/2002 17:46:45 #167070 WLS has been configured to query an LDAP server for user authentication. The issue we ar

  • In doubt... will upgrading to OS-10.5 stop Golive CS2 from working?

    Hi, it's been such a long time since we discussed this... I still use Golive CS2, as well as Photoshop CS2 sometimes to use the plug'ins that are not compatible with CS4. Will upgrading to the latest OS give me any trouble with those apps?

  • Function for accounting period

    Hi guru, do you know a function to know if the accounting period is open or closed? thanks

  • Removing duplicate home mailing addresses?

    after merging duplicate contacts, most contacts now have multiple (duplicate) mailing addresses.  How can I remove/merge these duplicate addresses? Thanks, Mike