A query can be passed to the user-defined function?

Hello
I created a function that takes one parameter and returns a value. Now tha value that is passed into the function comes also from a query, so can I pass that Charly directly in the parameter?
I tried this but it is giving error: ORA-00936: lack of expression.
select ID from table1
where areaid=f_getAreaID(SELECT sec FROM table2 WHERE artid='3232') and 
type='p002' 
Above code is in error. How do I get my requirement?
Note: Assume that query to the function will always return a value of skis.

Published by: bootstrap on August 28, 2011 12:13

Subquery must be enclosed in parentheses. Function parameters must be placed in brackets. Therefore, you should use

select ID from table1
where areaid=f_getAreaID((SELECT sec FROM table2 WHERE artid='3232')) and
type='p002'

Remember, it must be a scalar subquery (subquery returns one or no line).

SY.

Tags: Database

Similar Questions

  • the user-defined function

    Hi, experts,
    I wrote a sql query to get the amount after calculation.

    SELECT A.FORM_NO, C.SKUCODE, B.QUANTITY * (
    CASE WHEN TO_NUMBER(TO_CHAR(A.START_DATE,'YYYY')) = 2008 AND TO_NUMBER(TO_CHAR(A.END_DATE,'YYYY')) = 2008 THEN 
    TO_NUMBER(TO_CHAR(A.END_DATE,'MM')) - TO_NUMBER(TO_CHAR(A.START_DATE,'MM'))  +1 
    WHEN TO_NUMBER(TO_CHAR(A.START_DATE,'YYYY')) = 2008 AND TO_NUMBER(TO_CHAR(A.END_DATE,'YYYY')) > 2008 THEN
    12- TO_NUMBER(TO_CHAR(A.START_DATE,'MM')) + 1
    WHEN TO_NUMBER(TO_CHAR(A.START_DATE,'YYYY')) < 2008 AND TO_NUMBER(TO_CHAR(A.END_DATE,'YYYY')) = 2008 THEN 
    TO_NUMBER(TO_CHAR(A.END_DATE,'MM'))
    WHEN TO_NUMBER(TO_CHAR(A.START_DATE,'YYYY')) < 2008 AND TO_NUMBER(TO_CHAR(A.END_DATE,'YYYY')) > 2008 THEN
    12 ELSE 0 END )/((TO_NUMBER(TO_CHAR(A.END_DATE,'YYYY')) - TO_NUMBER(TO_CHAR(A.START_DATE,'YYYY'))) *12 + TO_NUMBER(TO_CHAR(A.END_DATE,'MM')) - TO_NUMBER(TO_CHAR(A.START_DATE,'MM')) + 1 )
    
    AS QUAN
    FROM FORM_TBL A, QUANTITY_TBL B, SKU_TBL C
    WHERE A.FORMNO = B.FORMNO AND B.SKU = C.SKU;
    It runs correctly, and no error returned.


    I would change for a user-defined function.

    create or replace
    function get_quantity
            (pi_year number, pi_year_diff number, pi_form_no varchar2, pi_skucode varchar2)
            return number is
        po_quantity number;
    begin
        
        
        SELECT ( B.QUANTITY * (
        CASE WHEN TO_NUMBER(TO_CHAR(A.START_DATE,'YYYY')) = (pi_year + pi_year_diff) AND TO_NUMBER(TO_CHAR(A.END_DATE,'YYYY')) = (pi_year + pi_year_diff) THEN 
        TO_NUMBER(TO_CHAR(A.END_DATE,'MM')) - TO_NUMBER(TO_CHAR(A.START_DATE,'MM'))  +1 
        WHEN TO_NUMBER(TO_CHAR(A.START_DATE,'YYYY')) = (pi_year + pi_year_diff) AND TO_NUMBER(TO_CHAR(A.END_DATE,'YYYY')) > (pi_year + pi_year_diff) THEN
        12- TO_NUMBER(TO_CHAR(A.START_DATE,'MM')) + 1
        WHEN TO_NUMBER(TO_CHAR(A.START_DATE,'YYYY')) < (pi_year + pi_year_diff) AND TO_NUMBER(TO_CHAR(A.END_DATE,'YYYY')) = (pi_year + pi_year_diff) THEN 
        TO_NUMBER(TO_CHAR(A.END_DATE,'MM'))
        WHEN TO_NUMBER(TO_CHAR(A.START_DATE,'YYYY')) < (pi_year + pi_year_diff) AND TO_NUMBER(TO_CHAR(A.END_DATE,'YYYY')) > (pi_year + pi_year_diff) THEN
        12 ELSE 0 END )/((TO_NUMBER(TO_CHAR(A.END_DATE,'YYYY')) - TO_NUMBER(TO_CHAR(A.START_DATE,'YYYY'))) *12 + TO_NUMBER(TO_CHAR(A.END_DATE,'MM')) - TO_NUMBER(TO_CHAR(A.START_DATE,'MM')) + 1 ))
        
        into po_quantity
        FROM FORM_TBL A, QUANTITY_TBL B, SKU_TBL C
        WHERE A.FORMNO = B.FORMNO AND B.SKU = C.SKU
        and c.skucode = pi_skucode and a.form_no = pi_form_no;
    return po_quantity;
    end;
    BUT IT CANNOT BE COMPILIED.
    The error is a recursive sql error

    ORA-00604: an error has occurred at the SQL level 1 recursive

    I think that there is no syntax error.

    What is the reason?

    Thank you very much!

    What is your DB version. If you are using 11g then can be consider that

    http://www.DBA-Oracle.com/sf_ora_00604_error_occurred_and_recursive_sql_level_string.htm

  • The user-defined functions...

    Hi all

    Where do we store the functions defined by the user of CF (models) in order so that it can be called by any model of CF? In the Custom Tag folder? In the directory root CF?


    Thanks in advance!

    We re-use our functions across different sites (I think it's what your bet to) using the method 'BlackBox '. I'm sure there are other ways, but this is the norm for society, that I work. For more information, see
    http://www.cfblackbox.com/

    Additional information:
    You can store them anywhere in your site, but you can declare the function once. For example, if you have a page that includes two models. Each of the two models to compose the same model that holds your function. This will cause an error. In addition, if you have the model in a loop, it will cause an error.

  • Using the Dollar sign ($) in an implementation of the user-defined function

    Hi all

    Just a quick question: how would you use a dollar sign ($) in the (Oracle) implementation of a user function? I ask because the table name that I use in the application happens to contain a dollar sign (I$ _FACT_SALES) and post the results I get now, ODI bed the $ as a reference to a variable, the sign $ so my name removed from the table during execution (I_FACT_SALES). Is there something like a backslash or some other character that could be inserted before the $ for him be part of the name of the table?

    Any response would be greatly appreciated.

    Thank you very much
    Marco

    You have 3 options:

    1.) try using the tablename parameter in the following quotations: ' MY$ TABLE "or maybe MY$ $TABLE using double symbol $
    or
    2) 2) I found this snippet: odiRef.getInfo (\\u0022DEST_WORK_SCHEMA\\u0022) + \\u0022.\\u0022,\\u0022\\u0022)?. "So on these lines, so that you can use \\u0022 as a symbol.
    You can see the similar problem/solution/explanation
    Re: Expression regular wierdness - problem with the character $

    or
    3.) change the prefix work Tables in the topology manager > physical schema > Your_Schema
    E$ _, $ CAN, I have$ _ something like ERR_, SRC_, TD4100

    Published by: Ace2 on December 2, 2009 09:57

  • How to use the user defined function in the Update statement

    Hi all

    I wrote under the update statement to update the column based on the return value of function. but it does not work. Could someone help me on this. This function returns a single value for each project.

    Thanks in advance.

    UPDATE dg2. OD_PROJ_LOOKUP_TEMP o
    SET Months_In_Stage_Cnt = Months_In_Stage_Cnt_ret (o.project_id) select the double;


    Thank you
    Deb

    PLS-00231: function 'MONTHS_IN_STAGE_CNT_RET' cannot be used in SQL

    -What is the function that is declared private in a package? If Yes, then it must be public, otherwise the SQL engine cannot be used.

    Published by: Dom Brooks on November 18, 2011 09:43

  • User-defined function removes the expression hooks

    Trying to convert this column in a user function expression, however when I apply the function to the user hooks literally disappear.

    1 REGEXP_REPLACE (SRC_IO_PHONES_A.PHONE, ' ({: digit:{3})\.(:digit:{3})\.(:digit:{4})' 1 (\1)-\2-\3'),)

    2 REGEXP_REPLACE (SRC_IO_PHONES_A.PHONE, ' ([[: digit:]] {3})------.) () [[: digit:]] {3}). ([[: digit:]] {4})' 1 (\1)-\2-\3')


    These lines come from the same mapping. One implements the user-defined function and the second line is with I plug the code into the target Expression field.


    Any thoughts on why this is?


    Thank you

    So I thought to it thanks to a post of @oraclebase.  Another friend of mine has indicated that user in ODI functions develops a sort of pseudo-code and it is not really passing commands to the database.  Anyway, my research turned to substitute for the construction of all [: digit:].  This resulted in me find the above post where \d = [0-9].  By replacing all the scoring by \d hooks, the function worked.

  • User-defined function problem. Help!

    I can't get the user-defined function to work in Essbase, although it seems to be just registered. Could someone help me to have a look at java codes below? Greatly appreciated!

    public class {depreciation

    public static double Adeath (double r, int period, double LoanBalance) {}

    Calculate amortization payment
    Double LBound = LoanBalance/period;
    Double UBound = LoanBalance;
    Double MBound =(LBound+UBound)/2;
    Double err = 0;
    int i = 0;

    If (r < 0 |) Period < = 0 | LoanBalance < = 0) {}
    MBound = 0;
    }

    ElseIf (period == 1) {}
    MBound = LoanBalance *(1+r) ;}

    on the other

    {}
    Double MBalance is PVCalc (r, Period, MBound);.
    ERR = MBalance-LoanBalance;
    If (err > 0) {}
    UBound = MBound ;}
    If (err < = 0) {}
    LBound = MBound ;}
    MBound =(UBound+LBound)/2;
    i ++ ;
    }
    While (err > 0.001 | err <-0,001 & & I < = 100);

    return (MBound);
    }


    Define the present value
    public static double PVCalc (double rate, NPER, double PMT int) {}
    Double pvpmt = pmt;
    Double cpvpmt = 0;

    for (int j = NPM; j > 0; j-) {}
    for (int i = 1; i < = j; i ++) {}
    pvpmt = pvpmt /(1+rate/12);
    }
    cpvpmt = cpvpmt + pvpmt;
    pvpmt = pmt;
    }
    Return cpvpmt;
    }
    }


    Is there something to do with the double data type, int, double? Essbase spend 'int '?
    Help, please! Thank you very much!!

    Published by: user9132709 on March 2, 2010 12:47

    I just tried and it works.

    I also added

    System.out.Print (MBound);

    just before the return (MBound);

    in the Java class

    I created a calc script against Sample.Basic

    Fix("Florida","100-10","Actual","Apr")

    ('Sales'
    'Sales' = @Amort (0.06, 360, 10000000);
    )

    ENDFIX

    I run essbase in the foreground, so I see the exit of System.out.print (Mbound);
    Validated the script "59955.05251799688" was written in the output window, so the Java class works.
    I also ran the calc script and the value was written in 'Sales' (the block already existed for the POV before anyone says that my script would not work)

    I registered the CDF of Java with.
    create or replace function '@AMORT' as
    "Amortization.Amort (double, int, double).

    You must ensure that you see something like the following in the application log or output in the command window.

    External function of [GLOBAL] [@AMORT] saved OK

    See you soon

    John
    http://John-Goodwin.blogspot.com/

  • User-Defined Functions

    Hi, I am a newbie in oracle database,

    I want to know if this is possible:

    is it possible to build a sql (in string format), then run it inside a function defined by the user (NOT stored procedure)?

    If so, are all versions of oracle database able to do this?

    and it's samples?

    and a stored procedure can be called inside a user-defined function?

    Thank you!

    Hello

    Forreging wrote:
    is it possible to build a sql (in string format), then run it inside a function defined by the user (NOT stored procedure)?

    Yes.
    Create a string that is a SQL command and then running it is called dynamic SQL .
    You can do inside of a function, or a procedure. (Attention this: all procedures and functions is often called Stored Procedures .)
    Everything you can do in a procedure, you can also do this in a function.

    If so, are all versions of oracle database able to do this?

    Yes, all versions of Oracle behave this way.

    and it's samples?

    The [PL/SQL manual | http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/dynamic.htm#sthref852] has many examples.
    There are a lot of questions on this forum about PL/SQL. Enter "Dynamic SQL" in the serach box (top right of the Thread list page) to see [examples | http://forums.oracle.com/forums/search.jspa?objID=f75&q=dynnamic+SQL].

    and a stored procedure can be called inside a user-defined function?

    Yes, it is done very often.

  • Can I pass name of user and password for strobe playback as parameters?

    A question related to the SSO on.

    Can I pass name of user and password for playback of strobe as parameters so that the user does not need to be prompted for the name of user and password for protected content? In other words, Strobe detects a need for authentication, but rather establish a dialog box to prompt the user, it just extracts the name of user and password transmitted and transmits it to the license server?

    If no such function is available, can anyone point to a simple sample plugin, where I can spend the long name of username/password or a token to the license server, perhaps through the object connection or flow? I looked at the example of Akamai, and it's quite complicated with little documentation.

    Thanks in advance for your help.

    -Leki

    Hi Lei,

    The SMILPlugin seems to have a bug when used with a proxy plugin.

    Please follow these steps:

    1 starting the SMILPlugin source code: http://opensource.adobe.com/svn/opensource/osmf/trunk/plugins/samples/SMILPlugin

    2. open the SMILMediaGenerator class.

    3. go to line 123. You should see the following code snippet:

    If (! isNaN (duration) & duration > 0)

    {

    (videoElement as VideoElement) .defaultDuration = duration;

    }

    4. replace by this excerpt:

    If (! isNaN (duration) & duration > 0)

    {

    Assuming that videoElement is that a VideoElement is wrong (I guess that we can find a better name for this variable?)

    Since any plugin proxy will break this code. Iterate through the string until you reach a VideoElement proxy

    We can add a deffensive code just after the iterator, unless we should always have a VideoElement on top.

    var temp: MediaElement = videoElement;

    While (temp is ProxyElement)

    {

    Temp = .proxiedElement (temp as ProxyElement);

    }

    (temp as VideoElement) .defaultDuration = duration;

    }

    5. check that everything works with this patch.

    6. Let us know if that fixes the problem.

    7. connect the bug and submit the patch (with a link to this post on the forum) here: http://bugs.adobe.com/jira/browse/FM

    Thank you

    ANDRIAN

    Post edited by: Andrian Cucu

    updated the piece so that it uses a temp var

  • How can I permamnetly delete the user account in Windows xp?

    How can I permamnetly delete the user account in Windows xp?

    1. 1

      Go to the control panel. There are several ways to do this, but the most common is to go to the Windows Start menu and click on "Control Panel" on the right side. Follow whatever it is more convenient for you.

    2. 2

      Click on "user accounts" in the window that appears. Or, you see the standard view (with lines of icons) or the display of the categories (which is explicit). Both have a shortcut to the user accounts Control Panel.

    3. 3

      If a control panel is not yet made, click the 'user accounts' Panel at the bottom of the window. If so, you can skip this step.

    4. 4

      Click the link you want to get rid of any user account.

    5. 5

      The next window will have a list of actions you can do for the user account, one of which will be "remove account". It is the action that you'll want to click on.

    6. 6

      The last window that you will see will ask you if you want to keep the soon-to-be-used user represents the files in a folder on your desktop. It's your choice here.

      • If you have already backed up all important data on this user account, you can safely click on 'delete files '.
      • If you do not, you must click "keep files".
    7. Kind regards
    Amith Malherbe
  • Can be passed to the formula of the procedure/function the column value?

    Cf_value is back after some calculation using the main request.

    Can be passed directly the value of column of formulas of procedure without assinged to placeorder?
    as below...


    f_convert(:cf_value,new_value);

    ---------------------------------------------------------------

    My procedure is...


    PROCEDURE f_convert (val1 val2 in number, number) IS

    BEGIN

    val2: = val1 * 100;

    END;


    If anyone knows pls answer me...

    In fact, if there is that other calculations he (in Proceudre)

    Can I used is like below?
    ---
    PROCEDURE f_convert (val1 val2 in number, number) IS

    BEGIN

    val2: = val1 * 100;

    return (val2);
    END;
    ----

    A procedure cannot return a value, the return in my previous post clause was part of the function for formula column.
    Let's say you have a column of forms of so-called CF_2, then the function because it will be like:

    function cf_2formula return number
    is
     val1 number;
     val2 number;
    begin
    
     val2 := :cf_1 * 100; -- or val2 := val1 * 100 --parameters not allowed in formula column function
    
     -- All the other code that you need inclusive of calling function, procedure as in any PL/SQL block can be placed 
    
     return (val2);
    
    end;
    

    Any calculation can be used in the service of the formula column

  • How can I view all the users?

    Hi all.
    I use Oracle 10 g.
    How can I view all the users?
    Tanx
    Alam

    [ALL_USERS | http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_2.htm#i1593342]

  • any user defined function in the rule set by the user

    Hello

    I wonder if I can use a function defined by the user in a rule set by the user in oracle sem... I've seen examples of user defined function the used in sparql query filter clause in this guide to dev... However, I don't know if I can define a function in oracle database SEM. and use it in the body rule or the head. For example, I want to define a function of the length that allow to calculate the difference between two dates.  So, I want to set a rule as follows: event1: d1 and event1 has_start_date: has_end_date d2 and duration (24, d1, d2) then event1:date_satisfiable 'yes '. Oracle supports this type of rule? Thank you very much.

    Hong

    Salvation Hong,

    User-defined in 12 c inference can be a good choice for your condition. Please see the following document.

    Defined by the user and querying inference

    Thank you

    Zhe Wu

  • How to operate the user defined table ddl transformations?

    How can I run (Oracle Data Modeller 4.1.0.873) my transformations of the user-defined table ddl (for the creation or - map source files). (In tools-> rules of design and Transformations-> Table DDL transform his only Test and debugging for an entity)

    Is it possible to have a new button in the toolbar to start my generations DDL?

    Hello

    There is a brief description in the file sqldeveloperdatamodelerscripting.docx located in the directory datamodeler\datamodeler\xmlmetadata\doc of your DM 4.1 instalation.

    Somehow you can read also here Oracle SQL Developer Data Modeler 4.1 user - defined DDL generation using transformation scripts

    You can use the script for the purposes of testing only, otherwise the output of this script will be included in the DDL if script 'Active' selected value and ago marked to be included in this generation of tables

    Philippe

  • How to remove the user defined color chart in illustrator cc

    How can I remove groups swatch defined by the user in the menu in illustrator CC drop down 'open the Swatch Library? I'm on a Mac Book Pro 13.

    Hi Peter,.

    You can navigate to: Applications > Adobe Illustrator CC 2015 > Presets > en_US > color chart, and there, you can manually delete the user defined color chart.

    Thank you

    OM

Maybe you are looking for

  • Why can't I choose the colors for tabs?

    28 Firefox is faster and improved - except that the tabs unread pages are of the same color as the background and the toolbar. Please revert to the previous version or let me PICK colors.

  • Automatic play button and the game will not work for videos

    I'm reading a video (the Web site supports .webm, .ogv, mp4), but neither autoplay, or the Start button seems to work. However, if I slide the button to the right (+/-40 sec) play video. I tried a lot of solutions suggested in other threads (potentia

  • Login screen broken

    I use the latest version of Skype (6.22.81) on Windows 8.1, I broke the Skype login page - it's the display without style. Except this everything works fine. I looked at all the solutions - probably, but none of them does not work for me - in the reg

  • Downgrade of HP mini 110-3109sl

    Hi, I'm Italian and I have a problem. I want to downgrade my hp mini 110 3109sl but before that I would like to know 3 things: I break the warranty?I need to put some whit nlite driver in my original cd Windows XP SP3?Should I install ubuntu or XP? T

  • Is what camcorder compatible with Windows Movie Maker on Vista Home Premium?

    I'm in a bit of a dead end.  I have to make and edit a film which is mostly clips stored in Windows Movie Maker on my old computer which has VISTA Home Premium/64 bit. In most old clips (that are compatible), I have to shoot some new images.  My rece