Searching for a better design for function in sql where clause

We are using for a while a parameter management framework based on parameter hierarchy and matrix fully internazionalized. For implementation flexibility we never use primary key to access directly the parameter but used a function that return the corresponding primary key by selecting it in an array in a package with a parameter name or external identification number that never change.
All is working well ... the system is very flexible ... we are as developper very happy because we can offer a centralized management parameter system for the whole application.
Our problem is regarding the lack of sql performance when the packaged function are used in sql ... it seem that they are executed each time for earch row instead of only once and bind to the sql (as a bind variable). This is really a big issue. We solve the problem in PL/SQL by getting the parameter in variable and bind it the sql but it is not possible everythere and we will be interesting to know if somebody had similar problem and how we may solve the problem.
Thanks a lot

    select  contractdate.contract_i
                            , contractdate.contractdate
                    from    contractdate
                            ,     (     select     contractdate.contract_i
                              , max( nvl( contractdate.dateto, sysdate) ) dateto
                         from     contractdate
                         where     contractdate.t_contractdate_i = firstexpiry
                         group by contract_i
                    ) contractdatelast
                    where     contractdate.contract_i = contractdatelast.contract_i
                    and     nvl( contractdate.dateto, sysdate ) = nvl( contractdatelast.dateto, sysdate )
                    and     contractdate.t_contractdate_i = t_contractdate_ipar.fgetflextypologyclassitem_i( t_contractdate_ipar.fis1stexpiry )t_contractdate_ipar.fgetflextypologyclassitem_i is the function that return the primary key corresponding to the internal identification number
t_contractdate_ipar.fis1stexpiry is the function that return the internal identification number
An array in a package contains class and items internal identification number with the corresponding primary key used in the whole application (label, description in the user language also). All data for item (parameters) are stored in the flextypologyclassitem table that is referred by all parameters in the application. An application manage this table as a centralized parameter system.

Similar Messages

  • Error message - image exceeds size save for web was designed for

    When I try to Save to Web in Illustrator CS3, I get the following error message: "the image exceeds the size save for web was designed for". Even when I click that I want to go ahead and save it, it sends another error that reads "could not complete this operation. the rasterized image exceeded the maximum bounds for Save for Web".
    Earlier in the day yesterday, I saved for web with no issue. NOw, it doesn't matter how small my design is, it is giving this error.
    Please advise.

    > So in CS3 Save for Web grabs the Artboard, neither the artwork nor the Crop Area/Marks area?
    Creating a new document using "Basic RGB Document" and then "Save for Web & Devices" crops either to the artboard or to the artwork as selected from the "image size" tab in the save-for-web window.
    If your artwork extends beyond the artboard, selecting "clip to artboard" will obviously eliminate everything outside the artboard. Unchecking it will crop the image to the artwork in the file (and thankfully not any artwork that is hidden).
    If you make crop marks in the file, you can choose to either clip to the artboard or not. Not will clip to the crop marks, acting as kind of a secondary artboard.
    ETA:
    You can choose which type of on-screen file type you want your output to be. From GIF, JPG, PNG-8, PNG-24, SWF, SVG, and WBMP. And whether or not you want transparency in those formats that support it.

  • SUBSTR function in the where clause

    HI
    I want to get a number of 15 digits from a column where the user only know the last 10 digits.
    So that when the user enter a number with 10 digits, only the record of that specific number should be displayed.
    And then when the user did not enter any number all the records in the table should be displayed.(this part works fine)
    The problem is: when the user enters any last digits( last, second last, thirth last and so on) the records which satisfy this are retrieved, which is not supose to be the case.
    I' am trying to use the substr function in the where clause but I'm not sure if it's working or not becasue the result of the query is just the same as before i used the substr.
    Thanks

    better to pad with '*' me thinks in case u have a number ending with 0's:
      1  select empno,ename
      2  from emp
      3* where empno like '%'||lpad('&1',2,'*')
    SQL> /
    Enter value for 1: 0
    old   3: where empno like '%'||lpad('&1',2,'*')
    new   3: where empno like '%'||lpad('0',2,'*')
    no rows selected
    SQL> /
    Enter value for 1: 00
    old   3: where empno like '%'||lpad('&1',2,'*')
    new   3: where empno like '%'||lpad('00',2,'*')
         EMPNO ENAME
          7900 JAMES
    SQL> /
    Enter value for 1:
    old   3: where empno like '%'||lpad('&1',2,'*')
    new   3: where empno like '%'||lpad('',2,'*')
         EMPNO ENAME
          7369 SMITH
          7499 ALLEN
          7521 WARD
          7566 JONES
          7654 MARTIN
          7698 BLAKE
          7782 CLARK
          7788 SCOTT
          7839 KING
          7844 TURNER
          7876 ADAMS
         EMPNO ENAME
          7900 JAMES
          7902 FORD
          7934 MILLER
    14 rows selected.

  • CBO and functions in the WHERE clause

    Hi,
    Can anyone point me to any documents describing how the cost based optimizer treats functions in a WHERE clause?
    For example, in
    select ...
    from   ...
    where  ...
    and    my_package.my_function( t.some_column ) = 'Y'
    ...does the CBO treat "my_package.my_function" as a black box or does it go into the body of "my_package.my_function" and take into consideration the associated costs of all the SELECT statements in the function?
    I've tried a few simple tests to answer the question, but I've received conflicting results. Has anyone had any experience with this?
    Thanks in advance for your help.

    Thanks for the info. Justin.
    <br><br>
    I think I've solved my problem, but I'll repeat it here in case it helps anyone else. Here is a very simplified example of what I was seeing.
    <br><br>
    A query like this:
        select
          a.party_id, b.cust_account_id
        from
          hz_parties a,
          hz_cust_accounts b
        where
          a.party_id = b.party_id
          and mis_hz_merge_veto_pkg.party_merge_will_be_vetoed(a.party_id) = 'N'was returning a drastically different execution plan than this
        select
          a.party_id, b.cust_account_id
        from
          hz_parties a,
          hz_cust_accounts b
        where
          a.party_id = b.party_id
          and mis_hz_merge_veto_pkg.account_merge_will_be_vetoed(b.cust_account_id) = 'N'I initially thought the difference was due to the fact that I was using different functions in the last line, but then I tried this version
        select
          a.party_id, b.cust_account_id
        from
          hz_parties a,
          hz_cust_accounts b
        where
          a.party_id = b.party_id
          and mis_hz_merge_veto_pkg.party_merge_will_be_vetoed(b.party_id) = 'N'and found that it gave me a different execution plan than the first SELECT as well, even though it used the same function. The difference seems to stem from the columns I use in the function parameter and not the choice of function.

  • Call a function in a where clause of a select

    hello,
    is it possible to call a function in a where clause of a select????
    ex: select col1, col2
    from my_table
    where my_package.my_function(32199, 2008, col3, 'P');
    and i have error message "ORA-00920: invalid relational operator"
    FUNCTION my_function(v_matricule IN NUMBER,
              v_Year IN NUMBER,
              v_date IN DATE,
              v_type IN CHAR DEFAULT 'P')
    RETURN BOOLEAN;
    @+Rosagio

    user10225229 wrote:
    hello,
    is it possible to call a function in a where clause of a select????
    ex: select col1, col2
    from my_table
    where my_package.my_function(32199, 2008, col3, 'P');
    and i have error message "ORA-00920: invalid relational operator"
    FUNCTION my_function(v_matricule IN NUMBER,
              v_Year IN NUMBER,
              v_date IN DATE,
              v_type IN CHAR DEFAULT 'P')
    RETURN BOOLEAN;You can call a function if it returns a datatype that is supported by SQL. BOOLEAN is NOT supported by SQL.

  • Function/Subrutine and where clause

    Hi,
      Is it possible to define a subroutine.function and use it in the SQL where clause in ABAP??
      If so, any reference code??
    Regards,
    Kit

    Hi Kit,
    It  is not possible to define a subroutine.function and use it in the SQL where clause in ABAP.
    But you can use dynamic where clause. Try F1 on select.
    Example
    Display of flight connections after input of airline and flight number:
    PARAMETERS: carr_id TYPE spfli-carrid,
                conn_id TYPE spfli-connid.
    DATA:       where_clause TYPE  STRING,
                and(4),
                wa_spfli TYPE spfli.
    IF carr_id IS NOT INITIAL.
      CONCATENATE 'CARRID = ''' carr_id '''' INTO where_clause.
      and = ' AND'.
    ENDIF.
    IF conn_id IS NOT INITIAL.
      CONCATENATE where_clause and ' CONNID = ''' conn_id ''''
        INTO where_clause.
    ENDIF.
    SELECT * FROM spfli INTO wa_spfli WHERE (where_clause).
      WRITE: / wa_spfli-carrid, wa_spfli-connid, wa_spfli-cityfrom,
               wa_spfli-cityto, wa_spfli-deptime.
    ENDSELECT.
    Regards,
    Clemens

  • Searching for a more elegant way to write my where clause.

    Hi,
    I have a table T which has two columns : X(Varchar2(100)), and Y(Varchar2(100)).I want to know all the rows in the table T for which two conditions are simultaneously true: the first condition is X is not null or Y is not null, and the second condition is not(X  is not null and Y is not null). So I write my query like below:
    select *
    from T
    where (X is not null or Y is not null) and  not(X  is not null and Y is not null)But the way I formulate my where clause doesn't seem elegant to me. Please, could I obtain the same result with a more elegant where clause?
    Thanks.

    <font face="courier">
    where (X is not null or Y is not null) and <font color="red">not(X is not null and Y is not null)</font><br>
    <font color="red">De Morgan</font><br>
    where ((X is not null) or (Y is not null)) and (<font color="red">not(X is not null) or not(Y is not null)</font>)<br><br>
    where ((X is not null) or (Y is not null)) and (<b>not(X is not null)</b> or <b>not(Y is not null)</b>)<br>
    <b>double negation</b><br>
    where ((X is not null) or (Y is not null)) and (<b>(X is null)</b> or <b>(Y is null)</b>)<br><br>
    where (<font color="green">(X is not null) <b>or</b> (Y is not null)</font>) <font color="blue"><b>and</b> ((X is null) or (Y is null))</font><br>
    Distributivity of <font color="blue"><b>and</b></font> over <font color="green"><b>or</b></font><br>
    where (<font color="green">(X is not null)</font> <font color="blue"><b>and</b> ((X is null) or (Y is null))</font>) <font color="green"><b>or</b></font> (<font color="green">(Y is not null)</font> <font color="blue"><b>and</b> ((X is null) or (Y is null))</font>)<br><br>
    where (<font color="red">(X is not null) <b>and</b></font> <font color="magenta">((X is null) <b>or</b> (Y is null))</font>) or (<b>(Y is not null) and ((X is null) or (Y is null))</b>)<br>
    Distributivity of <font color="red"><b>and</b></font> over <font color="magenta"><b>or</b></font> applied to the <b>second term</b> too<br>
    where ((<font color="red">(X is not null) <b>and</b></font> <font color="magenta">(X is null)</font>) <font color="magenta"><b>or</b></font> (<font color="red">(X is not null) <b>and</b></font> <font color="magenta">(Y is null)</font>)) or <br>      ((<b>(Y is not null) and (X is null)</b>)<b> or </b>(<b>(Y is not null) and (Y is null)</b>))<br><br>
    <font color="green"><b>Negation</b></font><br>
    where ((<font color="green"><strike>(X is not null)</strike> <b>not(Y is null)</b></font> and (X is null)) or ((X is not null) and (Y is null))) or <br>      (((Y is not null) and (X is null)) or (<font color="green"><strike>(Y is not null)</strike> <b>not(Y is null)</b>)</font> and (Y is null)))<br><br>
    where ((<font color="blue">not(X is null) and (X is null)</font>) or ((X is not null) and (Y is null))) or <br>      (((Y is not null) and (X is null)) or (<font color="blue">not(Y is null) and (Y is null)</font>))<br>
    <font color="blue">Complementation</font><br>
    where ((<font color="blue">false</font>) or ((X is not null) and (Y is null))) or <br>      (((Y is not null) and (X is null)) or (<font color="blue">false</font>))<br><br>
    <b>where ((X is not null) and (Y is null)) or ((Y is not null) and (X is null))</b><br><br>
    preferring clarity (in the eye of beholder as always) over efficiency<br><br>
    <b>where x || y in (x,y)</b><br><br>
    Regards
    Etbin
    </font>
    Edited by: Etbin on 28.8.2011 11:45
    steps separated with empty lines, negation enhanced

  • No output for XML Publisher Report using CASE/DECODE in Where Clause

    Hi,
    I've a business requirement to modify an existing report which has two input parameters,
    -> p_statcode (Closed Status) which can have values 'Y' or 'N'
    -> p_overdue (Overdue Flag) which can have values 'Y' or 'N'
    The Overdue Flag is an evaluated column having values of Y/N and it is evaluated as follows,
    ONTF_MOD_VAL(NVL (
                                         (TRUNC (SYSDATE)
                                          - (TO_DATE (oe_order_lines.attribute18,
                                                      'DD-MON-RRRR')
                                             + TO_NUMBER (fnd_lookup_values.meaning))),
                                         0
                            overdue_flagThe user requirement now is they needs to be a third option for parameter p_overdue called ALL,
    passing which the output should include records having
    p_statcode is Y ELSE p_statcode is N AND p_overdue is Y OR p_overdue is N
    In other words records having both Y and N vlaues for Overdue Flag have to be returned irrespective of the value given to Closed Status.
    Original where clause in the Data Definition file is as follows,
    WHERE Closed_Status = nvl(:p_statcode,Closed_Status)
                       AND overdue_flag = nvl(:p_overdue,overdue_flag)My modified code is as follows,
    WHERE   Closed_Status = NVL (:p_statcode, Closed_Status)
             AND overdue_flag = (CASE
             WHEN :p_overdue = 'Y' THEN 'Y'
             WHEN :p_overdue = 'N' THEN 'N'
             ELSE overdue_flag
             END)
    OR
    WHERE   Closed_Status = NVL (:p_statcode, Closed_Status)
             AND overdue_flag = DECODE (:p_overdue, 'Y', 'Y', 'N', 'N',overdue_flag)Both approaches have the same problem.
    The output is in EXCEL format. The modified query works fine for p_overdue as Y or N but when p_overdue is passed as ALL it returns an empty EXCEL sheet with just the report output column headers.
    Any help as to why this is the case ?? What is wrong in my approach ?
    Regards,
    Vishal

    not clear about p_overdue = ALL
    which values needed for p_overdue = ALL ?
    try smth like
    WHERE   Closed_Status = NVL (:p_statcode, Closed_Status)
    AND (
       overdue_flag = DECODE (:p_overdue, 'Y', 'Y', 'N', 'N',overdue_flag) and :p_overdue != 'ALL'
       or
      :p_overdue = 'ALL' and (overdue_flag = 'Y' or overdue_flag = 'N')
    )for overdue_flag which has more then 'Y', 'N' values
    if overdue_flag only in ('Y','N') then
    WHERE   Closed_Status = NVL (:p_statcode, Closed_Status)
    AND (
       overdue_flag = DECODE (:p_overdue, 'Y', 'Y', 'N', 'N',overdue_flag) and :p_overdue != 'ALL'
       or
      :p_overdue = 'ALL'
    )

  • Function calls in WHERE clause

    Hello,
    I have several procedures that all share a similar snippet of code in the WHERE clause. I tried to make this a function but, using a function increases the execution time of the calling procedure by a factor of ten. I am currently on 8i and will be moving to 9i soon. Was just wondering if there will be any performance increase from this type of function call on 9i vs. 8i.
    Thanks
    :)

    sometimes a perforance hit it worth the maintability factor.I disagree, strongly. The developer's Prime Directive is to make the user's experience a good one. Inflicting poorly performing code on the user in the name of maintinability is not on.
    Q: Why does the code have to be maintained so much?
    A: Because the users' keep complaining about how slow it runs....
    [SOAPBOX]
    Of course in the real world things get confused and it can be quite difficult to distinguish programmers' issues - encapsulation, flexibility, maintainability - from users' issues - correctness, completeness, performance.
    But the relative worth of these things is easy to assess. A highly-modular parameter driven architecture that delivers the wrong answer and takes an age to do it ain't worth jack. Even if it is so maintainable that it's easy to fix every bug in it.
    [SOAPBOX]
    "Whatever waits for us behind those doors, we have a better chance of survival if we stick together." Gladiator
    Cheers, APC

  • To_Date function in the Where Clause

    Hello All,
    I'm having an issue using the to_date function that has me quite perplexed.
    I have two varchar2 fields, one with a date value in the format Mon, DD YYYY, the other has a time value in the format HH:MI PM.
    When I run my query one of the columns I retrieve looks like this TO_DATE (d4.adate || e4.atime, 'Mon DD, YYYYHH:MI PM'). The two fields are concatenated together and converted to a date. This works fine.
    My problem occurs when I attempt to apply the same logic to the where clause of the aforementioned query. e.g. when I add the following criteria to my query and TO_DATE (d4.adate || e4.atime, 'Mon DD, YYYYHH:MI PM') <= sysdate I get an ORA-01843: not a valid month error.
    To further illustrate my problem here are the two queries:
    Select d4.adate, e4.atime, TO_DATE (d4.adate || e4.atime, 'Mon DD, YYYYHH:MI PM')
    from ....
    where ....
    The above query works.
    Select d4.adate, e4.atime, TO_DATE (d4.adate || e4.atime, 'Mon DD, YYYYHH:MI PM')
    from ....
    where ....
    and TO_DATE (d4.adate || e4.atime, 'Mon DD, YYYYHH:MI PM') <= sysdate
    The second query does not work.
    The tables used and the limiting criteria are identical, except for the last one.
    Does anyone have any ideas why this could be happening.
    er

    Hello,
    Check this out. It does work. Do cut n paste sample
    data from your tables.
    SQL> desc test
    Name Null? Type
    ID NUMBER
    DDATE VARCHAR2(20)
    DTIME VARCHAR2(20)
    SQL> select * from test;
    ID DDATE DTIME
    1 Jan, 10 2006 12:32 PM
    2 Mar, 11 2005 07:10 AM
    3 Apr, 13 2006 03:12 AM
    4 Nov, 15 2003 11:22 PM
    5 Dec, 20 2005 09:12 AM
    6 Oct, 30 2006 10:00 AM
    7 Jan, 10 2006 12:32 PM
    8 Apr, 11 2005 07:10 AM
    9 May, 13 2006 03:12 AM
    10 Sep, 15 2003 11:22 PM
    11 Oct, 20 2005 09:12 AM
    12 Dec, 30 2006 10:00 AM
    12 rows selected.
    SQL> select id, ddate, dtime,
    2 to_date(ddate||dtime,'Mon, DD YYYYHH:MI PM') AA,
    A,
    3 to_char(to_date(ddate||dtime,'Mon, DD YYYYHH:MI
    MI PM'),'Mon, DD YYYYHH:MI PM') BB
    4 from test;
    ID DDATE DTIME
    DTIME AA BB
    1 Jan, 10 2006 12:32 PM
    12:32 PM 10-JAN-06 Jan, 10 200612:32 PM
    2 Mar, 11 2005 07:10 AM
    07:10 AM 11-MAR-05 Mar, 11 200507:10 AM
    3 Apr, 13 2006 03:12 AM
    03:12 AM 13-APR-06 Apr, 13 200603:12 AM
    4 Nov, 15 2003 11:22 PM
    11:22 PM 15-NOV-03 Nov, 15 200311:22 PM
    5 Dec, 20 2005 09:12 AM
    09:12 AM 20-DEC-05 Dec, 20 200509:12 AM
    6 Oct, 30 2006 10:00 AM
    10:00 AM 30-OCT-06 Oct, 30 200610:00 AM
    7 Jan, 10 2006 12:32 PM
    12:32 PM 10-JAN-06 Jan, 10 200612:32 PM
    8 Apr, 11 2005 07:10 AM
    07:10 AM 11-APR-05 Apr, 11 200507:10 AM
    9 May, 13 2006 03:12 AM
    03:12 AM 13-MAY-06 May, 13 200603:12 AM
    10 Sep, 15 2003 11:22 PM
    11:22 PM 15-SEP-03 Sep, 15 200311:22 PM
    11 Oct, 20 2005 09:12 AM
    09:12 AM 20-OCT-05 Oct, 20 200509:12 AM
    12 Dec, 30 2006 10:00 AM
    10:00 AM 30-DEC-06 Dec, 30 200610:00 AM
    12 rows selected.
    SQL> select id, ddate, dtime,
    to_date(ddate||dtime,'Mon, DD YYYYHH:MI PM')
    2 from test
    3 where id > 3
    4 and to_date(ddate||dtime,'Mon, DD YYYYHH:MI PM')
    ') <= trunc(sysdate);
    ID DDATE DTIME
    DTIME TO_DATE(D
    4 Nov, 15 2003 11:22 PM
    11:22 PM 15-NOV-03
    5 Dec, 20 2005 09:12 AM
    09:12 AM 20-DEC-05
    7 Jan, 10 2006 12:32 PM
    12:32 PM 10-JAN-06
    8 Apr, 11 2005 07:10 AM
    07:10 AM 11-APR-05
    10 Sep, 15 2003 11:22 PM
    11:22 PM 15-SEP-03
    11 Oct, 20 2005 09:12 AM
    09:12 AM 20-OCT-05
    6 rows selected.
    SQL> select id, ddate, dtime,
    to_date(ddate||dtime,'Mon, DD YYYYHH:MI PM')
    2 from test
    3 where id > 3
    4 and to_date(ddate||dtime,'Mon, DD YYYYHH:MI PM')
    ') <= sysdate;
    ID DDATE DTIME
    DTIME TO_DATE(D
    4 Nov, 15 2003 11:22 PM
    11:22 PM 15-NOV-03
    5 Dec, 20 2005 09:12 AM
    09:12 AM 20-DEC-05
    7 Jan, 10 2006 12:32 PM
    12:32 PM 10-JAN-06
    8 Apr, 11 2005 07:10 AM
    07:10 AM 11-APR-05
    10 Sep, 15 2003 11:22 PM
    11:22 PM 15-SEP-03
    11 Oct, 20 2005 09:12 AM
    09:12 AM 20-OCT-05
    6 rows selected.
    -SriSorry Sri, but I fail to see what you mean. How is what you're doing any different than what I'm doing?

  • Function use in where clause

    hi,
    can we use output of a function in where clause directly ?
    i.e
    select node(condition1) clause from dual;
    clause
    occupation='SALARY'
    then i want to use this output i.e clause string directly in select stmt.
    select * from abc_table where clause
    more strictly
    select * from abc_table where (select node(condition1) clause from dual)
    which is interpreted as
    select * from abc_table where occupation='SALARY'
    Is there any way to use functions in clause area ???
    I tried CURSOR but not workd for this
    Thanks in advance,
    Rup

    I cant really understand your problem
    --fn1 is a function
    sql>
    select fn1
    from dual;
    FN1 
    CLERK 
    sql>
    select * from emp
    where job = fn1;
    EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO 
    7369  SMITH  CLERK  7902  17-DEC-80  800     20 
    7876  ADAMS  CLERK  7788  23-MAY-87  1100     20 
    7900  JAMES  CLERK  7698  03-DEC-81  950     30 
    7934  MILLER  CLERK  7782  23-JAN-82  1300     10
    Message was edited by:
            jeneesh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Table function sensitive to where clause?

    Hi-
    In Oracle SQL, you can use the results of a PL/SQL function as a table with the "TABLE()" syntax. Example: "SELECT * FROM TABLE(myfunction(param1,param2)) ..."
    Is there any (non-crazy) way for the function to be aware of the conditions in the WHERE clause of that SELECT statement? For example, if I wanted "myfunction" to know that I had specified "WHERE param3=10' without having to put param3 in the function call, could this be done?
    Other SQL implementations support this. I know of at least one where you can map a table on top of a function where the "in" parameters can correspond to columns on the mapped table. Does Oracle support a similar syntax or strategy?

    Not sure if it is too crazy for you ;)
    But again I rely on a helper function since I am not sure about the purpose of the whole thing:
    SQL> create or replace function set_param (p varchar2) return varchar2
    as
    begin
      dbms_application_info.set_client_info(p);
    return p;
    end set_param;
    Function created.
    SQL> create or replace function myfunction
       return sys.dbms_debug_vc2coll
    as
    begin
       return sys.dbms_debug_vc2coll (sys_context ('userenv', 'client_info'));
    end myfunction;
    Function created.
    SQL> select   *
      from   table (myfunction())
    where   set_param (3) is not null
    COLUMN_VALUE                                                                   
    3                     Hope you get the idea ....

  • How to use a function in a Where Clause?

    Hi,
    I've got a doubt. If MY_FUNCT is a function that returns a boolean, can I use it in a where clause for writing a query like this?:
    select ...
    from table a
    where ...
    and MY_FUNC (a.field) = true
    Thanks!
    Edited by: Mark1970 on 2-lug-2010 3.27

    Bear in mind that this could kill your performance.
    Depending on what you're doing, how many tables and other predicates are involved, you might want to try to eliminate all other data early before applying your function predicate otherwise your function might be called more times than you might have imagined. Strategies for this include subquery factoring and the old ROWNUM trick for materialising an inline view.
    If performance is impacted, you might also want to consider using a function-based index provided that the function is deterministic.

  • Trouble using a function in the where clause

    Hello,
    I am using a function found at ask.tom.oracle.com which converts a long data type to a character. The function is returning an error when it is placed in the where clause. The sql statement , error message and the function from ask tom are shown below. Does anyone know how to fix this?
    <pre>
    SELECT A.FLDPHYSICAL,
    A.FLDEXPOSURE,
    A.FLDDATEDUE,
    A.FLDDATELAST,
    A.FLDEMPLOYEE,
    B.FLDBDATE,
    B.FLDMAILSTOP,
    B.FLDREC_NUM,
    B.FLDLNAME,
    B.FLDMI,
    B.FLDFNAME,
    B.FLDBDATE,
    B.FLDDEPT,
    B.FLDSTATUS,
    B.FLDSSN,
    B.FLDHOMEPHON,
    B.FLDWORKPHON,
    B.FLDID,
    B.FLDDIVISION
    FROM REQEXAM A,
    EMPLOYEE B,
    EMPLOYEE_MEMO C
    WHERE A.FLDEMPLOYEE = B.FLDREC_NUM
    AND b.flduserstr = c.fldrec_num
    AND OHM_PKG.GET_LONG('EMPLOYEE_MEMO', 'FLDDATA', C.ROWID) LIKE '%CDL YES%'
    AND A.FLDDATEDUE > '01/01/1900'
    AND A.FLDPHYSICAL ='CDP'
    ORDER BY B.FLDDIVISION,
    B.FLDLNAME,
    B.FLDFNAME,
    B.FLDMI,
    A.FLDDATEDUE
    The error message
    Error at Command Line:26 Column:4
    Error report:
    SQL Error: ORA-00904: "OHM_PKG"."GET_LONG": invalid identifier
    00904. 00000 - "%s: invalid identifier"
    create or replace
    PACKAGE OHM_PKG AS
    /* TODO enter package declarations (types, exceptions, methods etc) here */
    function getlong( p_tname in varchar2,p_cname in varchar2,p_rowid in rowid ) return varchar2;
    END OHM_PKG;
    create or replace
    PACKAGE BODY OHM_PKG AS
    function getlong( p_tname in varchar2,p_cname in varchar2,p_rowid in rowid ) return varchar2 as
    l_cursor integer default dbms_sql.open_cursor;
    l_n number;
    l_long_val varchar2(4000);
    l_long_len number;
    l_buflen number := 4000;
    l_curpos number := 0;
    begin
    dbms_sql.parse( l_cursor,
    'select ' || p_cname || ' from ' || p_tname ||
    ' where rowid = :x',
    dbms_sql.native );
    dbms_sql.bind_variable( l_cursor, ':x', p_rowid );
    dbms_sql.define_column_long(l_cursor, 1);
    l_n := dbms_sql.execute(l_cursor);
    if (dbms_sql.fetch_rows(l_cursor)>0)
    then
    dbms_sql.column_value_long(l_cursor, 1, l_buflen, l_curpos ,
    l_long_val, l_long_len );
    end if;
    dbms_sql.close_cursor(l_cursor);
    return l_long_val;
    end getlong;
    END OHM_PKG;
    </prev>

    Remove the '_' from the function's name as below:
    AND OHM_PKG.GETLONG('EMPLOYEE_MEMO', 'FLDDATA', C.ROWID) LIKE '%CDL YES%'

  • Better Design for EJB 3 and Java Web Dynpro

    Hi all,
    When using EJB Model on CE, to each method a Request and Response are generated. To a CRUD i've 4 methods.
    I've a Foo (JPA Entity).
    public Foo create(Foo)
    public Foo update(Update)
    public void remove(Foo)
    public List<Foo> findBy...
    I think that i could use a Single view for both create and update method. But i will need a separated context objects to each function.
    Request_<Bean>_create
    Request_<Bean>_update
    What is better in this case? a single method createOrUpdate on my EJB? Or a View to each operation?
    Best regards

    Hi all,
    Just to share my decision:
    My EJB continue with the methods.
    public Foo create(Foo)
    public Foo update(Update)
    public void remove(Integer)
    public List<Foo> findBy...
    Was generated one Request to each method.
    Request_<Bean>_create
    Request_<Bean>_update
    I've mapped the both on my Component controller and have created on view to edit and create a new record.
    When the record already exists i'm initializing the Request_<Bean>_createElement with record data, when is a new i've just initialize the new Foo object and put on currentElement of update.
    On the generic save method of controller, a test is done to decide if the Request<Create> or Request<Update> model Object.
    Best regards

Maybe you are looking for

  • How Can I change a report with base in another in the same dashboard?

    Hi, I need to publish two reports in a dashboard, the first report is a list of values and the second report is a chart. When I click in a value of the first report, the second report must change with the value selected from the first report. I first

  • Exception in javascript library when testing Mail app with IE9/ Safari

    Hi, I have almost finished my mail app, but a strange issue that only appears with IE9 prevents me from successfully completing the verification process and therefore I can not publish my app. The issue is very similar to this post, which could unfor

  • Itunes error: "There was a problem downloading "AroundMe".

    Ever since I downloaded the AroundMe app, I've been getting this error whenever I opened Itunes: There was a problem downloading "AroundMe". Part of the file seems to be corrupted. To redownload the file, choose "Check for Available Downloads " from

  • Itunes changes genre information on its own

    Often I find that when I begin playing a song, iTunes will change (or have changed prior to launch) the information that I have already stored for that song. i.e., if I double click a song to play it, iTunes will change the genre to something else on

  • SRM standalone and extended classic

    Hi Experts, Configuration: ECC 6.0  (with Ehp4 installed - (not activated)                        SRM 7.0 Just want to seek confirmation of my understanding re: SRM implementation scenarios. Is it possible to have a extended classic and standalone se