User defined function Problem

if (a.equals= = 311&&b.equals == SL02&&c.equals==SL01))
return "SL04";
elseif(a.equals= = 311&&b.equals == SL01&&c.equals==SL11))
return "SL01";
Problem in this UDF
Regards
Skancham

Hi,
Your UDF code syntax is totally wrong. you are using the equals method and using the == also. It should not be like that.
Please modify the code as shown.
if (a.equals("311")&&b.equals("SL02")&&c.equals("SL01"))
return "SL04";
elseif(a.equals("311")&&b.equals("SL01")&&c.equals("SL11"))
return "SL01";
Thanks.

Similar Messages

  • Timesten user defined function problem

    create or replace
    FUNCTION FACTORIAL
      n IN NUMBER         
    RETURN NUMBER IS
    val NUMBER :=1;
    tem number :=n;
    BEGIN  
      while tem>1 LOOP
        val:=val*tem;
        tem:=tem-1;
      END LOOP;
      RETURN val;
    END FACTORIAL;
    I create a function like this.
    And I  test it in sql developer(ctrl-F10), and get the right result.
    When I use the function in SQL:   select factorial(10) from dual;     (I use log as function owner,  exactly same connection as I test the function with ctrl-F10)
    cames the error message:  
    [TimesTen][TimesTen 11.2.2.5.0 ODBC Driver][TimesTen]TT2818: Unknown function FACTORIAL. If this is a PLSQL function note that such functions are not yet supported in SQL statements. -- file "saCanon.c", lineno 24079, procedure "inferExprTNFunc()"  
    Does that means timesten doesn't support user defined function in SQL statements?

    Yes, unfortunately currently TimesTen does not support calling PL/SQL functions from within a SQL statement.
    Chris

  • Problem with user-defined functions in XQuery String

    hello
    i've a problem with user-defined functions in XQuery String
    details are here (the code is not Human-readable via forum's embedded editor ?? strange)
    http://docs.google.com/Doc?id=ddqwddsr_21c96d9x
    thanks !!

    See
    michaels>  select xmlquery('declare function local:test_function($namecmp as xs:string?, $inputtype as xs:string?) as xs:string?      
                        return {$inputtype}
                     local:test_function("1","2")' returning content) o from dual
    Error at line 5
    ORA-19114: error during parsing the XQuery expression:
    LPX-00801: XQuery syntax error at '{'
    3                       return {$inputtype}
    -                              ^
    michaels>  select xmlquery('declare function local:test_function($namecmp as xs:string?, $inputtype as xs:string?) as xs:string?      
                        $inputtype
                     local:test_function("1","2")' returning content) o from dual
    O   
    2   
    1 row selected.

  • Error in conditional map using User Defined Function

    All,
    In my mapping I basically have a user defined function that returns the filename of my inbound file from the adapter-specific message attributes (file adapter).  I know this is coded properly because if I simply assign this function to my destination field I can see the filename in the payload XML.
    However if I conditionally check that returned value using if,then,else I get an error message stating:
    "During the application mapping com/sap/xi/tf/_MaterialData2ZcustProdMastMulti_ a com.sap.aii.utilxi.misc.api.BaseRuntimeException was thrown: RuntimeException in Message-Mapping transformation"
    Essentially in my if I'm checking if the value returned by my user defined function is equal to the constant "SOMECONSTANT" then I'm setting my destination field to some other constant value.  Otherwise it's equal to a different constant value.
    Any thoughts?

    Claus,
    Thanks for the help.  I actually had figured the problem out on my own.  Sorry for not updating the thread sooner.  What happened was this (as I suspected it wasn't related to my user defined function).  For the newbies out there (of which I'm one) the problem was I was comparing strings in the graphical mapping tool using the Boolean "EQUALS" rather than the Text "EQUALSS".
    Can you give yourself points for solving

  • User Defined Function (Part 2)

    Hi,
    István Korös has finally solved my problem on User Defined Function.
    See
    My objective was to write a simple UDF to represent the following formula which Gordon Du gave me:
    (DATEADD (s, -1, 
             DATEADD (mm, (DATEDIFF (m,0,@refdtzz ) + @mthnumber),  0)))
    However, the solution proposed by István, although it works perfectly, leaves me scratching my head. Let's see why?
    The only difference between my solution and that proposed by István is that István enclosed the UDF name between .
    I wonder how this can make the vital difference between a (simple query!) that works well and one that gets blocked.
    I tried several combinations of and am in for a few surprises, listed below. Can anybody explain what's going on?
    Solution proposed by István:
    CREATE FUNCTION [dbo].[udf_EndOfMonth]
    and executed as:
    select  [dbo].udf_EndOfMonth (@refdt1 , 1)
    Remarks: works perfectly
    If I execute the UDF with exaclly the same name as in CREATE, it does not work
    CREATE FUNCTION [dbo].[udf_EndOfMonth]
    and executed as:
    select  [dbo].[udf_EndOfMonth] (@refdt1 , 1)
    Error Msg: Must specify table to select from
    If I don't put the , the function is created, but the execution of the calling query returns error
    CREATE FUNCTION dbo.udf_EndOfMonth
    Remarks : Creation OK
    and executed as:
    select  dbo.udf_EndOfMonth (@refdt1 , 1)
    Error Msg: Must specify table to select from
    It seems that the only combination that works is that provided by István.
    This is surely a simple UDF.
    I don't know what to do if I attack a more complicated UDF.
    Grateful if anybody could help light my way.
    Thanks
    Leon Lai

    Hi Leon,
    As István has already pointed out, there is no documentation for those small differences to make the SQL work or not. He must be tested quite a few times to find the actual working code. This question can only be answered by the developer who made this part for B1.
    Thanks,
    Gordon

  • User-Defined Function and Context Manipulation

    Hi Mapping Gurus, I need your help.
    I have a user-defined function and one of my input parameter (c) is in a loop (EDI segment).  So one, if I execute my function I get:
    Exception:[java.lang.ArrayIndexOutOfBoundsException: 0]
    If I change the context or use the remove context node function it’s working but it’s always taking the first row in consideration since I'm using c[0] .  Here is the logic:
    String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[0]"'";
    So since c is an array [], I have tried different logic to get to the right row.
    1- I tried using another parameter (e) to pass a counter or an index to my function.  So each time it's looping, it's passing a new value to the function but I’m still getting the first row and I’m not to sure why?
    int G = Integer.parseInt(e[0]);  // e[] = My counter field
    String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
    2- I tried using a parameter stored in the container:
    String Num;
    Num = (String)getParameter(“counter”);
    if (Num == null)  G = 0;
    else
    G = Integer.parseInt(Num);
    G = G + 1;
    String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
    Num = "" + G;
    setParameter(e[0], Num);
    and I’m still getting the first one, look like it’s using a different container each time it’s looping so the Value is always the same?
    4- I created a new user-defined function with the container logic, then it’s working but I’m back to the same problem in my main function, it’s only looking at e[0] for my counter all the time.
    5- I tried using the Seeburger Java Variables and guess what in the main fonction, as new UDF,... and guess what, same result!
    So anybody out there that was able to get UDF's working into a multiple context scenario?
    Am I missing something?
    I will reward points and beer for any help!

    This is one of the text with passing a counter to the function to try to go to the right row in the array since I'm doing a remove context and I'm getting all the d_234's:
    public void ReadTable(String[] a,String[] b,String[] c,String[] d,String[] e,ResultList result,Container container){
    int G = Integer.parseInt(e[0]); // My counter
    String var;
    String DBTABLE = a[0];
    String lookUpField = d[0];
    String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
    Now this one was with the internal container logic:
    int G;
    String DBTABLE = a[0];
    String lookUpField = d[0];
    String Num;
    Num = (String)getParameter(e[0]);
    if (Num == null)  G = 0;
    else
    G = Integer.parseInt(Num);
    G = G + 1;
    Num = "" + G;
    setParameter(e[0], Num);
    String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
    And now with the Seeburger Variables:
    int G;
    try {
    VariableBean be=VariableFactory.getVariableInstance("");
    G = Integer.parseInt(String.valueOf(be.getStringVariable("yves")));
    } catch (Exception f) {
    throw new RuntimeException(f);
    String DBTABLE = a[0];
    String lookUpField = d[0];
    String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
    try {
    G = G + 1;
    Num = "" + G;
    VariableBean be=VariableFactory.getVariableInstance("");
    be.setStringVariable("yves",Num);
    catch (Exception f) {
    throw new RuntimeException(f);
    All 3 logics were returning always the first row or a counter of 1 if the logic is in the main ReadTable function.

  • Error Using imported .JAR in user-defined function

    Hi All,
    I am trying to use jar files provided to me in user defined function as follows:
    DataEncryption temp = new DataEncryption();
    String ret = new String();
    ret = temp.getEncryptedData(a);
    return ret;
    All jar files working perfectly in java software, But when i am trying to test the mappings by using above user-defined function.
    I am catching the error and put in target field then, I am getting following message in target field:
    "An error occured in getEncryptedData method :  java.lang.SecurityException: The provider SunJCE may not be signed by a trusted party"
    Please help in finding the error.
    Regards

    Rohan
    Check if the XI Server JRE is the same as the client machine on which you have compiled your JAR.
    1.4 has had this issue and i remember seeing it in a few forums.The problem should not occure in 1.5

  • BUG in DB XML? (when dealing with modules, user-defined functions)

    Hi,
    this post can be related to Different results for the semantically the same queries but here examples are even simpler.
    I have the module with one user-defined function:
    module namespace tnt = "http://tntbase.mathweb.org/ns";
    declare function tnt:filter-path($docs as document-node()*, $path as xs:string) as document-node()*{
      $docs[dbxml:metadata('tnt:path') = $path]
    };Then I have a query:
    import module namespace tnt = 'http://tntbase.mathweb.org/ns'  at 'file:/path/to/module/user-func.xq';
    (: this variable is IMPORTANT in the query:)
    declare variable $len := 3;
    (: here goes the same function as in the module, but with different name :)
    declare function tnt:filter-path2($docs as document-node()*, $path as xs:string) as document-node()*{
      $docs[dbxml:metadata('tnt:path') = $path]
    (:the query itself :)
    tnt:filter-path(collection("xml_content.dbxml"), substring("a:/doc.xml", $len)) If I execute the query I get *0* results, if I use function tnt:filter-path2 (instead of module's tnt:filter-path) then I get the expected *1* result.
    Also I experimented a bit with a query and got the following observations (independent from each other):
    1) If I substitute $len by value *3* or *3.0*, then I get right results in both cases, i.e. if the query itself looks:
    tnt:filter-path(collection("xml_content.dbxml"), substring("a:/doc.xml", 3)) 2) If I change the module's function so that it uses value comparison instead of general comparison, then I get the right results in both cases as well:
    module namespace tnt = "http://tntbase.mathweb.org/ns";
    declare function tnt:filter-path($docs as document-node()*, $path as xs:string) as document-node()*{
      $docs[dbxml:metadata('tnt:path') eq $path]
    };Please, help me out! I'm pretty sure it's a problem of DB XML and I'm struggling with it for a long time in this or that shape.
    Thanks a lot in advance,
    Vyacheslav

    I upgraded from 2.5.13 to 2.5.16 and the bug disappeared. The reason why I didn't do it before was that I hadn't seen any relevant for me fixes in the release notes of 2.5.16 comparing to 2.4.13 (Actually I already have had two patches for two relevant issues in the 2.5.13 version)
    Sorry for the false alarm.
    Vyacheslav

  • User defined function to set a default value of a column

    Hi All
    Can we use user defined function to set a default value of a column ??
    for example:
    create or replace  function test1  return number is
    begin
    return 10;
    end;
    create table testt
    (id  as test1,
      name varchar2(20));
    error:
    ORA-02000: missing ( keywordThanks
    Ashwani

    174313 wrote:
    MichaelS for showing example to use function in table ddl , otherwise i was thinking we cannot use function in table ddl as per error I received.That was an example of a virtual column.
    ORA-04044: procedure, function, package, or type is not allowed hereUsing PL/SQL code like that raises 2 basic problems. If that PL/SQL code for the calculating the column default breaks, what happens to the SQL insert statements against that table. These will need to fail as the table definition depends on the PL/SQL code. This is problematic as this dependency simply increases the complexity of the SQL object.
    The 2nd issue is performance. PL/SQL code needs to be executed by the PL/SQL engine. This means a context switch from the SQL engine to the PL/SQL engine in order to determine the default value for that column. Context switching is a performance overhead.
    So even if it was possible to use a PL/SQL function as parameter for the SQL default clause, I would not be that keen to use it.

  • Java class within user defined function

    Hi all,
    in order to have a JDBC-lookup java function "globally" in XI i created a java class and imported it to XI as an imported Archive (i have to do the lookup within a mapping). I then can include the class to a user defined function. However the problem is now that this works fine within one Software Component Version but when i want to use it in several SWCV i have to import the jar to every SWCV. My question is therefore if anybody has already had this problem and if there is another possible solution - maybe deploying the class to XI using SDM?
    Thank you for your thoughts.
    Mathias

    hi Markus,
    >>>>My question is therefore if anybody has already had this problem and if there is another possible solution - maybe deploying the class to XI using SDM?
    if you do that then you'll have to remember about it
    every time you import a new SP or upgreade your XI
    this is not standard so SAP may always overwrite it
    and your interfaces will stop working
    consider importing it for every SWCV  
    Regards,
    michal

  • In Ref cursor, user defined functions give "invalid column" error in EJB.

    Hello,
    I have written PL/SQL stored procedures/functions in Oracle 8i. They return the result set as a ref cursor.
    These procedures are accessed by EJB (weblogic) using Type 4 (100% Java) JDBC Driver.
    My problem is - if I use a user defined function to fetch a value in the select statement of the reference cursor, the EJB gives an error msg - invalid column name.
    If instead of using the function I get the value directly from the table, it works fine. Refer the code below :
    //In the PL/SQL function -
    //instead of writing :
    Open rc for
    Select empcode, empname
    from emp ;
    //If I write :
    Open rc for
    Select empcode, mypack.getempname(empcode)
    from emp ;
    //getempname(empcode) is a function in
    //in a package named 'mypack'
    //and returns name for empcode.
    //The java code gives error
    //error : invalid column name
    //While both are working fine and
    //returning currect result in SQL Navigator.
    Help me solve this mystery ?
    Thanks in advance.
    Swati.
    null

    Hi:
    When use inline Function to simplify the SQL statements, there is one thing that one should conside--Purity Level.
    if you create standalone stored pl/sql function. Oracle implicitly determines the PURITY level during compilation of the stored objects or at execution of an anonymous pl/sql block.
    if you implement Package inline Function( in your case),unlike standalone stored pl/sql functions, the PL?SQL Engine does not determine the purity level of package functions. Therefore, you must explicity assign the correct purity levels for the function to be called inline.
    the code like:
    create or replace package mypack is
    function getempname(empcode emp%empid%type)
    return varchar2;
    PRAGMA RESTRICT_REFERENCES(getempname,WNDS,WNPS,RNPS);
    end mypack;
    I think it can solve your problem if you use enough "pure"to be called inline function. Or you can create the standalone function to do it.
    good luck!
    Yali
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Swati Agrawal ([email protected]):
    Hello,
    I have written PL/SQL stored procedures/functions in Oracle 8i. They return the result set as a ref cursor.
    These procedures are accessed by EJB (weblogic) using Type 4 (100% Java) JDBC Driver.
    My problem is - if I use a user defined function to fetch a value in the select statement of the reference cursor, the EJB gives an error msg - invalid column name.
    If instead of using the function I get the value directly from the table, it works fine. Refer the code below :
    //In the PL/SQL function -
    //instead of writing :
    Open rc for
    Select empcode, empname
    from emp ;
    //If I write :
    Open rc for
    Select empcode, mypack.getempname(empcode)
    from emp ;
    //getempname(empcode) is a function in
    //in a package named 'mypack'
    //and returns name for empcode.
    //The java code gives error
    //error : invalid column name
    //While both are working fine and
    //returning currect result in SQL Navigator.
    Help me solve this mystery ?
    Thanks in advance.
    Swati.
    <HR></BLOCKQUOTE>
    null

  • ? Regarding 'SQL user-defined function' execution performance ?

    Hi All,
    I have an user-defined function in SQL which am using in a SQL select statement and i found that the execution time taken by the user-defined function is 9-10 minutes as a result of which my whole query execution time is affected.
    How to i improvise the execution time. Should i do some sort of scheduling for executing the user-defined functions only. Am new to the database world. Your early response with a good suggestion would really be appreciated.
    Thanks in Advance.

    Try to read SQL tuning documents along with TkProf. Then only you will be able to detect the problem.
    There is no instant method by which you can solve this problem.
    But, you can get idea from this samples.
    Tuning:
    http://www.dba-oracle.com/art_sql_tune.htm
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::NO::P11_QUESTION_ID:8764517459743
    Reading TkProf:
    http://www.dbspecialists.com/presentations/use_explain.html
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:920429344869
    Regards.
    Satyaki De.

  • Converting the iif function in MS Access97 to an user defined function in Oracle

    Hi ,
    I have a problem here we are working with Visual Basic 6.0(ADOs 2.5) with Oracle 8i release 2. we have some queries stored in the tables which contains the iif function of MS Access 97 do we have a similar built in function in Oracle which replaces this iif function of Ms Access 97.
    we cannot use decode (built in function) of oracle b'cos it cannot be used in a where clause and we cannot write a user defined function also because it cannot be generalized for use b'cos sometimes we use
    field names and sometimes values as expression in the iif functions
    If anybody could suggest me some idea
    please mail me at [email protected]
    with best regards
    Jai

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Jai:
    Hi ,
    I have a problem here we are working with Visual Basic 6.0(ADOs 2.5) with
    Oracle 8i release 2. we have some queries stored in the tables which contains the iif function of MS Access 97 do we have a similar built in function in Oracle which replaces this iif function of Ms Access 97.we cannot use DECODE (built in function) of oracle b'cos it cannot be used in a where clause and we cannot write a user defined function also because it cannot be generalized for use b'cos sometimes we use field names and
    sometimes string values as expression in the iif functions. is there any other built in function ? can anybody suggest me some idea
    please mail me at [email protected]
    regards
    Jai<HR></BLOCKQUOTE>
    Hi,
    You still can use the seccond approach - with a udf IIF() that you place in a package and OVERLOAD it. See the documentation for limitations of Overloading
    Overloading permits you to declare several functions with the same name but havind different behaviours depending on the number and type of the parameters.
    George

  • How to call User defined functions in Mathscript Node ?

    Hi,
    I have created a user defined function and saved it to Search path of Labview as an M file. If I run my program in Math script window, the function is recognized and the program works properly. If I do the same with MathScript node , the user defined functions are not identified.
    Kindly help me with this problem. Thanks in advance
    Cheers
    Lenord Melvix

    This page may help:
    http://zone.ni.com/reference/en-XX/help/373123C-01/lvtextmathmain/caveats_recommendations_ms_search_...
    Kevin C.

  • How to use StreamTransformationException in user-defined function?

    Hi,
    I'm doing a DBLookup (using Java pgm in one of my Imported Java archives) for populating one of the fields in message mapping. If the DB connection fails, I want to terminate the mapping by throwing a StreamTransformationException from within a user-defined function.
    I require urgent help in this regard.
    Thanks in advance.
    Regards,
    Sridhar Rajan N

    Hi,
    I had the same problem. I failed to find the way how to throw a StreamTransformationException in my user-defined function. But I used another exception: NullPointerException. Yes, I know, this is not an elegant solution...
    Best regards,
    Andrzej Filusz

Maybe you are looking for