Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored Procedure that uses value which external sotware sends? how to?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
I have a Stored Procedure:

SELECT AlarmTypeText, ActionText, Handling
FROM AlarmTable
WHERE AlarmTypeID = <arg>;

<arg> is a value (an integer) that my external software should send to the Stored Proceudure when it's executed. If I try to CREATE this stored procedure I get an error as Query Analyzer doesn't understand the <arg>.

How do I define that in the Stored Procedure so it knows that the <arg> is a value that is passed in from my software?

I mean, before my software EXECUTE this stored procedure it should somehow replace <arg> with a value (an integer) that is sent from my software.

-Thanks, Nicholas Peterson
 
Try this my friend!


CREATE PROCEDURE MYPROCEDURE @Arg int
as
SELECT AlarmTypeText, ActionText, Handling
FROM AlarmTable
WHERE AlarmTypeID = @Arg
go

Where @arg is a integer parameter(I thinsk it's your case). To call the procedure write the followinf code in your application:

EXECUTE MYPROCEDURE 1 -- or in this way
EXECUTE MYPROCEDURE @arg=1

Where Number '1' is your parameter.

Here is a tip. If your procedure has more than one parameter you must use colon:

EXECUTE MYPROCEDURE 1,'Teste',5 -- or in this way
EXECUTE MYPROCEDURE @arg=1,@Name='Teste',@ID=5

I hope this help!

 
Thank you my dear friend!

I will try this and I hope it will work!

sincerely, Nicholas P.
 
Nicholas, you didn't mention what your external program is, but if you are going through ODBC, you can use the {CALL my_sp} ODBC instruction.
 
Yes, I am going through ODBC. My external program is like a shell or GUI that looks up and writes data from and to databases. All operations are handled through the software.

/Nicholas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top