Using Filter and where clause in GoldenGate

Hi,
I need to use where clause in extract process.
The condition i need to use is :- where (CODE LIKE '10%' OR CODE LIKE '0%')
how to use LIKE operation along with OR in extract.
I have multiple where conditions these are straight i.e = and <> which are working fine. But LIKE is not working.
Please do assist for the same.
Thanks.

GoldenGate uses FILTER and SQLPREDICATE (and COMPUTE is a variation that can work, depending on how you are trying to manipulate the data).
To filter data, you can use:
● A FILTER or WHERE clause in a TABLE statement (Extract) or in a MAP statement (Replicat).
● A SQL query or procedure
● User exits
FILTER comparison operators include:
Comparison operators:
> (greater than)
>= (greater than or equal)
< (less than)
<= (less than or equal)
= (equal)
<> (not equal)
WHERE clause permissible operators:
Column names PRODUCT_AMT
Numeric values -123, 5500.123
Literal strings "AUTO", "Ca"
Built-in column tests @NULL, @PRESENT, @ABSENT (column is null, present or absent in the row). These tests are built into Oracle GoldenGate. See “Considerations for selecting rows with FILTER and WHERE” on page 155.
Comparison operators =, <>, >, <, >=, <=
Conjunctive operators AND, OR
Grouping parentheses Use open and close parentheses ( ) for logical grouping of multiple elements.
You could try using a GoldenGate string function. You know what the leading one or two characters (0 and 10) are.
Use the @STREXT function to extract a portion of a string and do a comparison there. Or take care of it using SQLEXEC on replicat (call a function to be able to use LIKE).

Similar Messages

  • Error while using REMAP_TABLE and WHERE clause  together in IMPDP

    I am trying to move some records from a very large table to another small table.
    I am facing trouble while using REMAP_TABLE and WHERE clause together in IMPDP.
    Problem is data filter is not getting applied and all records are getting imported.
    here is how I have simulated this. please advice.
    CREATE TABLE TSHARRHB.TMP1
      A  NUMBER,
      B  NUMBER
    begin
    Insert into TSHARRHB.TMP1
       (A, B)
    Values
       (1, 1);
    Insert into TSHARRHB.TMP1
       (A, B)
    Values
       (2, 2);
    COMMIT;
    end;
    expdp system/password TABLES=tsharrhb.TMP1 DIRECTORY=GRDP_EXP_DIR DUMPFILE=TMP1.dmp REUSE_DUMPFILES=YES LOGFILE=EXP.log PARALLEL=8
    impdp system/password DIRECTORY=GRDP_EXP_DIR DUMPFILE=TMP1.dmp LOGFILE=imp.log PARALLEL=8 QUERY='TSHARRHB.TMP1:"WHERE TMP1.A = 2"'  REMAP_TABLE=TSHARRHB.TMP1:TMP3 CONTENT=DATA_ONLY
    Import: Release 11.2.0.1.0 - Production on Fri Dec 13 05:13:30 2013
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    With the Partitioning, Automatic Storage Management, OLAP, Data Mining
    and Real Application Testing options
    Master table "SYSTEM"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
    Starting "SYSTEM"."SYS_IMPORT_FULL_01":  system/********@GRD6.RBSG DIRECTORY=GRDP_EXP_DIR DUMPFILE=TMP1.dmp LOGFILE=SSD_93_TABLES_FULL_EXP.log PARALLEL=8 QUERY=TSHARRHB.TMP1:"WHERE TMP1.A = 2" REMAP_TABLE=TSHARRHB.TMP1:TMP3 CONTENT=DATA_ONLY
    Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
    . . imported "TSHARRHB"."TMP3"                           5.421 KB       2 rows
    Job "SYSTEM"."SYS_IMPORT_FULL_01" successfully completed at 05:13:33
    here I am expecting only 1 record to get imported but both the records are getting imported. please advice.

    The strange thing compared to your output is that I get an error when I have table prefix in the query block:
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    Master table "SYSTEM"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
    Starting "SYSTEM"."SYS_IMPORT_FULL_01":  system/******** DUMPFILE=TMP1.dmp LOGFILE=imp.log PARALLEL=8 QUERY=SYSADM.TMP1:"WHERE TMP1.A = 2" REMAP_TABLE=SYSADM.TMP1:TMP3 CONTENT=DATA_ONLY
    Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
    ORA-31693: Table data object "SYSADM"."TMP3" failed to load/unload and is being skipped due to error:
    ORA-38500: Unsupported operation: Oracle XML DB not present
    Job "SYSTEM"."SYS_IMPORT_FULL_01" completed with 1 error(s) at Fri Dec 13 10:39:11 2013 elapsed 0 00:00:03
    And if I remove it, it works:
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    Master table "SYSTEM"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
    Starting "SYSTEM"."SYS_IMPORT_FULL_01":  system/******** DUMPFILE=TMP1.dmp LOGFILE=imp.log PARALLEL=8 QUERY=SYSADM.TMP1:"WHERE A = 2" REMAP_TABLE=SYSADM.TMP1:TMP3 CONTENT=DATA_ONLY
    Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
    . . imported "SYSADM"."TMP3"                             5.406 KB       1 out of 2 rows
    Job "SYSTEM"."SYS_IMPORT_FULL_01" successfully completed at Fri Dec 13 10:36:50 2013 elapsed 0 00:00:01
    Nicolas.
    PS: as you can see, I'm on 11.2.0.4, I do not have 11.2.0.1 that you seem to use.

  • Can both in-row and off-row LOBs be used in a where clause?

    We are preparing to upgrade ASE from version 15.5 to 16.0.  One of the features that is very appealing has to do with the changes made concerning the handling of LOBs.  In particular, the ability to use a LOB column in search arguments (where clause) is something our developers have longed for since the retirement of the full-text search option.  So, in version 16.0, can any column with a datatype of text be used as a search argument? Are there any restrictions.
    Thanks in advance.

    Hi Kevin,
    The in-row LOB feature is mainly designed to save space when a text column has many short values, which is a particularly bad problem when the server uses a large page size (like 16K) as ASE would use a full 16K to store even a single bye "Y".  I don't think the feature made any change in how text can be used in search arguments.  i.e. you can still use LIKE and IS [NOT] NULL, but not others.
    Example:
    1> create table t (x text in row (8))
    2> go
    1> insert t values ("abc")
    2> insert t values ("abcdefghijkl")
    3> go
    (2 rows affected)
    1> select * from t where x like "%c%"
    2> go
    x                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
    abc                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
    abcdefghijkl                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
    (2 rows affected)
    1> select * from t where x !> "c"
    2> go
    Msg 257, Level 16, State 1:
    Server 'redhead', Line 1:
    Implicit conversion from datatype 'TEXT' to 'VARCHAR' is not allowed.  Use the
    CONVERT function to run this query.
    Msg 306, Level 16, State 5:
    Server 'redhead', Line 1:
    TEXT, IMAGE and UNITEXT datatypes may not be used in a WHERE clause, except with
    the LIKE expression and IS [NOT] NULL predicate on columns.

  • Difference of 'Specify Fragmentation Content'  and 'where clause Filter ' ?

    What is the difference of ‘Specify Fragmentation Content’ and ‘where clause Filter ‘
    As per my understanding Both looks like limit the data ?

    'Specify Fragmentation Content’ is for Union-ing tables, e.g. one table has data for 2008 while other has 2005-2007, so 'Specify Fragmentation Content’ tells server where to go look for data.
    'Where clause Filter' is for limiting data from the table, e.g. where status = 'Funded'

  • Using a dummy where-clause to force the use of an index

    I notice that an index only gets used when I use the index key in the where clause. Should I use a dummy where clause to force the index to be used?
    SQL> create table emp (
    2 empno NUMBER(5),
    3 empname VARCHAR2(15) );
    Table created.
    SQL> create index idx_emp_no on emp (empno);
    Index created.
    SQL> insert into emp (empno, empname) values (1, 'Peter');
    1 row created.
    SQL> set autotrace traceonly;
    SQL> select empno from emp;
    Execution Plan
    Plan hash value: 3956160932
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 13 | 3 (0)| 00:00:01 |
    | 1 | TABLE ACCESS FULL| EMP | 1 | 13 | 3 (0)| 00:00:01 |
    SQL> select empno from emp where empno > 0;
    Execution Plan
    Plan hash value: 434430053
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 13 | 1 (0)| 00:00:01 |
    |* 1 | INDEX RANGE SCAN| IDX_EMP_NO | 1 | 13 | 1 (0)| 00:00:01 |
    As you can see, using a dummy where clause (empno > 0), I manage to reduce the cost from 3 to 1.

    Again. Be careful with comparisons. But I like the discussion. It is usefull to carefully look at what happens "behind the scenes" and find a sensible explaination for that.
    Your new scenario now is different. By selecting one specific row instead of selection all you already made an assumption. That only one or few of the rows are returned. Andre's statement still is correct. Now the CBO will prefere the index scan.
    The CBO now has to decide between two options.
    Option a) use the index.
    This means =>
    Step 1: Access the index to find the value
    Step 2: Access the table using the rowid that was found in the index leaf entry.
    Option b) scan the full table
    This means =>
    Step 1: Iterate over all rows of the table
    Step 2: Apply a filter condition (empno = :x)
    We can see this execution plan by adding a hint to the query.
    select /*+ FULL(emp) */ * from emp where empno = 1;This hint will force the CBO to access the table emp using a full table scan.
    The cost in my environment for option B is 3.
    Option A has a cost with 2. Therefore the CBO prefers Option A.
    However this can easily change.
    Consider the following
    begin
      for i in 1..1000 loop
        insert into emp (empno, empname) values (1, 'Employee');
      end loop;
    end;
    commit;
    execute dbms_stats.gather_table_stats(user,'EMP');The run the select again.
    SQL> set autotrace traceonly
    SQL> select * from emp where empno = 1;
    1001 Zeilen ausgewõhlt.
    Ausf³hrungsplan
    Plan hash value: 3956160932
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |  1001 | 12012 |     3   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| EMP  |  1001 | 12012 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("EMPNO"=1)
    Statistiken
              1  recursive calls
              0  db block gets
             74  consistent gets
              0  physical reads
              0  redo size
          18356  bytes sent via SQL*Net to client
           1250  bytes received via SQL*Net from client
             68  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
           1001  rows processedThe CBO now prefers the full table scan and not the index access.
    If we force it to use an index then the cost increases.
    SQL> set linesize 100
    SQL> select /*+INDEX(emp) */ * from emp where empno = 1
    1001 Zeilen ausgewõhlt.
    Ausf³hrungsplan
    Plan hash value: 2426388914
    | Id  | Operation                   | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |           |  1001 | 12012 |     5   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| EMP       |  1001 | 12012 |     5   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | IDX_EMPNO |  1001 |       |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("EMPNO"=1)
    Statistiken
              0  recursive calls
              0  db block gets
            139  consistent gets
              0  physical reads
              0  redo size
          30550  bytes sent via SQL*Net to client
           1250  bytes received via SQL*Net from client
             67  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
           1001  rows processed
    SQL>The cost using the index range scan is now 5. WHile the FTS is still 3. Therefore the CBO prefers to use the FTS.

  • Slow split table export (R3load and WHERE clause)

    For our split table exports, we used custom coded WHERE clauses. (Basically adding additional columns to the R3ta default column to take advantage of existing indexes).
    The results have been good so far. Full tablescans have been eliminated and export times have gone down, in some cases, tables export times have improved by 50%.
    However, our biggest table, CE1OC01 (120 GB), continues to be a bottleneck. Initially, after using the new WHERE clause, it looked like performance gains were dramatic, with export times for the first 5 packages dropping from 25-30 hours down to 1 1/2 hours.
    However, after 2 hours, the remaining CE1OC01 split packages have shown no improvement. This is very odd because we are trying to determine why part of the table exports very fast, but other parts are running very slow.
    Before the custom WHERE clauses, the export server had run into issues with SORTHEAP being exhausted, so we thought that might be the culprit. But that does not seem to be an issue now, since the improved WHERE clauses have reduced or eliminated excessive sorting.
    I checked the access path of all the CE1OC01 packages, through EXPLAIN, and they all access the same index to return results. The execution time in EXPLAIN returns similar times for each of the packages:
    CE1OC01-11: select * from CE1OC01  WHERE MANDT='212'
    AND ("BELNR" > '0124727994') AND ("BELNR" <= '0131810250')
    CE1OC01-19: select * from CE1OC01 WHERE MANDT='212'
    AND ("BELNR" > '0181387534') AND ("BELNR" <= '0188469413')
          0 SELECT STATEMENT ( Estimated Costs =  8.448E+06 [timerons] )
      |
      ---      1 RETURN
          |
          ---      2 FETCH CE1OC01
              |
              ------   3 IXSCAN CE1OC01~4 #key columns:  2
    query execution time [millisec]            |       333
    uow elapsed time [microsec]                |   429,907
    total user CPU time [microsec]             |         0
    total system cpu time [microsec]           |         0
    Both queries utilize an index that has fields MANDT and BELNR. However, during R3load, CE1OC01-19 finishes in an hour and a half, whereas CE1OC01-11 can take 25-30 hours.
    I am wondering if there is anything else to check on the DB2 access path side of things or if I need to start digging deeper into other aggregate load/infrastructure issues. Other tables don't seem to exhibit this behavior. There is some discrepancy between other tables' run times (for example, 2-4 hours), but those are not as dramatic as this particular table.
    Another idea to test is to try and export only 5 parts of the table at a time, perhaps there is a throughput or logical limitation when all 20 of the exports are running at the same time. Or create a single column index on BELNR (default R3ta column) and see if that shows any improvement.
    Anyone have any ideas on why some of the table moves fast but the rest of it moves slow?
    We also notice that the "fast" parts of the table are at the very end of the table. We are wondering if perhaps the index is less fragmented in that range, a REORG or recreation of the index may do this table some good. We were hoping to squeeze as many improvements out of our export process as possible before running a full REORG on the database. This particular index (there are 5 indexes on this table) has a Cluster Ratio of 54%, so, perhaps for purposes of the export, it may make sense to REORG the table and cluster it around this particular index. By contrast, the primary key index has a Cluster Ratio of 86%.
    Here is the output from our current run. The "slow" parts of the table have not completed, but they average a throughput of 0.18 MB/min, versus the "fast" parts, which average 5 MB/min, a pretty dramatic difference.
    package     time      start date        end date          size MB  MB/min
    CE1OC01-16  10:20:37  2008-11-25 20:47  2008-11-26 07:08   417.62    0.67
    CE1OC01-18   1:26:58  2008-11-25 20:47  2008-11-25 22:14   429.41    4.94
    CE1OC01-17   1:26:04  2008-11-25 20:47  2008-11-25 22:13   416.38    4.84
    CE1OC01-19   1:24:46  2008-11-25 20:47  2008-11-25 22:12   437.98    5.17
    CE1OC01-20   1:20:51  2008-11-25 20:48  2008-11-25 22:09   435.87    5.39
    CE1OC01-1    0:00:00  2008-11-25 20:48                       0.00
    CE1OC01-10   0:00:00  2008-11-25 20:48                     152.25
    CE1OC01-11   0:00:00  2008-11-25 20:48                     143.55
    CE1OC01-12   0:00:00  2008-11-25 20:48                     145.11
    CE1OC01-13   0:00:00  2008-11-25 20:48                     146.92
    CE1OC01-14   0:00:00  2008-11-25 20:48                     140.00
    CE1OC01-15   0:00:00  2008-11-25 20:48                     145.52
    CE1OC01-2    0:00:00  2008-11-25 20:48                     184.33
    CE1OC01-3    0:00:00  2008-11-25 20:48                     183.34
    CE1OC01-4    0:00:00  2008-11-25 20:48                     158.62
    CE1OC01-5    0:00:00  2008-11-25 20:48                     157.09
    CE1OC01-6    0:00:00  2008-11-25 20:48                     150.41
    CE1OC01-7    0:00:00  2008-11-25 20:48                     175.29
    CE1OC01-8    0:00:00  2008-11-25 20:48                     150.55
    CE1OC01-9    0:00:00  2008-11-25 20:48                     154.84

    Hi all, thanks for the quick and extremely helpful answers.
    Beck,
    Thanks for the health check. We are exporting the entire table in parallel, so all the exports begin at the same time. Regarding the SORTHEAP, we initially thought that might be our problem, because we were running out of SORTHEAP on the source database server. Looks like for this run, and the previous run, SORTHEAP has remained available and has not overrun. That's what was so confusing, because this looked like a buffer overrun.
    Ralph,
    The WHERE technique you provided worked perfectly. Our export times have improved dramatically by switching to the forced full tablescan. Being always trained to eliminate full tablescans, it seems counterintuitive at first, but, given the nature of the export query, combined with the unsorted export, it now makes total sense why the tablescan works so much better.
    Looks like you were right, in this case, the index adds too much additional overhead, and especially since our Cluster Ratio was terrible (in the 50% range), so the index was definitely working against us, by bouncing all over the place to pull the data out.
    We're going to look at some of our other long running tables and see if this technique improves runtimes on them as well.
    Thanks so much, that helped us out tremendously. We will verify the data from source to target matches up 1 for 1 by running a consistency check.
    Look at the throughput difference between the previous run and the current run:
    package     time       start date        end date          size MB  MB/min
    CE1OC01-11   40:14:47  2008-11-20 19:43  2008-11-22 11:58   437.27    0.18
    CE1OC01-14   39:59:51  2008-11-20 19:43  2008-11-22 11:43   427.60    0.18
    CE1OC01-12   39:58:37  2008-11-20 19:43  2008-11-22 11:42   430.66    0.18
    CE1OC01-13   39:51:27  2008-11-20 19:43  2008-11-22 11:35   421.09    0.18
    CE1OC01-15   39:49:50  2008-11-20 19:43  2008-11-22 11:33   426.54    0.18
    CE1OC01-10   39:33:57  2008-11-20 19:43  2008-11-22 11:17   429.44    0.18
    CE1OC01-8    39:27:58  2008-11-20 19:43  2008-11-22 11:11   417.62    0.18
    CE1OC01-6    39:02:18  2008-11-20 19:43  2008-11-22 10:45   416.35    0.18
    CE1OC01-5    38:53:09  2008-11-20 19:43  2008-11-22 10:36   413.29    0.18
    CE1OC01-4    38:52:34  2008-11-20 19:43  2008-11-22 10:36   424.06    0.18
    CE1OC01-9    38:48:09  2008-11-20 19:43  2008-11-22 10:31   416.89    0.18
    CE1OC01-3    38:21:51  2008-11-20 19:43  2008-11-22 10:05   428.16    0.19
    CE1OC01-2    36:02:27  2008-11-20 19:43  2008-11-22 07:46   409.05    0.19
    CE1OC01-7    33:35:42  2008-11-20 19:43  2008-11-22 05:19   414.24    0.21
    CE1OC01-16    9:33:14  2008-11-20 19:43  2008-11-21 05:16   417.62    0.73
    CE1OC01-17    1:20:01  2008-11-20 19:43  2008-11-20 21:03   416.38    5.20
    CE1OC01-18    1:19:29  2008-11-20 19:43  2008-11-20 21:03   429.41    5.40
    CE1OC01-19    1:16:13  2008-11-20 19:44  2008-11-20 21:00   437.98    5.75
    CE1OC01-20    1:14:06  2008-11-20 19:49  2008-11-20 21:03   435.87    5.88
    PLPO          0:52:14  2008-11-20 19:43  2008-11-20 20:35    92.70    1.77
    BCST_SR       0:05:12  2008-11-20 19:43  2008-11-20 19:48    29.39    5.65
    CE1OC01-1     0:00:00  2008-11-20 19:43                       0.00
                558:13:06  2008-11-20 19:43  2008-11-22 11:58  8171.62
    package     time      start date        end date          size MB   MB/min
    CE1OC01-9    9:11:58  2008-12-01 20:14  2008-12-02 05:26   1172.12    2.12
    CE1OC01-5    9:11:48  2008-12-01 20:14  2008-12-02 05:25   1174.64    2.13
    CE1OC01-4    9:11:32  2008-12-01 20:14  2008-12-02 05:25   1174.51    2.13
    CE1OC01-8    9:09:24  2008-12-01 20:14  2008-12-02 05:23   1172.49    2.13
    CE1OC01-1    9:05:55  2008-12-01 20:14  2008-12-02 05:20   1188.43    2.18
    CE1OC01-2    9:00:47  2008-12-01 20:14  2008-12-02 05:14   1184.52    2.19
    CE1OC01-7    8:54:06  2008-12-01 20:14  2008-12-02 05:08   1173.23    2.20
    CE1OC01-3    8:52:22  2008-12-01 20:14  2008-12-02 05:06   1179.91    2.22
    CE1OC01-10   8:45:09  2008-12-01 20:14  2008-12-02 04:59   1171.90    2.23
    CE1OC01-6    8:28:10  2008-12-01 20:14  2008-12-02 04:42   1172.46    2.31
    PLPO         0:25:16  2008-12-01 20:14  2008-12-01 20:39     92.70    3.67
                90:16:27  2008-12-01 20:14  2008-12-02 05:26  11856.91

  • Using function in where clause

    I have created a function as follows
    create or replace FUNCTION get_codes RETURN varchar2 IS
    scodes varchar2(50) := 'A1,A2';
    BEGIN
    scodes := '('''||REPLACE(scodes,',',''',''')||''')';
    return scodes;
    END;
    this function returns ('A1','A2')
    now i want to use this in where clause, both below statements fetches no rows
    select * from tablea where code in (select get_codes from dual);
    select * from tablea where code in get_codes;
    but the following will fetch rows
    select * from tablea where code in ('A1','A2')
    how to use function in where clause
    Thanks

    Hi,
    The code that works:
    where code in ('A1','A2')is testing whther code is either of two 2-character strings, A1 or A2.
    The ones that don't work, such as:
    where code in get_codes;are comparing code to one 9-character string: 'A1','A2', where characters 1, 4, 6 and 9 are single-quotes. (The function can only return one value.)
    You can use dynamic SQL to embed that 9-character string in part of your query, where it will be interpreted as two 2-character strrings.
    [Oracle Base|http://www.oracle-base.com/articles/misc/DynamicInLists.php] and AskTom have good pages on the subject of dynamic IN-lists.
    Of you can use INSTR or LIKE:
    where INSTR ( get_codes
                , '''' || code || ''''
                ) > 0

  • Qualifying Expression and WHERE CLAUSE Extension

    I would like to know the exact difference between 'Qualifying Expression and WHERE CLAUSE Extension'. Since both are meant to contain some CONDITION that would facilitate the Edit Check's success, So I am sometimes a bit confused with these too as to when to use what.
    Can someone help Please??

    As you can tell from my previous posts (requests!) - I'm a newbie to OC.
    From the documentation - it appears that both Qualifying expression and Where Clause work the same way but the way they execute is different.
    Qualifying expression is applied after the fetch (key fields and question response data from DCM cursor i.e., after the cursor fetches the data) and Where clause filters before QG fetch.
    HTH

  • Using Date in where clause

    Hello all,
    I am new to Oracle, currently using 10G + aspvbscript.
    I've been trying to query data using date in where clause but nothing seems to work.
    The column is in date format.
    It gets printed out like this: 5/1/2010 11:21:19 AM
    I tried using this query:
    SELECT * from table where TRUNC(user_date) > to_date('FEB-01-2010:00:00:00','mm-dd-yyyy:HH24:MI:SS') order by user_date asc.
    It does return an output but it returns everything in table and does not take WHERE clause into consideration however, it does sort the date in ascending order.
    I've tried getting rid of TRUNC tried to format date in a different way but no such luck.
    Please point me to the right direction.
    Thanks.

    Welcome to the forums!
    In cases like this it is helpful if you can provide the following information:
    1. Oracle version (SELECT * FROM V$VERSION)
    2. Sample data in the form of CREATE / INSERT statements.
    3. Expected output
    4. Explanation of expected output (A.K.A. "business logic")
    5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.
    I'll try and take a stab at your request based on the data given. What your query says is that it will return all rows that have a date greater then 2/1/2010 (MM/DD/YYYY). If your query is returning all rows then maybe the possibility exists that all the dates in the table are greater then 2/1/2010. Have you checked all dates to see if this is the case?
    Also, one note about your TO_DATE() function.to_date('FEB-01-2010:00:00:00','mm-dd-yyyy:HH24:MI:SS')The date format does not match the string you are using with respect to month. Your string has 'FEB' but the format is 'MM' which is the numeric representation of the month. Although Oracle was able to convert it to the proper date on my system you should try and maintain consistency between the string and the date format used.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Using distinct in 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

    Additionally to the fact that we don't have an idea on the expected output, I can't understand the comparison of ROWIDs in your query. These are the logical addresses where the data reside in the disks, comparing them doesn't make sense to me; Oracle DB defines where to store, based on space availability in the disk allocation to the database occupation - and NOT in a logical sequence.
    Maybe the existing row is stored in an address that is not a higher number than other, and so it is not being retrieved in your sub-query - hence your test for distinction is failing.

  • Can i use Decode in Where clause

    Hi,
    Can i use Decode in Where clause Please Do the need full on the same.
    Thanks,
    Sanjeev.

    set serveroutput on
    DECLARE
    posn  PLS_INTEGER := 0;
    empid PLS_INTEGER := 178;
    x     NUMBER;
    BEGIN
      SELECT NVL(SUM(ah.quantity * ah.saleprice * ap.payoutpct), 0)
      INTO x
      FROM accessoryhistory ah, payoutpercentage ap,
      sku s, store st
      WHERE empid = DECODE(posn,
                              0, st.areadir,
                              1, st.areamgr,
                              2, NVL(st.storemgr1, st.storemgr2),
                              3, NVL(st.asstmgr1, NVL(st.asstmgr2,
                           st.asstmgr3)))
      AND ah.statustype IN ('ACT', 'DEA')
      AND ah.store = st.store
      AND s.dbid = ah.dbid
      AND s.sku = ah.sku
      AND ap.productgroup = s.productgroup
      AND ap.position = posn;
      dbms_output.put_line(x);
    END;
    /http://psoug.org/reference/decode_case.html

  • Why I cannot use RowID in where clause but can use it in order by clause

    I am on SQL Server 2008.
    1. If I use
    SELECT (ROW_NUMBER()  over
    (order by ImportId, ScenarioId, SiteID, AssetID, LocalSKUID, WEEKID, MonthID)) RowID, * 
      FROM [JnJ_Version1].[dbo].[td_Production_Week]
      order by RowID
    Statement works
    But
    2. If I use
    SELECT (ROW_NUMBER()  over
    (order by ImportId, ScenarioId, SiteID, AssetID, LocalSKUID, WEEKID, MonthID)) RowID, * 
      FROM [JnJ_Version1].[dbo].[td_Production_Week]
      where  RowID > 10000
    I get error, RowID is an invalid column Name why? How to correct query 2.

    This is due to the logical evaluation order of a SELECT statement. Logically, a SELECT statement is computed in the order:
    FROM (which includes JOIN)
    WHERE
    GROUP BY
    HAVING
    SELECT
    ORDER BY
    OFFSET
    Thus, you can use what is defined in the SELECT list in the ORDER BY clause, but not in the WHERE clause.
    In the case of row_number(), this has immediate repurcussions. row_number() is computed from the rows as they arrive the SELECT clause, and if you then you would filter on the value in the WHERE clause you would be going round in circles.
    To do what you are looking for, you use a nested table, for instance with a CTE:
    WITH numbering AS (
       SELECT (ROW_NUMBER()  over
    (order by ImportId, ScenarioId, SiteID, AssetID, LocalSKUID, WEEKID, MonthID)) RowID, * 
      FROM [JnJ_Version1].[dbo].[td_Production_Week]
    SELECT *
    FROM   numbering
    WHERE  RowID > 10000
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Regd. using functions in where clause

    Hi All,
    I need to apply a set of functions in sysdate and use that in a where clause to compare. My question is, will these functions on sysdate be executed for every record in the tables that I use? Will this have performance impact when i have millions of records returned by the select?
    Below is the scenario:
    Select * from table A inner join table B on A.c1 = B.c1 where
    TO_NUMBER(TO_CHAR(TRUNC(LAST_DAY(ADD_MONTHS(SYSDATE, -1))),'YYYYMMDD')) BETWEEN Date1 and Date2
    Regards,
    Raj.D

    1005330 wrote:
    I need to apply a set of functions in sysdate and use that in a where clause to compare. My question is, will these functions on sysdate be executed for every record in the tables that I use? Will this have performance impact when i have millions of records returned by the select?
    Below is the scenario:
    Select * from table A inner join table B on A.c1 = B.c1 where
    TO_NUMBER(TO_CHAR(TRUNC(LAST_DAY(ADD_MONTHS(SYSDATE, -1))),'YYYYMMDD')) BETWEEN Date1 and Date2
    Test it on a small data set - run a query and check the execution plan to see what the predicate section tells you.
    Oracle OUGHT to be smart enough to recognise that you've got a constant that it need only calculate once. If not, then change the usage to read:
        (select TO_NUMBER(TO_CHAR(TRUNC(LAST_DAY(ADD_MONTHS(SYSDATE, -1))),'YYYYMMDD')) from dual) BETWEEN Date1 and Date2Note, by the way, that 'constant between col1 and col2' is generally a tough one as far as efficiency is concerned; it translates to:
        col1 <= constant
    and col2 >= constantIn many cases this means oracle has to access a large volume of data (for one of the predicates) and then filter that data (with the other predicate). A typical damage limitation strategy is to create an index on the two columns, arrangin the column order to minimise the range scan on the first column.
    Depending on your data patterns and the nature of the predicate there are alternative optimiisation strategies.
    Regards
    Jonathan Lewis

  • OVD database adapter and WHERE clause

    Hi all,
    We're using OVD 11g, and have a database adapter defined against a table in an Oracle schema. The adapter correctly maps columns to LDAP attributes and creates a virtual directory.
    However the table contains users we don't want to appear in the directory. We have no control over the data in the table hence we cannot remove the unwanted users from the source.
    Is there any way we can specify a WHERE clause in the database adapter which limits the users pulled out of the table and created in the virtual directory? Something like WHERE organisation = 'Company A'.
    Thanks
    Alan

    You can specify LDAP filters in Routing Include/Exclude in Adapter configuration which will eventually translate into where clause for the database adapter.
    For example if you want to exclude users from organization A all you have to do is Add an LDAP filter for that organization in Routing Exclude...
    Same is the case for Routing Include.
    Hope this helps,
    Saggu

  • Clarification on using function in where clause of oracle sql query

    I have an issue in regarding function using where clause of sql query..
    We are facing performance issue while executing query, so in what ways to improve the performance of the query which i have posted below.
    select col ,case when my_function(parameter)
    from tab1 a ,tab2 b,tabl3 c
    where a.column1=b.column2
    and b.column3 =c.column6
    and my_function(parameter)>0
    Regards
    Dinesh
    Edited by: wild fire on May 18, 2012 4:15 PM

    Dinesh,
    remind that when you use a function in the where clause it normally will get started for each record in the table.
    So your answer is two-fold:
    1. make the function only start when needed by adding a function based index on the table (this will make inserts and updates slower)
    2. make the function faster by adding the DETERMINISTIC clause if possible. this will make Oracle "cache" the result of the function.
    Regards,
    Richard
    blog: http://blog.warp11.nl
    twitter: @rhjmartens
    If this question is answered, please mark the thread as closed and assign points where earned..

Maybe you are looking for

  • Extension error while running but not during debug

    Hi all, I'm using JDev 10.1.2 and I developed an extension for it. This extension guides the user to the creation of a sql file through a sequence of frames. While in debug mode, this extension works without the smallest problem, but when i restart j

  • Payment terms to change for every supplier...

    Hi, Is it possible to run a transaction in SAP to change payment terms on every suppliers in a company code...? Appreciate your quick response. Thank you

  • BADI/Exit: Changing IDoc Control Record

    HI, do you know a way to modify the IDoc Control Record for MASTERDATA IDocs like CREMAS/DEBMAS/ etc ? there are a lot of IDOC Badis and Exit´s but without changing the EDIDC. any ideas ? Regards, Gordon

  • Reformatting Macbook Pro Hard Drive

    OK ... Here's my issue. Our 2011 Macbook Pro is one of the ones associated with the recall and fix that Apple is finally doing. http://www.apple.com/support/macbookpro-videoissues/ When it became completely unusable last year we had to retrieve our d

  • One question about ROS ()

    HI,my experts:    I work in SRM7.0 .I have 2 clients  in my system .Client 100 -EBP ;Client 200-ROS (SUS). The both clients are on the same server .    Now ,1.I have create new ORG. in ROS Client ,and create user who is also in the EBP client.