Calling stored procedures with parameters with the Database Connectivi​ty Toolkit

Hi all,
I am new to the forum and am having difficulty finding a solution to a particular problem I am having regarding using the LabVIEW Database Connectivity Toolkit on a project I am currently working on at my job.  I have a database in which I have tables and stored procedures with parameters.  Some of these stored procedures have input, output, and return parameters.
I have been trying to follow this example but to no avail:  http://digital.ni.com/public.nsf/allkb/07FD1307460​83E0686257300006326C4?OpenDocument
One such stored procedure I am working on implementing is named "dbo.getAllowablePNs", which executes "SELECT * from DeviceType" (DeviceType is the table).  In this case, it does not require an input parameter, it has an output parameter that generates the table [cluster], and has a return parameter which returns an integer value (execution status code) to show if an error occurred.  The DeviceType table has 3 columns; ID (PK, int, not null), PN (nvarchar(15), null), and NumMACAddresses (int, null).  I have gone over many examples and have talking to NI support to try to implement this and similar stored procedures in LabVIEW but have not been successful.  I am able to connect to the database with the Open Connection VI without error, but am running into some confusion following this step.  I am then trying to use the Create Parameterized Query VI to call the stored procedure and set the parameters.  I assume I would then use the Set Parameter Value VI for each parameter that is wired into the parameters input on the previous Parameterized Query VI?  I am also having some confusion during and following these steps as well.  I would greatly appreciate any advice or suggestions anyone might have in regards to this situation as I am not a SQL expert.  Also, I would be happy to provide any more information that would be helpful.
Regards,
Jon
Solved!
Go to Solution.

Also, I don't know if this would be helpful but here is the actual stored procedure in SQL:
CREATEPROCEDURE [dbo].[getLastSequenceNumber]
@p1 nvarchar(10)='WO-00000'
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SETNOCOUNTON;
-- Insert statements for procedure here
selectmax(SequenceNumber)from Devices where WorkOrderNumber= @p1
END
GO

Similar Messages

  • SOAP TO JDBC scenario: calling stored procedure which will return the value

    Hi
    I have Soap To Jdbc scenario in which I am going to call the Stored Procedure at target side which will be executed and it is going to return the result set .
    Result contains following values.
    return code as ( 0 Or 1) and also specific exception message if its return code as 1.
    Could you suggest me the way by which I can handled this return code and send it back to the Sap PI system then the same thing is directed the to SMTP server for sending mail to consern person.
    Regards
    Kumar

    The OUT parameters of stored procedure will be returned as response. Where exactly are you facing the proble? Here is a complete walkthourgh
    /people/luis.melgar/blog/2008/05/13/synchronous-soap-to-jdbc--end-to-end-walkthrough
    In your case, you don't want response at sender. Instead you want to mail it. For this you may use BPM to design your scenario with following steps
    Receive (to receive data from sender)
    Send Sync (to stored procedure and get response)
    Send Async (to mail receiver)
    Regards,
    Prateek

  • Calling stored procedure multiple times in the JDBC receiver

    Hi,
    I am calling the stored procedure(SP) to update a DB table in the JDBC receiver.
    SP has 10 input parameters, and SP can receive one value for each parameter at a time.
    In my case, i will have multiple rows to insert using SP.i.e multiple values for each parameter.
    Its working correctly for a single value for each parameter, but when i have multiple values i want to call the SP multiples times.
    Is this possible and how?
    Thanks,
    Varghese.

    Varghese,
    I think you can have multiple statements in the JDBC Adapter's XML, as in http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm.
    Here the StatementName1 node can be inserted into your JDBC XML as often as you want.
    Kind regards,
    Koen

  • MaxDB 7.6 carshes on calling stored procedure with driver 7.6

    Hi All,
    Recently I upgraded MaxDB from v7.5 to v7.6 after several hiccups I am almost done but one strange problem remains. I have a stored procedure which is used for generating Bill Of Material (recursive cursor). The said stored procedure uses some views (if that matters at all). If I call that stored procedure using JDBC driver v7.5 then all works well and if JDBC driver v7.6 is used to call the stored procedure it simply crashes the database. Does not it sound strange
    Does anyone have any clues?
    Thanks,
    Vinod

    Hi Marco,
    Here is the stored procedure, which causes database crash-
    START -
    [code]CREATE DBPROC shortlist_all_month (IN schedule VARCHAR(14)) RETURNS CURSOR AS
        $CURSOR = 'bom';
        BEGIN
        CREATE TABLE temp.bom_view
          (bom_version, main_item_code, sub_item_code, sub_item_qty, bom_item_remarks) AS
          SELECT bom_version, main_item_code, sub_item_code, sub_item_qty, bom_item_remarks
          FROM suman.mfg_bom_m
          WHERE bom_version = (SELECT MAX(bom_version) FROM suman.mfg_bom_m M
                        WHERE M.main_item_code = mfg_bom_m.main_item_code);
        DECLARE :$CURSOR CURSOR FOR
        WITH RECURSIVE PX (main, sub, qty, super_main) AS
           (SELECT main_item_code, sub_item_code, sub_item_qty, main_item_code
             FROM temp.bom_view WHERE main_item_code IN (
                SELECT schedule_plan_item FROM suman.ppc_schedule_m WHERE schedule_code = :schedule)
            UNION ALL
            SELECT main_item_code, sub_item_code, sub_item_qty, super_main
             FROM temp.bom_view B, suman.PX
             WHERE sub = B.main_item_code)
        SELECT sub AS sub_item_code, item_item_desc, item_mfg_flag, stock_item_qty,
         SUM(qty * schedule_plan_qty) AS req_qty, (stock_item_qty - SUM(qty * schedule_plan_qty)) AS short_qty
         FROM suman.PX B, suman.ppc_schedule_m S, suman.mfg_item_p I, suman.mfg_item_stock V
         WHERE B.super_main = S.schedule_plan_item
         AND schedule_code = :schedule
         AND B.sub = I.item_item_code
         AND B.sub = V.stock_item_code
         AND V.stock_dept_code = 'DP0008'
         GROUP BY sub, item_item_desc, item_mfg_flag, stock_item_qty
         HAVING SUM(qty * schedule_plan_qty) > 0 ORDER BY 3, 1;
        DROP TABLE TEMP.BOM_VIEW;
    END;[/code]----
    END -
    This used to work fine for last >4 years. See if you can find something fishy. I will try to give a runnable test case to reproduce the crash.
    Thanks,
    Vinod

  • Calling stored procedures in Sybase from java

    Hi,
    I am using the following stored procedure in Sybase
    use xyzdb
    go
    -- drop procedure if it already exist
    if object_id('up_name_select') is not null
    begin
    drop procedure up_name_select
    end
    go
    create procedure up_name_select
    @zid          numeric(7,0),
    @firstname     char(40),
    @lastname     char(40)
    as
    select zid,
    firstname,
    lastname
    from name
    where zid = @zid or
    (lastname like @lastname or firstname like @firstname)
    go
    -- update documentation records in object_docs
    delete object_docs
    from object_docs
    where object_name = "up_name_select"
    go
    insert into object_docs values("up_name_select","Selects records from the name table based upon the values of the input parameters.")
    go
    -- update documentation records in column_docs
    delete column_docs
    from column_docs
    where object_name = "up_name_select"
    go
    insert into column_docs values("up_name_select","@zid","System generated ID for an individual contact.")
    insert into column_docs values("up_name_select","@firstname","First name of the contact. SQL wild card characters are accepted.")
    insert into column_docs values("up_name_select","@lastname","Last name of the contact. SQL wild card characters are accepted.")
    go
    -- print success message and grant permissions
    if object_id('up_name_select') is not null
    begin
    print "Procedure up_name_select created."
    grant execute on up_name_select to developer_role
    end
    go
    This stored procedure selects the values from the table "name" for a given where condition (if I am not wrong).
    Can any one give me sample java code to select the records from the table "name" for a given zid.
    Thankyou in advance.
    Regards
    sgatl2

    calling stored procedures from java
    here is the sample code
    CallableStatement cs = con.prepareCall("{call selectlogin (?)}");
    cs.setString (1, "value");         
    ResultSet rs = cs.executeQuery ();
                while (rs.next ())
                //your code for display
                } more on gooooooogle
    http://www.google.com/search?q=calling+stored+procedures+from+java+with+sample+example&client=netscape-pp&rls=com.netscape:en-US

  • 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 Parameters in PowerPivot DataModel

    Hi All,
    I wanted to call a SQL stored procedure from PowerPivot(Excel) on based on changing slicer's value. 
    Currently, we can call stored procedure wihtout any parameter from Data Model tab using 
    Exec stored_proc_name in Table Properties window.
    What if I want to call the same procedure with a parameter whouse value will come by changing slicer's value. I  meant, changing slicer value will act as a parameter to that stored procedure & it should return updated results. 
    Is this possible in PowerPivot?

    Hi Rameshwar,
    According to your description, you call a SQL Server stored procedure in PowerPivot data model, now the problem is that you need to pass a parameter to the stored procedure, right?
    Based on my research, it seems that we cannot achieve this requirement directly in current version of PowerPivot data model. Here is a similar thread for you reference.
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/5350228d-bc62-4a3b-a1a6-e847483e2858/powerpivot-for-excel-2013-call-execute-stored-procedure-with-parameters?forum=sqlkjpowerpivotforexcel
    If you have any concern about this behavior, you can submit a feedback at
    http://connect.microsoft.com/SQLServer/Feedback and hope it is resolved in the next release of service pack or product. Your feedback enables Microsoft to make software and services the best that they can be, Microsoft might consider to add this feature
    in the following release after official confirmation.
    Regards,
    Charlie Liao
    TechNet Community Support

  • Calling stored procedures with output parameters using RDO and VB

    I have a simple test procedure defined as follows:
    CREATE OR REPLACE PROCEDURE test_sp (inval1 IN VARCHAR2,
    inval2 IN NUMBER, inval3 OUT VARCHAR2, inval4 OUT NUMBER) IS
    BEGIN
    inval3 := 'RETURN TEST';
    inval4 := 10;
    END;
    I am attempting to call this procedure from VB 5.0 using RDO and the Oracle ODBC Driver 8.01.06:
    dim rdoQd as rdoQuery
    dim grdoCn as rdoConnection
    strSQL = "{ call test_sp('SOMETHING',?,?,?) }"
    Set rdoQd = grdoCn.CreateQuery("", strSQL)
    rdoQd(0).Direction = rdParamInput
    ' get error# 40041 at above line
    ' "Object Collection: Couldn't ' find item indicated by text."
    rdoQd(0).Type = rdTypeINTEGER
    rdoQd(0).Value = 5
    rdoQd(1).Direction = rdParamOutput
    rdoQd(1).Type = rdTypeVARCHAR
    rdoQd(2).Direction = rdParamOutput
    rdoQd(2).Type = rdTypeINTEGER
    Set rdoApp = rdoQd.OpenResultset()
    MsgBox (CStr(rdoQd(1)))
    MsgBox (CStr(rdoQd(2)))
    When I run this VB code, I get the above mentioned error. If I use placeholders for all parameters (like "{ call test_sp (?,?,?,?) }" ), no error occurs.
    I really need to use the first type of syntax from above and not have to use placeholders for all parameters. Is there a way to accomplish this?
    TIA,
    Esther

    Are you getting any warning while importing the stored procedure?
    Please check the below datatypes:
    While creating the stored procedure, if you have used varchar(MAX), please ALTER it to varchar(255) and reimport to DS.
    Also, the datatype of $message (global variable or local variable) used inside DS should also be varchar(255)
    Try a print statement in between.
    ADMIN.DBO.SPJOBSUMMARY(69,$message,$rtCode,$rtVal);
    print('Message is '||$message);
    smtp_to('leighattest.com.au', 'Results of ' || job_name(), $rtCode || '//' || $rtVal || '~~' || $message || '//', 0,0);
    and see in the job log if DS is able to retrieve the output from DB.
    Regards,
    Suneer

  • 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

  • Call stored procedure with OUT parameter

    Hello,
    I have created a short-lived process. Within this process I am using the "FOUNDATION > JDBC > Call Stored Procedure" operation to call an Oracle procedure. This procedure has 3 parameters, 2 IN and 1 OUT parameter.
    The procedure is being executed correctly. Both IN parameters receive the correct values but I am unable to get the OUT parameter's value in my process.
    Rewriting the procedure as a function gives me an ORA-01460 since one of the parameters contains XML (>32K) so this is not option...
    Has someone been able to call a stored procedure with an OUT parameter?
    Regards,
    Nico

    Object is Foundation, Execute Script
    This is for a query, you can change to a stored procedure call. Pull the value back in the Java code then put into the process variable.
    import javax.naming.InitialContext;
    import javax.sql.DataSource;
    import java.sql.*;
    PreparedStatement stmt = null;
    Connection conn = null;
    ResultSet rs = null;
    try {
    InitialContext ctx = new InitialContext();
    DataSource ds = (DataSource) ctx.lookup("java:IDP_DS");
    conn = ds.getConnection();
    stmt = conn.prepareStatement("select FUBAR from TB_PT_FUBAR where PROCESS_INSTANCE_ID=?");
    stmt.setLong(1, patExecContext.getProcessDataLongValue("/process_data/@inputID"));
    rs = stmt.executeQuery();
    rs.next();
    patExecContext.setProcessDataStringValue("/process_data/outData", rs.getString(1));
    } finally {
    try {
    rs.close();
    } catch (Exception rse) {}
    try {
    stmt.close();
    } catch (Exception sse) {}
    try {
    conn.close();
    } catch (Exception cse) {}

  • DB Adapter - Calling Stored Procedure with Object Type

    So, we are using JDeveloper 10.1.3.3
    We are trying to create an ESB process that invokes a SP with an object type. However, the owner of the package / SP, is NOT the owner of the object type. When going through the DB Adapter wizard, it gives us the following error:
    When attempting to use the DB Adapter in JDeveloper to create a partner link to execute a stored procedure. JDeveloper returns the following error:
    Unable to import WSDL.
    Error while writing wsdl file
    Database type is either not supported or is not implemented.
    Check to ensure that the type of the parameter is one of the supported datatypes or that there is a collection or user defined type definition representing this type defined in the database.
    However, if I create a wrapper package / SP, it works just fine. I'd really like to not be having to create wrapper code for these SPs to work. Is this resolved in 11g? Is there a patch available for 10.1.3.3?
    I think this is a JDeveloper Wizard issue, but thought I'd post this here as well.
    Thanks,
    BradW

    This problem can be resolved by granting execute permission on the object type to the caller. For example, if the stored procedure is in schema1 and the object type is in schema2 then you would connect as schema2 and execute
    SQL> grant execute on <object type> to schema1
    Referencing object types defined in other schemas is documented. This is the described method for accessing object types in other schemas.

  • JDBC-Adapter-Receiver Calling Stored Procedure with Input-Typ Record

    Hallo,
    I´ m trying calling a stored-procedure with two input-parameter; one of typ record (oracle) and one of type tabel of records. Is this possible (I think there are only types like string, integer etc. possible)? When not is there another possibility to work with that type?
    Thanks in advance,
    Frank

    Hi Frank,
    I think stored procedures will not take Array of Records as a Input. If you want to make a loop funtionality etc then JDBC adapter will work accordingly. You need to just call the stored procedure from the JDBC adapter. It will work for the array of records(multiple occurences).
    Receiver JDBC Procedures.
    /people/siva.maranani/blog/2005/05/21/jdbc-stored-procedures
    Alternative option is you can make use of Java Proxy and from there you can call stored procedure ..I think it is possible.. not tried.
    Hope this helps
    Regards,
    Moorthy

  • Calling Stored Procedure with CLOB parameter

    Hi,
    i have one procedure with IN parameter CLOB which is taking xml file and stored in one table column and this table column datatype is also CLOB. And this procedure called by .Net program but problem is when the file will come more than 32KB calling procedure failed. But as i know CLOB can stored up to 4GB data.
    Is that Limitation of oracle or .Net version
    please let me know the solution for that,
    Create Procedure Insert_File(P_XMLFILE IN CLOB)
    as
    begin
    insert into instances
    values(p_xmlfile);
    commit;
    end;
    regards,
    Madan

    Hi Thanks for your reply,
    Actually this procedure called by .net program and the XML file has passed in that parameter which come from some FTP(its inbound) and this files we are storing into above mentioned table.
    Error has come while calling stored procedure Through .net
    Error Details:
    Error calling stored procedure. 0 retry attemps has failed. Error: System.Exception: Error while calling stored procedure on Oracle: INSERT_FILE: System.Data.OracleClient.OracleException: ORA-01460: unimplemented or unreasonable conversion requested

  • Calling Stored Procedure with OraClob as parameter IN

    I am using Visual C++ and using oo4o the ole way
    I am try to call stored procedure that have Clob as parameter in
    it seems the the OraParameters Add method don't have the ability since it can only receive variantt.
    How do I do it
    Thanks
    Yoav

    fyi
    Related to the solution/workaround posted by Luc.
    see "Do Oracle's JDBC drivers support PL/SQL tables/result sets/records/booleans? "
    at http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-faq-090281.html#34_05
    regards
    Jan Vervecken

  • Problems calling stored procedure with DG4IFMX

    Hi guys,
    I am trying to call stored procedures from Informix Database which is connected through Oracle Database Gateway for Informix.
    I have run select,update,delete successfully but when i try to run a stored procedure nothing happens.
    for example :
    when i run
    call "branko"@link_informix(1)
    it returns that it is successfully executed, without any error, but as u can see bellow no entry is entered in the branko_test table
    at informix :
    drop procedure branko;
    create procedure "informix".branko(_vlez integer)
    returning boolean;
    if _vlez = 1 then
    insert into branko_test values('test uspesen','1');
    else
    insert into branko_test values('test uspesen 2','2');
    end if;
    end procedure;
    the procedure runs ok when called from informix.
    Thank you for any help
    P.S i have even tried running:
    declare
    ret integer;
    begin
    ret := DBMS_HS_PASSTHROUGH.EXECUTE_IMMEDIATE@link_informix('execute procedure branko(2)');
    end;
    but the same thing is happening, no entry in the table branko_test.

    Found the root cause:
    when using dbaccess to call the original procedure it reports on the screen (expression)
    => removing the return value as it is not handled
    -> looks like the unhandled return value boolean. Modifying the procedure to
    drop procedure branko;
    create procedure "informix".branko(_vlez integer)
    if _vlez = 1 then
    insert into branko_test values('test uspesen','1');
    else
    insert into branko_test values('test uspesen 2','2');
    end if;
    end procedure;
    allows me to execute the procedure using passthrough
    DECLARE
    result VARCHAR2(50);
    BEGIN
    result := DBMS_HS_PASSTHROUGH.EXECUTE_IMMEDIATE@dg4ifmx('execute procedure informix.branko(1)');
    END;
    Edited by: kgronau on May 6, 2011 7:31 AM

Maybe you are looking for

  • Synchronizing color settings in Adobe Bridge

    I want to synchronize color settings in Adobe Bridge and I've currently installed photoshop extended CS5 and InDesing CS5.5 (these programs are not installed from any Adobe Creative Suite package. I mean these are not from: Adobe Creative Suite 5.5 D

  • How to change location in iMessage?

    How To change locations in iMessage?

  • Weird Pacman behavior [Solved]

    The weirdest thing is happening.  I reformatted and installed Duke.  When I run pacman -Syu, everything goes really slow.  Not the download speed, that is fast, but it pauses for about 30 seconds after every event.  So it will download an update, the

  • Automatic Billing For third party

    Hiya Can we have a automatic trigger for trade invoice? Once the vendor invoice is received and trade invoice should be triggered/created. However I would also like to check that trade invoice only be created for received quantity. Bit specific... an

  • Budget Initialization - checking "relavant to budget" at one go

    Dear All, Could neone tell me how to set all the G/L Accounts as relavant to budgets at one GO, i think when we initialize the budget it happens.. please respond immediately