Calling stored proc (with 2 IN and 3 OUT) - from SQL Plus

This is the signature of my stored proc:
CREATE OR REPLACE PROCEDURE myschema.myproc
   p_usr_name     IN  VARCHAR2,    
   p_send_tmstmp  IN  DATE,    
   p_ret_value    OUT NUMBER,
   p_err_code     OUT VARCHAR2
)If I need to call it from sql plus, how do I need to pass the arg?
This is what I am doing
execute myschema.myproc('abc123','02-MAY-2008');
What is wrong here? If someone could help. Thx!

Try something like this
var usr_name    varchar2(30)  
var send_tmstmp varchar2(11)  
var ret_value   number
var err_code    varchar2(10)
begin
:usr_name    := 'abc123';
:usr_name := '02-MAY-2008';
myschema.myproc ( p_usr_name           => :usr_name,
                  p_send_tmstmp        => TO_DATE( :usr_name, 'DD-MON-YYYY' ),
                  p_ret_value          => :ret_value,
                  p_err_code           => :err_code);
end;
print ret_value;
print err_code;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Calling Oracle Stored proc with record type and table Type

    I have a oracle SP which takes record type and table Type which are used for order management.
    Is there anay way to populate parameters with these datatypes and call the stored procedure using ODP.NET?
    Please help.
    Thanks in advance

    Hi,
    ODP supports associative arrays and REF Cursors. There is no support for PLSQL table of records.
    Jenny

  • Calling Stored Procedure with table type as In parameter from Java

    Hi Everyone,
    Can anyone help me with the sample code to call a stored procedure having input parameter of Table type (consisting of multiple fields) from Java. This job is currently being done by a BPEL process.
    We want to implement the same using Java.
    Any sample code will be really helpful.
    Thanks & Regards,
    Vikas

    To start using a blob you have to insert it into the database and then get it back. Sounds weird but that is how it is. Here is a very simple program to do this:
    #include<occi.h>
    #include <iostream>
    using namespace oracle::occi;
    using namespace std;
    int main()
      try
        Environment *env = Environment::createEnvironment(Environment::OBJECT);
        Connection *conn = env->createConnection("hr","hr","");
        string stmt1 = "insert into blob_tab values (:1) ";
        string stmt2 = "select col1 from blob_tab";
        Blob blob(conn);
        blob.setEmpty(conn);
        Statement *stmtObj = conn->createStatement(stmt1);
        stmtObj->setBlob(1,blob);
        stmtObj->executeUpdate();
        conn->commit();
        Blob blob1(conn);
        Statement *stmtObj2 = conn->createStatement(stmt2);
        ResultSet *rs = stmtObj2->executeQuery();
        while(rs->next())
         blob1 = rs->getBlob(1);
        string stmt3 = "begin my_proc(:1) ;end;";
        Statement *stmtObj3 =  conn->createStatement(stmt3);
        stmtObj3->setBlob(1,blob1);
        stmtObj3->executeUpdate();
      catch (SQLException e)
        cout << e.getMessage();
      /* The tables and procedure are primitive but ok for demo
        create table blob_tab(col1 blob);
        create or replace procedure my_proc(arg in blob)
        as
        begin
         -- just a putline here. you can do other more meaningful operations with the blob here
          dbms_output.put_line('hello');
       end;
    }Hope this helps.
    Thanks,
    Sumit

  • Can I call a function with an arguement of %ROWTYPE directly from SQL?

    I have the following function in a 10g DB:
    CREATE OR REPLACE FUNCTION f_is_eligible2 (in_dm_row IN amplify_dm%ROWTYPE)
    RETURN NUMBER
    IS
    I know I can call that function from another pl/sql function but I'm wondering if I can call that function directly from a SQL statement, something like this:
    SELECT f_is_eligible2(dm.*)
    FROM amplify_dm dm
    or
    SELECT f_is_eligible2(dm%rowtype)
    FROM amplify_dm dm
    neither of those worked so I'm thinking it's not possible but I thought I'd ask anyway.
    Thanks in advance!

    Not possible as said - but - based on what I'm seeing - you could simply pass the parameter(s) that are key on that table and - accomplish the same thing by modifying the function.
    not sure why you'd need the whole row if I'm interpretting the code excerpt.

  • Stored Proc with SSRS multi value parameter gives " Must Declare scalar Varaiable @StateID

    Hi All,
    I have one stored proc with @fromDate , @Todate and multivalue input
    parameter@StateID of type integer.
    When I run below stored proc via SSRS by selecting multiple values thru multiValue parameter into @StateID...it gives error saying "Must Declare scalar variable @StateID"
    Not sure what is wrong with the input parameters.
    ID is Integer type in all the 3 tables - dbo.EastCities, dbo.WestCities  , dbo.Country
    I need help fixing this  "Must Declare scalar variable @StateID" error
    This is the UDF split() I am using..
    Function:
    CREATE FUNCTION dbo.SplitStateID
    (    @List VARCHAR(MAX))
    RETURNS TABLE
    AS   
    RETURN   
    (        SELECT DISTINCT [Value] = CONVERT(INT, LTRIM(RTRIM(CONVERT( VARCHAR(12),SUBSTRING(@List, Number, CHARINDEX(',', @List + ',', Number) - Number))))
     FROM  dbo.Numbers       
     WHERE Number <= CONVERT(INT, LEN(@List))AND SUBSTRING(',' + @List, Number, 1) = ','    );
     GO
     SELECT [Value] FROM dbo.SplitStateID('10,30,50');
    Also, I have created dbo.Numbers table which is used in udf..
    reference url -- > 
    http://sqlblog.com/blogs/aaron_bertrand/archive/2009/08/01/processing-a-list-of-integers-my-approach.aspx
    SET NOCOUNT ON;
    DECLARE @UpperLimit INT;
    SET @UpperLimit = 10000;
    WITH n AS(   
    SELECT        rn = ROW_NUMBER() OVER        (ORDER BY s1.[object_id])   
    FROM sys.objects AS s1   
    CROSS JOIN sys.objects AS s2   
    CROSS JOIN sys.objects AS s3)
    SELECT [Number] = rn - 1
    INTO dbo.Numbers FROM n
    WHERE rn <= @UpperLimit + 1;
    CREATE UNIQUE CLUSTERED INDEX n ON dbo.Numbers([Number]);
    Stored procedure:
    Create Procedure dbo.CountrySelection
    ( @FromDate Date, @ToDate Date, @StateID Int)
    AS
    BEGIN
    set nocount on;
    SELECT * INTO #EastCities
    FROM (
    SELECT ID,Description from dbo.EastCities
    Where ID IN (SELECT Value from dbo.SplitStateID(@StateID))
    ) AS A
    SELECT * INTO #WestCities
    FROM (
    SELECT ID,Description from dbo.WestCities
    Where ID IN (SELECT Value from dbo.SplitStateID(@StateID))
    ) AS B
    SELECT * INTO #Country
    FROM (
    SELECT ID , Description, State,Country From dbo.Country
    ) AS C
    SELECT EC.ID AS East, WC.ID AS West , EC.Description AS EastDesc, WC.Description AS WestDesc, CT.State, CT.Country
    FROM #Country CT
    LEFT JOIN #EastCities EC ON CT.ID=EC.ID
    LEFT JOIN #WestCities WC ON CT.ID=WC.ID
    DROP TABLE #EastCities
    DROP TABLE #WestCities
    DROP TABLE #Country
    END
    Above 3 temp tables are joined by #Country.ID key
    It works fine when single value is passed in @StateID
    Exec dbo.CountrySelection '01/01/2010','02/01/2010',10
    It fails when multi value passed into @StateID
    Exec dbo.CountrySelection '01/01/2010','02/01/2010','10,30,40'
    SSRS error log shows "Must declare scalar variable @StateID"
    Need help in fixing this issue.
    Thanks,
    RH
    sql

    Visakh,
    I changed @StateID date type to varchar(max) and still I get this error.  
    System.Data.SqlClient.SqlException: Must declare the scalar variable "@StateID".
       at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
    I am running this SO in SSRS quert Type =Text
    Actually sp created on db2 database and due to some limitations I am running(via SSRS) this from different db1 database data source within the same db server. When I run this sp from SSRS query designer(edit query designer button) and pass
    multivalue parameters to @StateID as 10 , 20 it works and gives expected resultset.
    Thanks,
    RH
    sql

  • How to call stored procedure with multiple parameters in an HTML expression

    Hi, Guys:
    Can you show me an example to call stored procedure with multiple parameters in an HTML expression? I need to rewrite a procedure to display multiple pictures of one person stored in database by clicking button.
    The orginal HTML expression is :
    <img src="#OWNER#.dl_sor_image?p_offender_id=#OFFENDER_ID#" width="75" height="75">which calls a procedure as:
    procedure dl_sor_image (p_offender_id IN NUMBER)now I rewrite it as:
    PROCEDURE Sor_Display_Current_Image(p_n_Offender_id IN NUMBER, p_n_image_Count in number)could anyone tell me the format for the html expression to pass multiple parameters?
    Thanks a lot.
    Sam

    Hi:
    Thanks for your help! Your question is what I am trying hard now. Current procedure can only display one picture per person, however, I am supposed to write a new procedure which displays multiple pictures for one person. When user click a button on report, APEX should call this procedure and returns next picture of the same person. The table is SOR_image. However, I rewrite the HTML expression as follows to test to display the second image.
    <img src="#OWNER#.Sor_Display_Current_Image?p_n_Offender_id=#OFFENDER_ID#&p_n_image_Count=2" width="75" height="75"> The procedure code is complied OK as follows:
    create or replace
    PROCEDURE Sor_Display_Current_Image(p_n_Offender_id IN NUMBER, p_n_image_Count in number) AS
        v_mime_type VARCHAR2(48);
        v_length NUMBER;
        v_name VARCHAR2(2000);
        v_image BLOB;
        v_counter number:=0;
        cursor cur_All_Images_of_Offender is
          SELECT 'IMAGE/JPEG' mime_type, dbms_lob.getlength(image) as image_length, image
          FROM sor_image
          WHERE offender_id = p_n_Offender_id;
        rec_Image_of_Offender cur_All_Images_of_Offender%ROWTYPE;
    BEGIN
        open cur_All_Images_of_Offender;
        loop
          fetch cur_All_Images_of_Offender into rec_Image_of_Offender;
          v_counter:=v_counter+1;
          if (v_counter=p_n_image_Count) then
            owa_util.mime_header(nvl(rec_Image_of_Offender.mime_type, 'application/octet'), FALSE);
            htp.p('Content-length: '||rec_Image_of_Offender.image_length);
            owa_util.http_header_close;
            wpg_docload.download_file (rec_Image_of_Offender.image);
          end if;
          exit when ((cur_All_Images_of_Offender%NOTFOUND) or (v_counter>=p_n_image_Count));
        end loop;
        close cur_All_Images_of_Offender;
    END Sor_Display_Current_Image; The procedure just open a cursor to fetch the images belong to the same person, and use wpg_docload.download_file function to display the image specified. But it never works. It is strange because even I use exactly same code as before but change procedure name, Oracle APEX cannot display an image. Is this due to anything such as make file configuration in APEX?
    Thanks
    Sam

  • Calling Stored Procedure with TestStand to SQL 2000

    When I run the Stored Procedure in the query analyzer it returns the recordset fine. I am not specifying any parameters. I am Using TestStand 2.01 and SQL Server 2000. I am using the OPEN SQL STATEMENT step to call the SP. When I run the SP in TestStand I get no data returned. If I run the SQL statment in TestStand I get the data that I am requesting. Does TestStand not support stored procedures.

    Hi,
    The instructions that I posted were for TestStand 3.0. In version 3.0 you can call stored procedures with input/output paramateres and to support this functionality the data operation step support several new modes.
    TestStand 2.0.1 does not support parameters on stored procedures, but it does support calling stored procedures that do not take parameters. To be able to access the data back from the database you need to set the cursor location (in the Advanced tab of the Open SQL Statement step) to Client (http://digital.ni.com/public.nsf/websearch/0EF68BF97AB1A61F86256B8E007D70C0?OpenDocument).
    By changing the cursor to Client I was able to succesfully call a stored procedure from TestStand 2.0.1 and to read back the recordse
    t return by the database. Please let me know if you are still experiencing dificulties.
    Best regards,
    Alejandro del Castillo
    National Instruments

  • BPC5.1 - Data manager package to Stored proc with custom return codes

    Hi all,
    Does anyone have experience passing the return codes from a stored procedure back into the eData "view status" package progress or event log details?
    When my stored procedure throws errors, the offending SQL code shows up in the pacakge details, which is helpful. But what I'd really like is to structure my stored proc with return codes
    0 = everything's wonderful
    1 = invalid category / time combination
    2 = unauthorized
    3 = no data to process
    And then handle these codes as either "completed" "warning" or "error" in the package progress.
    And ideally, I'd like to put some meaningful message about the warnings & errors, directly into the log details, so the user can fix the problem themselves rather than ask the IT guy to trouble-shoot.
    Any tips? I've started playing with using the on-complete, on-success, on-failure routing of different tasks within the DTSX package (SQL 2005), but I'm just working on a trial-and-error basis right now. (With # of errors = # of trials.)
    Thanks,
    Tim

    In case anyone's interested, I've solved this by tracking my return codes as a package variable.
    Within the package, I have conditional logic moving from task to task, evaluating the return code to check for various conditions, and selecting which tasks to perform accordingly.
    In the last task, I run a final stored procedure which posts some data (completion time & status) to a custom transaction log table, and then if the return code is not zero, I script and execute some SQL which I know will throw a "fake" error. The SQL statement itself includes the key information I want the end user to see. For example
    Select InvalidEntitySelection [USEast1],TransactionID [12340]  from ThisTableDoesntExist
    Select UnauthorizedUser [Tim], TransactionID [12345] from ThisTableDoesntExist
    Select WorkStatusIsLocked [USEast1 Actual 2008], TransactionID [12345] from ThisTableDoesntExist
    It's not exactly elegant, but it gets the message across, which is all that I need. In this way, the end user sees that the package failed with an error, and when they look at the package details, they can see the problem. They can pass on the transaction ID to an administrator to look into the details, if they can't figure it out on their own.
    Sorin, I never managed to figure out how to use a VB task to send the information back to the user, plus force the package to end in an error. I'm sure there's a way to do so, but this seems to work for my requirement.
    I'm not entirely happy with the "fake error" approach, but I don't know if BPC has any support for "intentional" programming of errors in the DTS scripting toolset.
    Thanks,
    Tim

  • SQL Exception: Invalid column index while calling stored proc from CO.java

    Hello all,
    I am getting a "SQL Exception: Invalid column index" error while calling stored proc from CO.java
    # I am trying to call this proc from controller instead of AM
    # PL/SQL Proc has 4 IN params and 1 Out param.
    Code I am using is pasted below
    ==============================================
              OAApplicationModule am = (OAApplicationModule)oapagecontext.getApplicationModule(oawebbean);
    OADBTransaction txn = (OADBTransaction)am.getOADBTransaction();
    OracleCallableStatement cs = null;
    cs = (OracleCallableStatement)txn.createCallableStatement("begin MY_PACKAGE.SEND_EMAIL_ON_PASSWORD_CHANGE(:1, :2, :3, :4, :5); end;", 1);
         try
    cs.registerOutParameter(5, Types.VARCHAR, 0, 2000);
                        cs.setString(1, "[email protected]");
                             cs.setString(2, s10);
    //Debug
    System.out.println(s10);
                             cs.setString (3, "p_subject " );
                             cs.setString (4, "clob_html_message - WPTEST" );
                   outParamValue = cs.getString(1);
    cs.executeQuery();
    txn.commit();
    catch(SQLException ex)
    throw new OAException("SQL Exception: "+ex.getMessage());
    =========================================
    Can you help please.
    Thanks,
    Vinod

    You may refer below URL
    http://oracleanil.blogspot.com/2009/04/itemqueryvoxml.html
    Thanks
    AJ

  • What's the phone number I should call for help with my iPhone and ihome dock?

    What's the phone number I should call for help with my iPhone and ihome dock?

    http://www.ihomeaudio.com/support/

  • Slight roadblock in "DW 8 with ASP, ColdFusion, and PHP: Training from the Source"

    I'm working my way through Dreamweaver 8 with ASP,
    ColdFusion, and PHP:
    Training from the Source. I've come to the middle of Lesson 6
    and have hit
    my first obstacle in learning PHP. I'm following the
    instructions to format
    the output of the tour price calculator, but my issue is with
    where to place
    the following PHP code: <?php setlocale(LC_MONETARY,
    'en_US'); echo
    money_format('%i', $tourPrice); ?>
    I placed it before the DOCTYPE and when that didn't work, I
    tried inserting
    right before the code that retrieves the tour price (in the
    body of the
    page). That didn't work either.
    I also tried changing money_format to number_format and
    manually inserting
    the $, but when I tested everything, the output printed as
    follows:
    The estimated cost of your tour is
    $0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000500.
    I'm not quite sure where I've gone wrong.
    Thanks for any help,
    Heather

    Coach Bob wrote:
    > David,
    >
    > I would like to understand better your comment about the
    money_format. The
    > ability to use it is dependent on the host system's
    support of the C library
    > function strfmon(), correct? So if a user were
    developing on a windows box with
    > a local WAMP install it would not work while it may work
    on their *nix-based
    > Web host?
    Check the PHP documentation - it tells you all you need to
    know:
    http://www.php.net/manual/en/function.money-format.php
    > I will see to it that it gets corrected in the next
    version of the book!
    I've no idea what relationship you have with "Training from
    the Source",
    but I find it interesting - to say the least - that you need
    to the ask
    the author of a rival book.
    David Powers, Adobe Community Expert
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • Had a problem with newest update and the advice from turingtest2 resolved my problem just to say thanks! Had never used this route before so was less painful than thought it would be again thanks.

    Had a problem with newest update and the advice from turingtest2 resolved my problem just to say thanks! Had never used this route before so was less painful than thought it would be again thanks.

    how can i find out what the fix is that works..please

  • HT201272 Hi there! today i wanted to buy some gems so i charged my acc with 10 dolars and try out to buy gems. problem is i m getting "your purchase could not be completed" error... I have tried all possible solutions i found on internet...my restrinction

    Hi there! today i wanted to buy some gems so i charged my acc with 10 dolars and try out to buy gems. problem is i m getting "your purchase could not be completed" error...
    I have tried all possible solutions i found on internet...my restrinctions are disabled...tried reinstaling, relogging, restarting phone.. nothing seems to help...
    normally i would contact custommer support but i m using US account and i m not from US. anyway my US account is charged with money and it workes perfectly for all my other friends using this method ( we got some free US vouchers so we needed US accounts)
    Any advice?
    thanks in advance

    iTunes Store Support
    http://www.apple.com/emea/support/itunes/contact.html

  • My iphone synched with a computer and wiped out my contact.  can they be recovered?

    my iphone synched with a computer and wiped out my contacts.  can they be recovered?

    Yes, if you still have a backup from the time before this happened, see this article for more info: iPhone and iPod touch: About backups

  • How to delete forecast entries with zero current and original qty from a particular forecast set which span across multiple forecasts

    how to delete forecast entries with zero current and original qty from a particular forecast set which span across multiple forecasts

    Hi,
    There is no way to delete those records selectively from front end.
    The best possible way is to delete the records from MRP_FORECAST_DATES tables from backend.
    Hope that helps!!
    Regards,
    Mohan Balaji
    NOTE: Please mark the post as Helpful or Answered if the update has really helped you. This would also bring the thread to logical conclusion and will be helpful for the viewers.

Maybe you are looking for

  • Best practice of coding optional prompts

    Post Author: maddyforums CA Forum: WebIntelligence Reporting I have a report that has 35 optional prompts for which I want to pass default values if the user doesnu2019t enter any values. This report was originally designed using BO 6.5 and has to be

  • BB 8530

    HELLO i just bought a BB 8530 and i want to insert a sim card how can i do it? because is different from the others.. is it possible or do i need to change it? thanks 

  • Po release not possible

    [Re: po release is not posible].I have tried this link but didnt work anything.Plz Suggest.I tried deactivating exit .tried all release tables.but didnt work cl24n checked throght all end.

  • How do I syncronize and implement MANY DAQ cards?

    I need to acquire 30 channels of analog data at 400 kHz scan rate (all 30 channels is one scan. It would be preferable to convert all 30 cahannels simultaneously and stream data to disk for long data collection times. Signal conditioning such as inte

  • How can I close the iCloud screen if it is stuck?

    I have the iCloud screen up from System Preferences and I can not get it to close. How can I get that fixed?