LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Call a SQL stored procedure using input and output parameters

There must be an easy way to call a stored procedure using input and output variables, but I am having no luck.

For debug, I wrote a simple stored procedure (MS SQL Server), which as follows:
------
CREATE PROCEDURE sp_test_procedure
(
@ser_num varchar(50),
@new_ser_num varchar(50) OUTPUT
)

AS

SET @new_ser_num = @ser_num + ' <<<--- This Is Your Serial Number'

RETURN
GO
----

I am using LabVIEW 6.02, and the database connectivity toolset (ADO.

All the items found on NI's site seem to relate to a) the older SQL toolkit, or b) a stored procedure that returns a recordset.
0 Kudos
Message 1 of 3
(3,273 Views)
I found an answer from someone on info-labview, which is as follows:
(in the stored procedure)
Before the RETURN Function, write: SELECT @parameterName (in your case:
Select @new_ser_num )

So the new stored procedure would be:
------
CREATE PROCEDURE sp_test_procedure
(
@ser_num varchar(50),
@new_ser_num varchar(50) OUTPUT
)

AS

SET @new_ser_num = @ser_num + ' <<<--- This Is Your Serial
Number'
Select @new_ser_num
RETURN
GO
-----
0 Kudos
Message 2 of 3
(3,273 Views)
just a way to save a few lines of code

CREATE PROCEDURE sp_test_procedure
@ser_num VARCHAR(50)
AS
SELECT @ser_num + ' <<<--- This Is Your Serial Number'
AS Variable_name
GO

the Variable_name acts like a colum name
(and should be without an '@')
0 Kudos
Message 3 of 3
(3,273 Views)