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.

Similar Messages

  • 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;

  • 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

  • Stored procedure with select query

    Hi,
    I have a problem , We have a sysnchronous scenario and executing a stored procedure and a selcect statement .
    it is running fine with little confilt in data is there.
    We we run the scenario it execute the strored procedure and return the value like 500 and under select statement it select entire table which has same flag.
    I want to execute stored procdure and in slect statement one row at a time and then again it will insert to other table in then database.
    currently we are getting value like this.
      <?xml version="1.0" encoding="utf-8" ?>
    - <ns0:MT_SP_JDBC_response xmlns:ns0="http://ns_cfgCountry">
    - <GetNextSiteNumber_response>
      <Result>10000000000400</Result>
      </GetNextSiteNumber_response>
    - <Statement2_response>
    - <row>
      <ID>IN</ID>
      <Description>INDIA</Description>
      <GDate />
      <FLAG>FALSE</FLAG>
      </row>
    - <row>
      <ID>EN</ID>
      <Description>ENGLAND</Description>
      <GDate />
      <FLAG>FALSE</FLAG>
      </row>
    - <row>
      <ID>ZA</ID>
      <Description>SA</Description>
      <GDate />
      <FLAG>FALSE</FLAG>
      </row>
      </Statement2_response>
      </ns0:MT_SP_JDBC_response>
    Regards
    Laxmi Bhushan Jha

    Hi,
    Can u please write your req little clear....
    If you want to selcect and update a table and again select ... what ever it may be.... all these has to be done in the stored procedure only.
    At the end of all ur statements u pass back the value from your Stored Procedure
    Babu

  • Call selectlist inside select query

    Can i call selectlist in side select query.
    example: select empno,p1_job,sal from emp;
    in this job_lov is having the following query.
    select job from emp;
    this lov is attached one text item p1_job.
    p1_job should be called as drop down in side the query. How can i call select list.
    please help

    I forgot to mention that there is no relation between lov and emp table.
    Example job is not there in emp. it is completeley independent select list.
    select emp,p1_job,empno from emp.
    but there is no relation between p1_job and emp table.
    it is completeley indepent select list.
    lov query is select job from jobs;
    Edited by: 893185 on Apr 2, 2012 11:25 AM

  • Call the Function against a select query in 500 procedures...

    Hello Gurus,
    I have a scenario, where i had made one function(UDF Function) to calculate something and in every procedure i call that function and calculate my requirement.
    Yesterday, i made a select query using reg exp for the same calculation..
    So my question is, what should be the proper approach..
    I need to implement this on 500 procedures...
    And the UDF function is
    CREATE OR REPLACE FUNCTION "UDF_TEXTSPLIT" (
    p_list VARCHAR2,
    p_del VARCHAR2 := ','
    ) RETURN split_tbl pipelined
    IS
    l_idx PLS_INTEGER;
    l_list VARCHAR2(7999) ;
    l_value VARCHAR2(7999);
    BEGIN
    l_list := p_list;
    LOOP
    l_idx := INSTR(l_list,p_del);
    IF l_idx > 0 THEN
    pipe ROW(SUBSTR(l_list,1,l_idx-1));
    l_list := SUBSTR(l_list,l_idx+LENGTH(p_del));
    ELSE
    pipe ROW(l_list);
    EXIT;
    END IF;
    END LOOP;
    RETURN;
    END Udf_Textsplit;
    I have made this query:
    SELECT a.b,z. b1 FROM
    (SELECT ROWNUM d,REGEXP_SUBSTR(str1, '[^> ]+', 1, LEVEL) b
    FROM (SELECT 'xxx>zzz>gg' str1 FROM dual)
    CONNECT BY REGEXP_SUBSTR(str1, '[^> ]+', 1, LEVEL) IS NOT NULL)a,
    (SELECT ROWNUM d,REGEXP_SUBSTR(str1, '[^> ]+', 1, LEVEL) b1
    FROM (SELECT '100>500>20' str1 FROM dual)
    CONNECT BY REGEXP_SUBSTR(str1, '[^> ]+', 1, LEVEL) IS NOT NULL)z
    WHERE a.d=z.d
    Do i use the same select query in all 500 procedures or call the (UDF Function) in every procedure..
    So which will be faster...
    Your approach would be very much appreciated...
    Thanks,
    Haraprasad...

    Hmm, do I edit 500 procedures to replace a function call with a SQL statement, or edit 1 function to use a sql statement instead of the current algorithm?
    This is why we use code modules that do one thing and do it well. As long as the new version of the function takes the same arguments and returns the same results as the old, then the callers will never know that the way the function works has changed.
    Whenther you put the select statement in 500 procedures, or 1 function, there will still be a context switch every time you use it. The tiny additional overhead of calling a function before the context switch would be unnoticeable.
    John

  • Can we get data return from stored procedure in a select query ?

    Hello,
    Suppose i have a function GetSum(x,y) that returns sum of two numbers x and y .We can call this function from within a sql function like this :
    select GetSum(4,5) SUM from dual;But is this possible through a stored procedure ? i.e., can i call a stored procedure from within a select query like i have done in above code ?

    Hi,
    bootstrap wrote:
    Hello,
    Suppose i have a function GetSum(x,y) that returns sum of two numbers x and y .We can call this function from within a sql function like this :
    select GetSum(4,5) SUM from dual;But is this possible through a stored procedure ? i.e., can i call a stored procedure from within a select query like i have done in above code ?The short answer has already been given.
    Why can't you use a function?
    Suppose you could use a procedure. What results would you want to see from:
    SELECT  my_proc (4, 5)
    FROM    dual
    ;? Why?
    Explain what you want to do, and somebody will help you find a good way to do it.

  • SELECT Query in a Procedure

    how do I create a procedure for a SELECT query like the following? When I create a procedure; I get an error "
    Error(80,1): PLS-00428: an INTO clause is expected in this SELECT statement"
    PROCEDURE  MyProc
    IS
    BEGIN
    select 'Dakota' as ALIAS
          ,A.StartDate
          ,B.EndDate
    from Customer A
        ,Clients b
    where  a.cType = b.cType
    and b.Active =0
    ORDER BY StartDate, EndDate
    END  MyProc;

    I get an error:
    Error(4,29): PLS-00103: Encountered the symbol "SYS_REFCURSOR" when expecting one of the following: := . ) , @ % default character The symbol ":=" was substituted for "SYS_REFCURSOR" to continue. 
    Package:
    PROCEDURE  MyProc(c out OUT SYS_REFCURSOR)
    Package Body:
    PROCEDURE  MyProc(c out OUT SYS_REFCURSOR)
    IS
    BEGIN
      open c for
                select 'Dakota' as ALIAS
                            ,A.StartDate
                            ,B.EndDate
                from Customer A,Clients b
                where  a.cType = b.cType
                     and b.Active =0
                ORDER BY StartDate, EndDate;
    END  MyProc;

  • How to call pl/sql stored procedure in JDBC query dialogbox

    Hi,
    how to call pl/sql stored procedure in JDBC query dialogbox(reports 9i) .
    Cheers,
    Raghu

    please refer : Re: problem If you have more doubts, please ask in that question.

  • Calling Oracle stored procedure from xMII Query Templates.

    Hi All,
    We have a requirement to call a Oracle stored procedure from xMII, the SP expects some inputs and then it returns multiple rows.
    I tried different approches with no results, I remember some posts on the same topic but I could not get in search results.
    Looking for some help in this regards
    Rupesh.

    Hi Rupesh Bajaj,
    In oracle stored procedure we have to use Packages..if you used packages the u have to assign to some variable.
    To calling Stored procedure  in Query Template is CALL Testing('[Param.1]','[Param.2]',,:X)
    In above line Testing is Stored procedure name and Param.1 is parameters and X is Package.
    Thanks
    Ravilla Ramesh

  • SELECT query from within a stored procedure

    DB Version:10gR2
    For auditing purpose, i just want to execute the query within the IF condition, and get the results for spooling. But i am getting PLS-00428 error. Can't i just execute a SELECT query and get its results displayed in SQLPLUS so that i can spool them?
    SQL&gt; create or replace procedure ship_dtl_aud
      2  is
      3  v_exists number;
      4 
      5  begin
      6  
      7  Select count(1) into v_exists
      8  From ship_dtl
      9  WHERE track_code = 10
    10  AND mod_date_time &lt; SYSDATE - 1/(24*60);
    11 
    12   if v_exists&gt;0
    13   then
    14            select s.username,s.sid, s.serial#, s.terminal,p.spid
    15   from v$session s, v$process p
    16   where s.paddr = p.addr and s.sid in (select SESSION_ID from V$LOCKED_OBJECT);
    17 
    18          end if; 
    19  end;
    20  /
    Warning: Procedure created with compilation errors.
    SQL&gt; show errors
    Errors for PROCEDURE ship_dtl_aud:
    LINE/COL ERROR
    14/11    PLS-00428: an INTO clause is expected in this SELECT statement

    Within PL/SQL code, the results of a query have to be returned from the SQL engine to the PL/SQL engine, hence why it is asking you to include an INTO within your query. Note that the PL/SQL engine is running on the database server so it has no interface to display output to. To output from within PL/SQL you would have to write the data out yourself to whatever output you want e.g. use DBMS_OUTPUT to put the data to the standard output buffer (which can then be read by SQL*Plus if serveroutput is set to "on") or written out to a file on the server, or written out to a table.
    You are assuming that because you can execute SQL from SQL*Plus and spool the output, you can do the same within PL/SQL. This is not the case. When SQL*Plus issues a SQL statement, it goes to the SQL engine and the results of that cursor (as an SQL query is a cursor) are collected by SQL*Plus and it displays them itself. When PL/SQL issues a SQL statement, it goes to the SQL engine and the results of that cursor come back to PL/SQL. PL/SQL doesn't have a display mechanism, so the results have to be collected INTO something.
    Hope that's clear.

  • Design a procedure which returns a result set of a select Query

    Hi...
    Can some one help me out with a brief design or work around for creating a stored procedure which runs a select Query and Returns a result set...
    If not a stored procedure, at least a function which makes the job simple....
    Awaiting help in this regard ........

    Hi...
    I am sorry for providing insufficient Info...
    Actually I am using Oracle 10G DB...
    I have a select Query..
    Since I am a part of team which is building a Complete Data Driven site, Even an SQL Query and a PL/SQL function body was stored in the Table itself to bring in some kind of Dynamism in the site.... But the master table was loaded with a lot of data and hence Now we decided to Store everythin in a generic package..
    I used REF CURSORS to store a result set of a simple SELECT Query.... and declaring it as an out parameter in my Procedure body so that the JAVA team can directly access the Procedure from the JAVA layer....
    Now I want to know can I do anything more efficient to carry out the above operation....

  • Send SQL query or call stored procedure, which is best???

    hello experts!!
    i would like to ask what will be the best implementation on querying a database using Java, send a SQL query(insert into table values...) or call stored procedure(just pass parameters)?? and also in stored procedure does "autoCommit/rollback" applies/make sense??

    I searched google for this:
    Stored Procedures vs. SQL
    and found this useful link:
    http://www.karlkatzke.com/stored-procedures-vs-sql-calls/
    I thiink you should also read up on other articles based on such google searches
    to get other opinions. Also, read the links provided by that article.
    Personnally, I think stored procedures should be avoided unless there is a definite
    advantage as specified in the above article. Especially not used for CRUD operations.
    Also, no matter where you put the SQL, it should be documented. I've seen too many stored procedures that aren't documented.

  • How to call store procedure in query generator

    Hi All,
    How to call store procedure in query generator.
    Regards
    Rajkumar Gupta
    Edited by: Rajkumar Gupta on Dec 7, 2010 2:11 AM

    Hi,
    Please check the following threads.
    How to use Stored Procedure in sap business one
    How to add parameters to a stored procedure in B1 Query generator
    How to execute the procedure in sap b1
    Hope it helps,
    Vasu Natari.

  • Need sample source code for calling stored procedure in Oracle

    Hi.
    I try to call stored procedure in oracle using JCA JDBC.
    Anybody have sample source code for that ?
    Regards, Arnold.

    Thank you very much for a very quick reply. It worked, but I have an extended problem for which I would like to have a solution. Thank you very much in advance for your help. The problem is described below.
    I have the Procedure defined as below in the SFCS1 package body
    Procedure Company_Selection(O_Cursor IN OUT T_Cursor)
    BEGIN
    Open O_Cursor FOR
    SELECT CompanyId, CompanyName
    FROM Company
    WHERE CompanyProvince IN ('AL','AK');
    END Company_Selection;
    In the Oracle Forms, I have a datablock based on the above stored procedure. When I execute the form and from the menu if I click on Execute Query the data block gets filled up with data (The datablock is configured to display 10 items as a tabular form).
    At this point in time, I want to automate the process of displaying the data, hence I created a button and from there I want to call this stored procedure. So, in the button trigger I have the following statements
    DECLARE
    A SFCS1.T_Cursor;
    BEGIN
    SFCS1.Company_Selection(A);
    go_Block ('Block36');
    The cursor goes to the corresponding block, but does not display any data. Can you tell me how to get the data displayed. In the future versions, I'm planning to put variables in the WHERE clause.

Maybe you are looking for

  • I'm afraid of my MacBook? :(

    please forgive me if I'm misusing these forums- I'm new! I'll start by saying that I am a (notorious among friends) non-complainer. I am also a huge apple lover. I have the phone, the pad and the computer. My father's industry is very reliant on appl

  • Unable to load ADFS 2.0 in Windows Server 2.0

    I am trying to federate a domain in Office 365. The AD FS servers are running Windows 2012 R2 and AD FS appears to be working properly. The errors I receive are shown below. PS C:\Windows\system32> import-module msonline PS C:\Windows\system32> Conne

  • Will ipod touch settings copy to a new iphone with cloud / same apple id?

    My daughter has an ipod touch 4th generation. I had set the restrictions on her touch, but have since forgotten the password. We are giving her an iphone 5c for the holidays and I'm wondering if she uses the same itunes/apple account for her phone as

  • Open Item Clearing: Exchange Rate Differences

    Hi guru I have one account 100 and in fbl3n I have the following posting: document number 1: account 100--> Amount 2000$ in S, Exchange rate 0,63 document number 2: account 100--> Amount 2000$ in H, Exchange rate 0,70 Then I have cleared this account

  • IDOC to mutiple systems.

    Hi Paulie, Yes this can be achieved through enhanced receiver determination. If both the conditions that you provide for the mapping of Service node on the target, the message is send to both the systems. But i think you will need enhanced interface