Pass a datarow as input parameter in a stored procedure

Hi everyone!
I wonder if anyone know how to pass a datarow (better if tipized like "tablenameRow") as input parameter for a stored procedure.
links or suggestions are welcome! (i'm newbie in .net programming, so if you can post some code i'll be really grateful!)
Thank you!

Hi,
YES!! its possible you can pass a datarow to a SP from your Dot net application.
Here below i'm going to give you an example for Desktop Application.
For Passing a datarow as Input Parameters, your SP need to support for all these parameters.
I mean, if a data row has 03 Columns. Then your procedure should be able to take 03 arguments/parameters.
--Adjust code according to your need.
--Its for C# Desktop application.
--Visual Studio Professional, Framework (2.0)
//Setting connections.
OracleConnection con=new OracleConnection("Data Source=orcl9i; user id=scott; password=tiger");
OracleComand cmd=new OracleCommand(con);
cmd.Type=CommandType.StoredProcedure; //you are useing SP
cmd.Text="my_stored_procedure"; //Mention SP name.
--if DataRow has Three columns. You need three parameters.
OracleParameter p1=new OracleParameter ();//By default parameters are input parameters.
OracleParameter p2=new OracleParameter ();
OracleParameter p3=new OracleParameter ();
//We assume that Datarow already has data in it.
p1.ParametersName="sp_var1 ";
p1.OracleDbType=OracleDbType.Varchar;
p1.Value=tablenameRow[1]; //Here DataRow object's Column1 is input.
p2.ParametersName="sp_var2 ";
p2.OracleDbType=OracleDbType.Varchar;
p2.Value=tablenameRow[2]; //Here DataRow object's Column2 is input.
p3.ParametersName="sp_var3 ";
p3.OracleDbType=OracleDbType.Varchar;
p3.Value=tablenameRow[3]; //Here DataRow object's Column3 is input.
cmd.OracleParameter.Add(p1); //Add parameters.
cmd.OracleParameter.Add(p2); //Add parameters.
cmd.OracleParameter.Add(p3); //Add parameters.
cmd.ExecuteNonQuery(); //Execute Procedure here.
Feel free to ask if still found problem.
....

Similar Messages

  • Set Null as Default  for input parameter to a stored procedure

    hi ,
    How can we set default values as NULL to an input parameter in a stored Procedure.
    create or replace procedure emp_proc ( p_test_input in varchar2
                                                        p_emp_id in number,
                                                        p_emp_name in varchar2,
                                                       p_manager_id in number )
    as
      begin
       if ( upper ( p_test_input ) = 'I' )
       then
          insert into emp
          values      ( p_emp_id  ,p_emp_name ,p_Manager_id,sysdate );
       elsif ( upper ( p_test_input ) = 'D' )
       then
          delete from emp
          where       emp_id  = p_emp_id;
       else
          dbms_output.put_line
             ( 'Please input ''A'' for ADD or ''D'' Delete  EMPLOYEE'
       end if;
    end;As Shown above if i want to do only delete operation
    i want to call this procedure like without passing extra parameters .
    EXECUTE  emp_proc('D',1010);Edited by: Rede on May 28, 2010 12:21 PM
    Edited by: Rede on May 28, 2010 12:22 PM

    create or replace procedure emp_proc ( p_test_input in varchar2,
                                                        p_emp_id in number,
                                                        p_emp_name in varchar2 default null,
                                                       p_manager_id in number default null )

  • Can I pass an array as an input parameter for a stored procedure on SQL Server 2000

    I am trying to pass an array to a stored procedure residing on my SQL Server 2000 database server. Is this even possible? If it is possible, what is the syntax for this?
    Any help would be greatly appreciated.
    Thanks

    I have passed arrays to and from a database using SQL and ActiveX, including to and from stored procedures, but I cannot recall the precise method used to do so. If memory serves, everything is in the form of a string. You need to do a lot of parsing and 'unparsing' to get this data into your stored procedure.
    You are left with a couple of options to get your data to the stored procedure. I recommend using SQL in LabVIEW wherever possible as it saves the amount of external code calls (and believe me, calling ActiveX procedures developed by someone else in Visual Basic is NOT much fun at all...). You can either send the array and other data to the stored procedure (you will find the syntax in the SQL references in LabVIEW help under SQL), or you can send
    the array to the database, and have the database then act upon the array.
    I strongly recommend making routines (subVIs) to handle these operations.
    Sorry I don't have the syntax, I don't have SQL installed on this machine. If you can't find the syntax in the help, please post here again.
    -Mike Du'Lyea

  • Question?? - passing 2D array as a parameter of a stored procedure

    Hi,
    I have been having a lot of trouble with executing a stored procedure. I'm hoping someone can help me with this:
    THe stored proc. has 10 parameters, 5 IN and 5 OUT. One of these parameters coming out is a 2D array, however I"m not sure how I would be able to call the correct OCCI type coming out.
    I've declared a 2D array char sample[10][10];
    and then:
    stmt - > registerOutParam ( 7, oracle::occi:OCCI*???, sizeof(sample);
    and then :
    char outarray[10][10];
    out_array = stmt -> getString??? get*??
    I tried just passing a string itself, but as the procedure is looking for a 2D array, the program aborts, but I'm really not sure how I can solve this...??
    I'm kind of new to this subject, and I would really appreciate any help anyone can provide, with being able to pass in a 2D char array and being able to receive the outcomning data.
    Thanks a lot for any help!

    Hi,
    thank you for the link, it helped a lot....
    my C++ app that calls my stored procedure does compile, however, when I execute it "Aborts". I debugged it and found that right before my
    stmt->executeUpdate()
    statement, it outputs "Aborts", I'm really not sure why this is aborting, are there any specific debug statements or anything I can use specific to occi so that I can trace why my program aborts right before the executeUpdate statement (also I have checked my procedure and it is compiled and valid, and all my parameter types are correct).
    Does anyone have any ideas??
    Any help on this matter is really appreciated... thank you

  • Ignoring blank input parameter in a stored procedure

    I'm trying to write a SP that ignores a blank parameter in a
    where clause like this.
    create procedure blah @myvar int AS
    select * from companies
    where 1 = 1
    if @myvar is <> ''
    and id = @myvar
    This seems like a simple task but it doesn't work. Thanks in
    advance

    Assuming SQL Server, you might try something like this:
    SELECT *
    FROM companies
    WHERE id = ISNULL(@myvar, id)
    If your @myvar parameter is NULL, then your WHERE clause is
    basically
    id = id, which makes it a "don't care" condition and returns
    all rows as if there was no where clause. You can add other
    parameters to your where clause, and they would not be affected, as
    this condition would only restrict the selection if @myvar was not
    null, otherwise it is "ignored".
    Phil

  • How to pass a table as parameter on a stored procedure

    Hello all,
    I want to pass the name of a table as parameter into a stored procedure, that will be used for cursors etc.
    But when i pass the parameter and i compile the S.P. it give me error (error: table not existing...)
    Any Help?
    Thanks in advance, Marco

    Marco wrote:
    As i've written above, i'm using stored procedures like 'batch' programs which will be executed with oracle scheduler (passing to s.p. the name of the 'input' tables)
    These input tables are 'external' tables which have got the same structure; for example i've got TABLEX_001, TABLEX_002, XXTAB etc. with the same structure.
    This is the the reason... what do you think?An external table definition can reference multiple files via the LOCATION definition or you can user "ALTER TABLE" to alter the location and change the file that the external table points to.
    Thus you only need one static External Table and use an alter table (via execute immediate) to change the file location it points to, or if you want all the data together, just specify all the files in the location.
    That would be clean design, using one fixed table, without the need to pass any table names, just dynamically altering the file names if necessary at run time.

  • How to pass the parameter of a stored procedure to iReport

    Hi... i don't know how to pass the parameter of the stored procedure to the iReport.
    In the Report Query, i tried
    1. sp_storedprocedure ' value'
    2. sp_storedprocedure +''''+$P{parameter}+''''+
    3. sp_storedprocedure +$V+$P{parameter}++$F($F is a variable having a value of ' (a single quote))may you enlighten us please? thank you

    For M$ SQL server I find that it only works when U use the fully qualified name...
    e.g. catalod.dbo.my_procedure_name 'variable'
    My full query in the Report Query window is something like this:
    EXEC arc.dbo.jasper_Invoice 1000
    Note that you may find that selecting from VIEWS / TABLES fails for no apparent reason and iReport will prompt you with the usual very unhelpful (we have what we "pay" for) prompt, stating that "The document is empty".
    To work around this issue, where a statement like "SELECT * FROM arc.dbo.acc_invoices WHERE Invoice_id=1000" does not work, simply create a PROC, something like:
    CREATE PROC jasper_MyProc (@my_rec_id integer) AS
    SELECT * FROM arc.dbo.acc_invoices WHERE Invoice_id= @my_rec_id integer
    ...to wrap your SELECT statement, then call the PROC
    Edited by: Sylinsr on Apr 22, 2008 4:23 PM

  • In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String

    In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String , for executing the Stored Procedure with Current date as the input .

    Hi Srinath,
    The below blog might be useful
    http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/03/06/executing-stored-procedure-from-sender-adapter-in-sap-pi-71
    PI/XI: Sender JDBC adapter for Oracle stored procedures in 5 days
    regards,
    Harish

  • Passing Multi-Value Parameter to a Stored Procedure

    Has anyone experienced passing a Parameter (MultiValue) to a Stored Procedure? I am aware that Crystal Passes the Param as an Array. How would you go about handling this within a Stored Procedure???

    Hi Daniel
    Try as below:
    1. Create a Crystal report, and add a multi-value parameter.
    2. Since the multi-value parameter is treated as an array, create a formula that uses the JOIN function. Create a formula as below:
    //Formula: @JoinFormula
    Join ({?Multi-value parameter array},";")
    ====================
    NOTE:
    In the formula above, a semi-colon (";") is the delimiter.
    ====================
    3. Within the main report, create a subreport based on the stored procedure, and include the parameter to be populated with the multi-value list.
    4. Link the Join formula in the main report to the stored procedure parameter in the subreport.
    Doing so passes a multi-value parameter to the stored procedure.
    Hope this helps!!!!
    Regards
    Sourashree

  • Would like to pass multi-value parameter to a stored procedure

    Hi,
    Is it possible to pass a multi-value parameter to a stored procedure using crystal reports.
    Is there is a way to do so??/
    Thanks,
    Brian.

    Hi,
    Is it that you want to pass 2 or more parameters to a stored proc. it is possible
    go to database expert
    select your connection and click on add command their you will have to create parameters and pass to a proc
    for ref..
    {CALL `menagerie`.`sp_timer`({?delay time},{?delay time2})}
    where `menagerie`.`sp_timer` is a stored proc.
    and delay time and delay time2 are  parameters.
    but if it is like you have to pass multiple values to stored proc using single parameter as per my experience its
    not possible.

  • How to pass parameter from 1 stored procedure to another stored procedure inside crystal report

    Hi
    I have several stored procedure in my Crystal Report. I am wondering if it is possible for me to pass a parameter to one of the stored procedure and to use the result of that stored procedure E.g. CustomerCode. To another 2 stored procedure to generate the report dynamically?
    I have 3 stored procedure
    The 1st one is used to gather information and process the calculation
    another 2 stored procedure is used for generate the graph and both of them required to take 2 parameters. The 1st stored procedure will require 1 parameter (E.G. Reference Code) and will return a set of information including the data that could be use on the other 2 stored procedures.
    After I added these 2 stored procedure, it requires me to pass 3 parameters to the report. I would like to know if I could only pass the Reference Code for stored procedure 1 and use it to retrieve the information for the other 2 parameter?
    Thanks in advance
    Chi

    Hi Chi
    To pass parameter from 1 stored procedure to another stored procedure, you will have to create sub report. In your case you will have to create 2 sub reports for 2nd and 3rd stored procedure and link those sub reports with the main report using Reference Code field in order to pass the values.
    After creating the report when you will refresh the report, it will ask 4 parameters, one parameter for main report, one for the first subreport and two for second subreport to fetch the data correctly.
    Regards
    Poonam Thorat.

  • Problem in OUT Parameter in the stored procedure

    Hi,
    I have a problem in the OUT parameter of the stored procedure under the package. I encountered the error PLS-00306. Below are the codes.
    Package
    CREATE OR REPLACE package body test as
         procedure sp_countries(rst OUT country_typ) as
         sql_stmt VARCHAR2(300);
         begin
         sql_stmt := 'SELECT * FROM countries WHERE region_id = 1';
         OPEN rst FOR sql_stmt;     
         end;
    end test;
    by the way. i declared the country_typ as this:
    TYPE country_typ IS REF CURSOR;
    Here is the code that will call this package:
    declare
    tst countries%ROWTYPE;
    begin
    test.sp_countries(tst);
    dbms_output.put_line(tst.country_name);
    end;

    Works for me. Although I had to use emp instead of your table:
    SQL> create or replace
      2  package test as
      3     TYPE country_typ IS REF CURSOR;
      4     procedure sp_countries(rst OUT country_typ);
      5  end;
      6  /
    Package created.
    SQL> CREATE OR REPLACE
      2  package body test as
      3     procedure sp_countries(rst OUT country_typ) as
      4        sql_stmt VARCHAR2(300);
      5     begin
      6        sql_stmt := 'SELECT * FROM emp WHERE deptno = 20';
      7        OPEN rst FOR sql_stmt;
      8     end;
      9  end test;
    10  /
    Package body created.
    SQL> var tcur refcursor
    SQL> exec test.sp_countries(:tcur);
    PL/SQL procedure successfully completed.
    SQL> print tcur
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
    SQL>

  • MII BLS Trasaction calling SAP RFC call - How to pass XML document as input parameter

    Hi,
    1. I am very new to the SAP and SAP xMII workbench.
    I have a webpage with iGrid applet embedded on it. We have multiple rows in the iGrid applet that can be selected by user.
    After selecting single or multiple grid rows user clicking a 'button' on the web page.
    We are using iCommand applet (ExacuteQuery] to call the BLS transaction.
    Using iCommand applet on the webpage we are passing parameters to BLS Transaction.
    Would like to pass on the single/ multiple selected grid row values as a XML document to BLS Transaction variable which is an Input parameter for SAP RFC call.
    I am using SAP JCo Session to make the RFC call. 
    Any pointers will be helpful.
    2. Which is a best track in SAP training courses to get formal training.
    Thanks,
    Senthil

    Hi Senthil,
    What version of MII (or xMII) are you working with?  There are some examples of this type of transaction in the wiki which you may want to download and take a look at.
    Regards, Mike
    SAP Customer Experience Group - CEG

  • Is it possible to pass a null Input Oracle parameter to a stored procedure

    I have a stored procedure that take 3 inputs and gives 1 output.I'm using Oracle parameter to add all 3 input parameters as follows :
    OracleParameter inobj = cmd.Parameters.Add("wid", OracleDbType.Int32,50);
    inobj.Direction = ParameterDirection.Input;
    inobj.Value = _employeeID;
    and added the output parameter as follows:
    OracleParameter outobj = _cmd.Parameters.Add("w_first", OracleDbType.Varchar2, 50);
    outobj.Direction = ParameterDirection.Output;
    On the UI end , the user has a choice to provide 1 input or all inputs or any 2 inputs based on his interest. Stored Proc looks as follows:
    SP( inp1 in parameter, inp2 in parameter, inp3 in parameter, output1 out parameter)
    If i just get 1 input or 2 inputs from the user, is it fine to query the data for output using same stored procedure or should i have individual stored procedures for each scenario(combination of different inputs)?
    Will i get any pl/sql error that says invalid number of arguements?

    This means if i have 1 input , i need to have a different method to pass 1 parameter value and other input parameters as null and if there are 2 inputs will need different method to handle. So 5 different methods all together?
    What if the stored procedure is as follows ,will its make things easier so that only one method is used for all scenarios?(optional parameters is set default value as null in the stored proc)
    Create or Replace
    Procedure GetFoo
    (cur_z OUT sys_refcursor,
    pub_date IN varchar2,
    fname IN varchar2 default null,
    lname IN varchar2 default null,
    phone IN varchar2 default null
    IS
    BEGIN
    ---get some data
    END;
    *actually i can test this but, all the database servers are down today. So, i need to have idea if this thing works before i confirm with someone. Thanks.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Dynamically Pass a list as input parameter to a Graphical Clac View

    Hi All,
    Can anyone please let me know if it is possible to pass a list of comma separated values as an input parameter to a graphical calculation view and how this list can be parsed inside the view?
    The requirement is to invoke the graphical view using sql script.
    Thanks,
    Goutham

    Hi Goutham,
    Have a look on these documents:
    Using Multiple Values in Input parameter for filtering in Graphical Calculation View
    SAP HANA: Handling Dynamic Select Column List and Multiple values in input parameter
    Regards,
    Krishna Tangudu

Maybe you are looking for

  • End routine  not workind when DSO Activated

    I have code in End routine of the transformation to populate a date field (from sales header to  sales line item to have the assocaited date to populate for each line item ) to the DSO. The code works and displays data being populated in new data tab

  • Error message when i try to open programme

    when i try to open up a third party programme i get this message about my air installation "the installation of this programme is damaged. try to re-installing or contacting the publisher for assisstance" i have uninstalled and reinstalled so many ti

  • 24+ Hours  To export 1m 27s of video?

    Not entirely sure what is happening here. I am using the same settings as ever default Compressor settings HD 1080p Video Sharing. Seems as though since updating to Mountain Lion everything takes forever to export using Compressor itself or "Export U

  • Can analytical function support this requirement?

    As a result of some Qry, I get the following result set. Column1 Column2 A       100    A       200 A       200 A       100 B       200 B       200 B       200 C       100 C       200 D       200 D       200 E       200 With this as input i had to ta

  • Adding Sales Order Lines repeating for all orders

    I have a C# program whereby I am trying to get Sales Orders from one database (source) and create them in another database (destination). I asked a question on how to set the current line and was helped. The only problem now is that for all Business