Can we call a procedure in select statement?

Can we call a procedure in select statement?

Hi,
Raghu_appsdba wrote:
Can we call a procedure in select statement?No. You can call functions, but not procedures.
If the procedure does not change the database state (for example, it doesn't update any tables), then you can wrap it in a function, or re-write it as a function.
Here's an example of wrapping.
CREATE OR REPLACE FUNCTION fun_x (in_txt IN VARCHAR2)
RETURN  VARCHAR2
IS
BEGIN
        proc_y (in_txt);
        RETURN  in_txt
END     fun_x;

Similar Messages

  • Calling a procedure in select query.

    I have created a procedure with three parameter one in parameter and two out parameter.
    I want to call this procedure in select statement.How can i do this?
    procedure is like this.
    CREATE OR REPLACE PROCEDURE p_payment_adjustment (
    p_cons_ref IN VARCHAR2,
    p_bd OUT NUMBER,
    p_ed OUT NUMBER,
    p_roundoff OUT NUMBER
    )

    You can't use procedures but you can use functions. You could create 3 functions that have the 3 out parameters as result or you could create a type that contains the 3 values and that is returned by the function.

  • Why I Can't use procedure in select statement

    Why I Can't use procedure in select statement

    We can use function in select statement but we couldn't use procedure with one out parameters in select statement... You can use Function because they are designed for this but procedure are not. Functions can return value (without OUT parameter) which can be used in SELECT whereas procedures do not have such concept. As you can see in the above post you can not call even functions also if it has any out parameter.
    I have just trying to use procedure in select statement ..for this I require technical answer..The technical answer is because conceptually procedure is for doing set of operation, performning DMLs on the tables , whereas functions are for processing and producing a single result. Functions are basically for not using INSERT/UPDATE/DELETE in it. That is the reason they are allowed to be used in SELECT because conceptually they are not supposed to do any data changes.
    Regards,
    Avinash

  • Error by using database procedure in select statement

    hi ,
    I have built a database procedure having one parameter with in out varchar type. that return value with some addition.
    i am using it with some column in select statement only for display purpuses but i am facing error by doing that in select statement. that procedure is working well with bind variable but not with select statement.
    plz help me how i can use a procedure in select statement. or can i do it or not.

    plz help me how i can use a procedure in select statement. or can i do it or not.A workaround could be to create a wrapper function for your procedure. One that only passes the input parameters and returns the output parameter.
    The simply call this function in your select which internally calls the procedure.

  • Unable to call local function in select statement.

    Hi all,
    I am unable to call the local function in select statement in below scenario.
    DECLARE
    l_cnt NUMBER;
    FUNCTION FUN1 RETURN NUMBER
    AS
    BEGIN RETURN 2;
    END;
    BEGIN
    SELECT FUN1 INTO l_cnt FROM DUAL;
    DBMS_OUTPUT.PUT_LINE(l_cnt );
    END;
    /Any alternate way to call local function in select statement?
    Thanks
    Ram.

    Hi,
    Sorry, you can't call a locally defined function in a SQL statement, even if that SQL statement is in a PL/SQL block where the function is in scope.
    This applies to packages, also. If a function is not declared in the package spec, but only in the package body, then you can't call it from SQL statements in the package body.
    Why do you want a locally defined function? Why not a function defined outside the procedure?

  • Can we call a procedure within function?

    Can we call a procedure in function?
    If yes, then please explain with example.
    Thanks
    Aman

    Why don't you try it?
    SQL> set serveroutput on
    SQL> declare
      2   procedure p1 (
      3    i1 in out number
      4   )
      5   as
      6   begin
      7    i1 := 200;
      8   end p1;
      9   function f1
    10   return number
    11   is
    12    l1 number;
    13   begin
    14    p1(l1);
    15    return l1;
    16   end f1;
    17  begin
    18   dbms_output.put_line(f1);
    19  end;
    20  /
    200
    PL/SQL procedure successfully completed.
    SQL> set serveroutput off

  • How to call user fuction in select statement.

    hi,
    i am facing some problem.How to call user functions in select statement.please send me answer with example.
    Thanks
    Gopal

    Locations to Call User-Defined Functions
    • Select list of a SELECT command
    • Condition of the WHERE and HAVING clauses
    • CONNECT BY, START WITH, ORDER BY, and GROUP
    BY clauses
    • VALUES clause of the INSERT command
    • SET clause of the UPDATE command
    Restrictions on Calling Functions from SQL Expressions
    To be callable from SQL expressions, a user-defined
    function must:
    • Be a stored function
    • Accept only IN parameters
    • Accept only valid SQL data types, not PL/SQL
    specific types, as parameters
    • Return data types that are valid SQL data types,
    not PL/SQL specific types
    • Functions called from SQL expressions cannot
    contain DML statements.
    • Functions called from UPDATE/DELETE statements
    on a table T cannot contain DML on the same table
    T.
    • Functions called from an UPDATE or a DELETE
    statement on a table T cannot query the same table.
    • Functions called from SQL statements cannot
    contain statements that end the transactions.
    • Calls to subprograms that break the previous
    restriction are not allowed in the function.
    jeneesh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Can we call a procedure from  a trigger

    Can we call a procedure from a trigger
    thanks

    Why cant you test yourself..?
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace procedure p1
      2  as
      3  begin
      4   null;
      5* end;
    SQL> /
    Procedure created.
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace trigger t1
      2  after insert on t
      3  begin
      4   p1;
      5* end;
    SQL> /
    Trigger created.
    SQL> insert into t
      2  values(5,'n');
    1 row created.
    Message was edited by:
            jeneesh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How can we call a Procedure?

    Hi All,
    How can we call a procedure having all in parameters Otherthan Callablestatement?
    Thanks in advance,
    Sekhar

    I guess you have to use Callablestatement still.

  • Can we call the procedure which contain commit  in trigger

    can we call the procedure which contain commit in trigger

    Well, what i've noticed from op's past post - whenever op post - he/she posts multiple short questions here. This may be indication of some sort of assignment or any kind of online exam's ...... :?)
    Regards.
    Satyaki De.

  • Calling a procedure into select

    Is this possible ?
    select sp_info_element_ctrl(:new.code_usager_ctrl), from dual;

    Hi,
    932262 wrote:
    Yes it was part of a trigger, what i am trying to do is to insert data of an old tabl into new one, the new one contains all the old colomns plus one, the code_usager_ctrl which is given by the procedure. But i don't want to use the trigger. Is that possible ? Or do i need to convert the procedure into a function.There is no way to call a procedure from a SQL statement.
    You can call a function from a SQL statement, such as a query. There are some restrictions on the function. In particular, it can't have IN OUT or OUT arguments, only IN arguments. It looks like you could convert your procedure into a fucntion. The return value of the function would be what the IN OUT argument p_code_usager_ctrl is in the procedure. It looks like p_date_ctrl is always SYSDATE, so you might as well just use SYSDATE.
    Here's the procedure
    CREATE OR REPLACE PROCEDURE SP_INFO_ELEMENT_CTRL
    ( P_DATE_CTRL IN OUT DATE -- TIMESTAMP DE LA TRX
    ,P_CODE_USAGER_CTRL IN OUT CHAR -- CODE D'usager utilise
    ) AS
    BEGIN
    -- RECHERCHE DE LA DATE
    P_DATE_CTRL := SYSDATE;
    -- Si l'usager est IGD, c'est le package qui fourni le nom d'utilisateur
    IF (USER = 'IGD' OR USER = 'GDI' OR USER='IGDD') AND P_CODE_USAGER_CTRL IS NOT NULL THEN
    P_CODE_USAGER_CTRL := 'IGDD\'||TRIM(P_CODE_USAGER_CTRL);
    ELSE
    -- RECHERCHE DE L'usager
    P_CODE_USAGER_CTRL := USER;
    END IF;
    END;
    Edited by: 932262 on 2012-05-11 10:28It looks like this procedure doesn't do anything that you couldn't do as eaily in a CASE expression in pure SQL

  • JDBC Sender MSSQL Stored Procedure - Multiple Select Statements

    Hello all,
    I will proceed to tell you my problem, for which solution I request your kind advice:
    Im working in a project for a retailer, which consists in sending the information from erp and sql server to pos thru XI interfaces.
    One of the interfaces is about sending items from sql server to a file so the pos can load it into the system. For doing so I have devloped an stored procedure which function is to return several select statements as many stores the retailer might have, so they can have a different file per store along with its corresponding items in it. 
    The thing is that XI just gets the first select statement and creates the corresponding file, but it seems to ignore the remaining responses as I'm neither getting any file nor an error afterwards.
    So, my question is: is XI capable of handling multiple select responses from an Stored Procedure in graphical mapping??? Or am I just wasting my time trying?
    Thanks in advice for your help.
    Regards.

    Hello Ramkumar,
    After 5 days trying, I finally made it work out applying your advice. Below the short explanation of what I did:
    My Source structure is: Main Node->Row->Records (Material Number, StoreNum, Price, Status)
    My Target structure is: Main Node->File Node->Record Node->Records ( Material Number, Price, Status)
    The key was to make all the occurrences happen against StoreNum node. So, based on what you adviced these two where the key mappings:
    1) The Mapping that will create a new file for each different store that comes in the query (In my case, query was already sort by store using an sql "order by" function, if not you can also use xi node function "sort" as Ramkumar suggested)
    StoreNum->RemoveContext->SplitbyValue (Value Changed)->Collapse Contexts->File Node
    2) The Mapping that will create each record in its corresponding store file:
    StoreNum->RemoveContext->SplitbyValue (Value Changed)->Record Node
    And Voilá !!! It worked.
    Thanks very much Ramkumar.
    Regards.

  • Using procedure in SELECT statement

    I have a select statement that currently uses 4 functions to receive necessary values. All the functions are recursive and returns values from the same row.
    What I would like to do is replace these for function calls with 1 procedure. Does anybody know if it possible to use a procedure in this way inside a select statement?
    If so, do you have the syntax for doing this?
    E.g
    SELECT
    Mdbrd_Pkg.calculate_fixed_charge_fn(in_rc_id, ap.CONFIGSET_ID) AS FIXED_CHARGE,
    Mdbrd_Pkg.calculate_charge_rate_fn(in_rc_id, ap.CONFIGSET_ID) AS CHARGE_RATE,
    Mdbrd_Pkg.tax_liable_fn(in_rc_id, ap.CONFIGSET_ID) AS TAX_LIABLE,
    Mdbrd_Pkg.charge_unit_fn( in_rc_id, ap.CONFIGSET_ID) AS CHARGEUNIT_ID
    FROM .....

    This cannot be done. The part of the function used in the SELECT statement is the return value: procedures don't have return values (that's what makes tham procedures and not functions).
    Obviously I don't know what your code does, but you should consider putting them into a single function that returns a TYPE with four attributes and then using the TABLE() function to cast them into something you could reference in the FROM clause of a correlated sub-query. Sounds a bit messy though.
    Do these functions actually select data? Where does the recursion fit in?
    Cheers, APC

  • Help with calling stored procedure and preparing statement

    hi guys help please..I want to call a procedure set the ResultSet to TYPE_SCROLL_INSENSITIVE and CONCUR_UPDATABLE in order for me to scroll thru the resultset from 1st row to end row and vice-versa..but currently, my code has an error becuase im hot sure on how to do this..Can you please help me guys to solve this? Thanks in advance!
    CODE:
                int c = 0;
                String searchArg = txtSearch.getText();
                String studName, mInitial;
                searchArg = searchArg.replace('*', '%');           
                con = FuncCreateDBConnection();
                con.prepareCall("{call dbsample.usp_StudentInfo_SEARCH(?, ?)}");
                *cStmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);*
                cStmt.setString("searchArg", searchArg);
                cStmt.setString("searchType", cmboSearchBy.getSelectedItem().toString());           
                rs = cStmt.executeQuery();           
                if (rs != null){
                    listModel = new DefaultListModel();           
                    lstSearchResult.setModel(listModel);
                    while (rs.next()){                                      
                          mInitial = rs.getString(4).substring(0, 1).toUpperCase();
                          studName = rs.getString(3) + ", " + rs.getString(2) + " " + mInitial + ".";                     
                          listModel.addElement(studName);
                    System.out.println("Rows:"+ rs.getString(2));                                                     
                          c++;
    ERROR:
    Incompatible Types
    Found : java.sql.Statement
    Required: java.sql.CallableStatement

    Nevermind guys..i got it..
    CODE:
                int c = 0;
                String searchArg = txtSearch.getText();
                String studName, mInitial;
                searchArg = searchArg.replace('*', '%');           
                con = FuncCreateDBConnection();           
                cStmt = con.prepareCall("{call dbsample.usp_StudentInfo_SEARCH(?, ?)}",ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
                cStmt.setString("searchArg", searchArg);
                cStmt.setString("searchType", cmboSearchBy.getSelectedItem().toString());           
                rs = cStmt.executeQuery();           
                if (rs != null){
                    listModel = new DefaultListModel();           
                    lstSearchResult.setModel(listModel);
                    while (rs.next()){                                      
                          mInitial = rs.getString(4).substring(0, 1).toUpperCase();
                          studName = rs.getString(3) + ", " + rs.getString(2) + " " + mInitial + ".";                     
                          listModel.addElement(studName);
                    System.out.println("Rows:"+ rs.getString(2));                                                     
                          c++;
                }     Edited by: daimous on Jan 31, 2008 6:04 PM

  • Can UDConnect call stored procedures?

    When I create a datasource for UDConnect, I can choose to pull data from the source system's table or view into my BW system. Is there a way for me to choose/call the source system's stored procedures instead of just tables and views? Thanks.

    Hi,Chris
    "Stored PL/SQL procedures can be called from data Templates and Oracle Reports."Really?It is a great news for me.
    Currently I am working on a poc.
    There is a problem about calling Oracle stored procedures directly thru BI EE or BI Publisher.
    Our customer has a lot of stored procedures in their previous system,they strongly hope our BI EE can call these sp directly.
    All of these sp return the result set to the cursor,then the applications operate the cursor.
    As there is no way can BI EE working with Oracle stored procedures or cursor,I am wondering whether can I call the sp from BI Publisher.
    Can BI Publisher call sp or pl/sql?Can data template using pl/sql not only pure sql statements?
    I have try write some pl/sql in data template,but it failed.It seems that the data template can only operate on some returned result sets.But sp won't.
    If sp can be called thru data template,everything will be ok for me.For I can use pl/sql to opereate the returned cursor.

Maybe you are looking for

  • Firefox 4.0.1. is having problems with AVG anti-virus and overall hangs, crushes often

    Dear Firefox Why do you upgrade my Firefox 4 browser to this trash, glitchy version of 4.0.1? I'll delete it, reinstall older version Firefox 4 or even 3.6 and will disable automatic update and installation. If not successful I'll switch to another b

  • Home network and FTP giving diffrent drive letters

    I have my iTunes library on a home server and I have it synced to that drive letter (i.e. X:). When I am remote, which is often in my job, I ftp in and get a different drive letter (i.e. T:). When I attempt to do anything it is telling me it can't th

  • I have problem  with user of httpserver trex

    HI, All I have a problem when open de pag http://<Host>:port/TREXHttpServer/TREXISAPIExt.dll, I have to enter the user, but I don't know which ther user??? An other problems I have error  when create  a RFC destination  in TREX admin Tool I don't kno

  • Can't find EXSP 24 -newbie

    Folks, I'm new to LE having switched from Sonar. Love LE and have done audio recording with no problems. I now want to use the EXSP24 sampler, but can't fnd it OR I'm being very dim and not setting up LE properly. I have a lot of Akai samples that I

  • Can I add final cut pro to more than one Mac?

    I'm gonna buy final cut pro 5.1 and I wanted to know if I need to buy 2 or can I just get 1 and put it on both my Macs. I also wanted to know if this will work for Shake 4.1, Logic pro 7, Office 2004. 24" IMac 3GB ram 750 GB hard drive   Mac OS X (10