How to use a user defined function in where cluase condition

Hi,
I have designed a query by selecting some columns in the tables and some columns are retrieved directly from table and some columns are passing to a user defined function. Now my requirement is i need to use that user defined function result in oracle where condition clause.
Ex : select marketing_user_id,get_name(marketing_user_id),item_id,get_item_name(item_id),get_country_name(country_id),
from
where get_item_name(item_id) in ('x','y','z')
and get_country_name(country_id) in ('India','America','China');
When am i trying the query by above format i am getting the wrong resultset.
BR,
uma

I am not sure why your getting the wrong results but you should seriously reconsider the approach your are taking. Using functions like this is very ineffecient and should be avoided at all cost.

Similar Messages

  • How to use a user defined function in XI

    Hi Experts,
    I would like learn how to use a user defined function  in Xi during mapping . Is there any step by step on that.
    Besides during when me make communcaton channels I see the following tabs...Paramters ..Identifiers ...Module...
    The module that is given here ...where and how it is used.

    Hi,
    You can write UDFs in java in Graphical mapping to enhance your XI Graphical mapping functionality
    The steps for doing it would be:
    1. Click on Create New function Button found on Bottom left corner on your XI Mapping window.
    2. Write your java code.
    3. Run the Mapping Test as usual.
    >>The module that is given here ...where and how it is used.
    The adapters in the Adapter Framework convert XI messages to the protocols of connected external systems and the other way around. When doing so, some
    functionality might need to be added specific to a situation which is possible with the use of custom modules.
    Typical example would be validation of file content when using a File Adapter or modification of the message payload to a common content structure which is not supported by any of the standard SAP modules.
    An Adapter module is developed as an Enterprise Java Bean and is called locally by the Adapter.
    An example on modules :
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/da5675d1-0301-0010-9584-f6cb18c04805">How to develop a module for reading file name in a sender file adapter XI 3.0</a>
    Cheers,
    Chandra

  • How to use a user defined function module in IP

    Hi All,
    Can you please guide me on how to use a user created function module in IP? My requirement is to have 2 exit function modules to be used in IP to load the falt file data into a cube..
    Regards,

    Hi,
    /people/marc.bernard/blog/2007/11/25/how-to-load-a-file-into-sap-netweaver-bi-integrated-planning-part-1
    thanks to Marc Bernard
    Regards

  • How many types of user defined functions are there?

    how many types of user defined functions are there?

    Hi Ramakrishna,
    A user-defined function is only visible in the message mapping in which you created it. You can insert the function in the data-flow editor as a standard function by using the User-Defined function category.
    You can use the following user-defined functions:
    1.Simple functions, which can process individual field input values for each function call. Simple functions therefore expect strings as input values and return a string.
    2.Advanced functions, which can process several field input values for each function call. You can import either all field values of a context or the whole queue for the field in an array before calling the function. For more information, see Advanced User-Defined Functions.
        go through :
    http://help.sap.com/saphelp_erp2004/helpdata/en/22/e127f28b572243b4324879c6bf05a0/content.htm
         Advanced user-defined functions, which can process more than just individual field values.Instead, you can import a complete context or an entire queue for a field as an array before your function is called
        go through :
    http://help.sap.com/saphelp_erp2004/helpdata/en/f8/2857cbc374da48993c8eb7d3c8c87a/content.htm
    *Pls: Reward points if helpful*
    Regards,
    Jyoti

  • Using a User Defined Function as a constraint within a temporary table.

    Hello, 
    I am trying to create a temp table that uses a UDF in a constraint. I'm getting the following error message 
    Msg 4121, Level 16, State 1, Line 1
    Cannot find either column "dbo" or the user-defined function or aggregate "dbo.CK_LoseTeamSportExists", or the name is ambiguous.
    I've tested the function and it works in other contexts. Any idea? All code below:  
    Thanks, 
    - Bryon
    create function dbo.CK_LoseTeamSportExists (@loseteam int, @sportid int)
    returns bit
    as
    begin
    declare @return bit
    if exists 
    select TeamID, sportid from Link_TeamSport
    where 
    TeamID = @loseteam 
    and
    SportID = @sportid
    set @return = 1
    else set @return = 0
    return @return
    end
    go
    create table #check
    SportID int
    ,WinTeamID int
    ,LoseTeamID int
    ,check 
    (dbo.CK_LoseTeamSportExists(LoseTeamID,SportID) = 1)

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
    use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. 
    >> I am trying to create a temp table that uses a UDF in a constraint. <<
    You do not understand how SQL or any declarative language works! 
    We do not use UDFs (procedural programming)
    We do not use bit flags (assembly language).
    We do not use temp tables (mag tape files).
    We do not use integer as identifiers (what math do you do on them?)
    Your silly “Link_TeamSport” implies a pointer chain; we have no links in SQL. Where is the DDL? 
    Constraints are always predicates in any declarative language. 
    Do you know why you have to create a local variable to pass the non-relational flag back to the calling environment? FORTRAN I and II! These early languages has to use hardware registers in the first IBM computers to return results. In your ignorance, you mimic
    them! 
    We do not use if-then-else control flow in any declarative language. We have CASE expressions that we put where you have a local variable getting an assignment. 
    I see you also put the comma at the start of the line. We did that with punch cards, so we could re-use them 50 years ago. 
    In SQL, we would use REFERENCES to assure a team reference exists. We use names for teams because they are entities, not quantities: 
    CREATE TABLE Game_Results
    (sport_name CHAR(10) NOT NULL PRIMARY KEY,
     win_team_name CHAR(12) NOT NULL
      REFERENCES Teams(team_name)
       ON DELETE CASCADE,
     lose_team_name CHAR(12) NOT NULL
      REFERENCES Teams(team_name)
       ON DELETE CASCADE,
     CHECK (win_team_name <> lose_team_name)); 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • How to implement a user-defined function in a mathscript node

    I am trying to use a mathscript node that includes self-defined functions, but I always get an error. I tried to run an NI-example: MathScript using Riemann Zeta.vi ,and I got the same error I get when I run my own programmes:MathScript Node'MathScript Node' (zeta): User-defined function contains an error. I didn't change anything in that example, so what could be wrong?

    Try the Mathscript forum instead. Good luck.
    (Maybe start reading this, for example)
    Message Edited by altenbach on 11-18-2009 01:48 PM
    LabVIEW Champion . Do more with less code and in less time .

  • How can I find user defined functions in oracle

    Hello All,
    I need to find out what are the user defined functions available in my schema?
    Please let me know on what system tables shall I query and find out the user defined functions?
    Thanks,
    Milind.

    Thanks Satish,
    One more query. Can I find what are the parameters that needs to be passed?
    Here is what I have to do..
    I have to find all the accessible user defined functions. If I select one of them in my UI, I need to show the parameters used in the respective function.
    Please let me know if these parameters are stored anywhere..
    Thanks again,
    Milind

  • Alert messages  by using any User Defined Functions

    Hi friends,
          I  have one requirement.. that  when ever  my scenario successully  processed.. (file to file scenario) i need to raise a ALERT message  that is.. Successfully processed..  otherwise.. it should raise a Errors occured during Scenario..  These messages i want to display for my scenario..
       for this requirement what can i do.. my scenario is with out BPMs, so, can u explain with clear steps.. is there any USER DEFINED FUNCTION IS REQUIRED OR  with that UDF 's also  can we do.. and where can we do other settings..
    Thanks
    Babu

    Hi,
    Check this blog.
    /people/bhavesh.kantilal/blog/2006/07/25/triggering-xi-alerts-from-a-user-defined-function
    Regards,
    Sudheer.

  • User defined function in where IN clause

    Hi,
    I have a Function who returns in priview:
    (1,2,3,4)
    Now i am using this function in SQL where clause
    Select from debug where id in debug.debug_process()
    On execute select i am getiing ORA-01722 invalid number , i understand that functions return not only numbers but  character symbols too '(,)'
    Are it posible to use user defined function who do not return NUMBER in Where clause IN statement ?  If not what tips can sugest me for getting list of values for use in IN Clause?
    ID.
    Thanks!

    Hi,
    Please try:
    You can use SYS REFCURSOR for return your data.
    create or replace function get_debug return sys_refcursor is
         v_rc sys_refcursor;
       begin
         open v_rc for 'select * from debug where id in '|| debug.debug_process();
         return v_rc;
       end;
    Function created.
    Now, if we look at using this through SQL*Plus we first create ourselves a ref cursor variable to accept the results of the function, and then call the function to get the ref cursor back..
    SQL> var rc refcursor
    SQL> exec :rc := get_debug ;
    SQL> print rc;
    Regards
    Mahir M. Quluzade

  • How to distinguish the User-Defined-Function from Oracle Build-In function

    Hi Friends,
    I could get the function list form all_objects table by the SQL:
    select * from all_objects where object_type = 'FUNCTION'
    but there is no column in all_objects specify the function is build-in or user-defined.
    But I found in SQL Server there is a column "is_ms_shipped" in the sys.all_objects table. This column will specify the object is build-in or user-defined. I want to get the equivalent column in Oracle but failed.
    Could anyone tell me how to solve this problem?
    Thanks,
    Ricky

    Thanks Pavan.
    But if an user connects to database using "conn /as sysdba" syntax and creates a function. This user-defined funtion goes into the "SYS" schema also. I know it is not the best practise to create objects using sys user so I think your solution is right.
    Regards,
    Ricky

  • Use of user defined function in mathscript containing structure

    Hi, I am an beginner user of LabView's MathScript Module,
    I have the following problem when integrating my MATLAB code into LabView, for HMM:   In my program, I tried to call a user defined MATLAB function called 'mixgaussinit.m' It show this error ..
    Error -90162 occurred at Line 36, Column 20: unexpected char: '.'
    C:\HMMall\KPMstats\mixgauss_init.m
    Possible reason(s):
    LabVIEW:  A recognition error occurred while generating a stream of tokens.
    the line 36 of the file is this "mu = reshape(mix.centres', [d M])"
    mix.centers is a structure.. 
     How can this error be corrected?
    Solved!
    Go to Solution.

    I just noticed that these files appear to be under copyright. My first question is do you have the copyright permissions to post them in a public forum? If not then you may wish to delete them. That being said I have examined the code and it seems easy enough to work around your issues (provided you have the copyright permissions). The way to work around the issues is indeed to replace the struct fields with variables. This will of course require you to change a couple function definitions to input and output the neccesary variables which I believe was at most 5 variables. You will also need to redo the error checking code that uses a cell array. Altogether I estimate about 30 minutes of work. I would have given you the work around in these files had the files not been copyrighted. So, unfortunately, you will have to implement the work around yourself.
    Good luck!
    K Scott

  • Using user defined function in where clause

    Hi,
    I have defined function to get maximum date before passed date on the table 'A' and I'm using the same function to get details on that date from the same table 'A' in where clause.
    for ex:
    SELECT x,y,z
    FROM A
    WHREE a.date = max_date;
    But on one database instance it is running fine and on other it is going in a infinite loop.
    Pls help me out
    Thanks in advance,
    Prashant

    Hello Siva,
    sorry, but I don't understand your reply:
    This is not right forum to posting this question.
    You are from which module or working any 3rd party application.
    MaxDB 7.7.07.16 is the community version of MaxDb,
    we are not using it for SAP
    and no 3rd party software is required to reproduce my problem,
    Sql Studio or Database Studio will do.
    Regards,
    Silke Arnswald

  • User Defined function in Where clause

    DB:- 11.2
    Input:- 'ACCOUNTING,SALES'
    Output:- ('ACCOUNTING','SALES')
    WITH T AS (select 'ACCOUNTING,SALES' str from dual)
    select '('||regexp_replace(str,'([[:alpha:]]+)','''\1''')||')' from t /*this works*/I've created a function to use this in a where clause
    create or replace function ss(dname varchar2)
    return varchar2 is
    begin
      RETURN '('||regexp_replace(dname,'([[:alpha:]]+)','''\1''')||')';
    end; 
    select ss('ACCOUNTING,SALES') from dual --this worksBut when I am using this function in a where clause result is not coming..any thing i am missing?
    select * from dept where dname in ss('ACCOUNTING,SALES') --no rows

    940838 wrote:
    Output:- ('ACCOUNTING','SALES')Wrong. ('ACCOUNTING','SALES') is a list of two strings 'ACCOUNTING' and 'SALES' while your function returns a single string '(''ACCOUNTING'',''SALES'')'.
    IN clause requires a comma-separated list of values while your function, again, returns just one value. So query is comparing 'SALES' whith '(''ACCOUNTING'',''SALES'')', not with ('ACCOUNTING','SALES') and obviously no match. What you are trying to do is called dynamic SQL. There are plenty examples on how to use it. But you don't need it. Use nested table or varray. I'll use Oracle supplied varray type sys.OdciVarchar2List:
    select  *
      from  dept
      where dname in (
                      select  *
                        from  table(sys.OdciVarchar2List('ACCOUNTING','SALES'))
        DEPTNO DNAME          LOC
            10 ACCOUNTING     NEW YORK
            30 SALES          CHICAGO
    SQL>SY.

  • Help: How to call a user defined function in a data block query?

    I created a string aggregation function in the program unit, see reference:
    http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
    I now like to call the function in my data block query. I got the error: ORA-00904: 'concatenate_list' invalid identifier.
    Please help.
    Thank you in advance.
    Jimmy

    Hi,
    You can write UDFs in java in Graphical mapping to enhance your XI Graphical mapping functionality
    The steps for doing it would be:
    1. Click on Create New function Button found on Bottom left corner on your XI Mapping window.
    2. Write your java code.
    3. Run the Mapping Test as usual.
    >>The module that is given here ...where and how it is used.
    The adapters in the Adapter Framework convert XI messages to the protocols of connected external systems and the other way around. When doing so, some
    functionality might need to be added specific to a situation which is possible with the use of custom modules.
    Typical example would be validation of file content when using a File Adapter or modification of the message payload to a common content structure which is not supported by any of the standard SAP modules.
    An Adapter module is developed as an Enterprise Java Bean and is called locally by the Adapter.
    An example on modules :
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/da5675d1-0301-0010-9584-f6cb18c04805">How to develop a module for reading file name in a sender file adapter XI 3.0</a>
    Cheers,
    Chandra

  • Strange errors when using user defined function in where clause

    Hello,
    I am having trouble with a function that, when used in the where clause of a select will cause an error if the first column selected is of type INTEGER. Not sure whether I am doing something wrong or whether this is a bug.
    Here is a very simple test case:
    create table test(
    col1 integer not null,
    col2 varchar(20) ascii default ''
    insert into test values(1,'2011-03-15 05:00:00')
    insert into test values(2,'2011-03-15 07:00:00')
    CREATE FUNCTION BTR_TAG  RETURNS VARCHAR AS
        VAR ret VARCHAR(20);
      SET ret='2011-03-15 06:00:00';
      RETURN ret;
    Select * from test where col2 >= BTR_TAG()
    Select col1,col2 from test where col2 >= BTR_TAG()
    =>  Error in assignment;-3016 POS(1) Invalid numeric constant
    Select '',* from test where col2 >= BTR_TAG()
    Select col2,col1 from test where col2 >= BTR_TAG()
    => works as it should
    MaxDB V 7.7.07.16 running on Windows Server 2003
    I can replicated the test case above with Sql Studio and other ODBC based tools.
    Thanks in advance,
    Silke Arnswald

    Hello Siva,
    sorry, but I don't understand your reply:
    This is not right forum to posting this question.
    You are from which module or working any 3rd party application.
    MaxDB 7.7.07.16 is the community version of MaxDb,
    we are not using it for SAP
    and no 3rd party software is required to reproduce my problem,
    Sql Studio or Database Studio will do.
    Regards,
    Silke Arnswald

Maybe you are looking for

  • How to get the RGB Working Space from within a Filter Plug-In?

    Within my Filter Plug-In I need to access the image's icc profile data. I know this can be accomplished with the according data structure 'iCCprofileData'. But what if there is no profile assigned to the image? Then iCCprofileData is NULL and the def

  • ROWNUM can use with ORDER BY clause?

    Hi Following i have two quires in ROWNUM order for example.. 1:query select rownum,empno,ename,deptno from emp where rownum <= 14; result: rownum empno ename deptno 1 7369 SMITH 20 2 7499 ALLEN 30 3 7521 WARD 30 4 7566 JONES 20 5 7654 MARTIN 30 6 769

  • SAP PM for logistic industry

    Hi Experts, I would like to design SAP PM for logistics company (Freight forwarding) with international operations. Air, Sea, Land etc. Can I get power point presentation document or any other document for the same. Please do the needful. Please upda

  • Adding new column to Webdynpro Table

    Hi How can I add a new column, already one of my friend has added a table to the view in webdynpro, there are 4 columns presently maped to BAPI I need to add 2 new columns to the webdypor table and map it to BAPI. please suggest me. basically I am en

  • How do I close bridge application to continue with CS6 download if app not currently open?

    I am trying to upgrade CS5 to CS6.  I have downloaded the application and have attempted to run the install from the applications manager box but am getting a box which says I need to close down Bridge to continue with the install but neither Photosh