Saturday, February 25, 2012

Call a Stored Procedure within an SQL statement

Hi All,
I created a stored procedure which updates a specific row whose row ID is passed.
But what I want to do now, (which is a one time requirement) is to update all rows
is it possible to call this stored procedure within an sql statement and pass each row ID to it?

(would i have to go to cursor approach -- damn will have to learn that )
thanks

Quote:

Originally Posted by Shashi Sadasivan

Hi All,
I created a stored procedure which updates a specific row whose row ID is passed.
But what I want to do now, (which is a one time requirement) is to update all rows
is it possible to call this stored procedure within an sql statement and pass each row ID to it?

(would i have to go to cursor approach -- damn will have to learn that )
thanks


You can call a function from a SQL statement and not a STORED PROCEDURE.

Restrictions on calling a Function from a SQL statement:

1. Function should not have RETURN TYPE as BOOLEAN
2. Function should not perform any side effects. (ie No DML operations)|||

Quote:

Originally Posted by Shashi Sadasivan

Hi All,
I created a stored procedure which updates a specific row whose row ID is passed.
But what I want to do now, (which is a one time requirement) is to update all rows
is it possible to call this stored procedure within an sql statement and pass each row ID to it?

(would i have to go to cursor approach -- damn will have to learn that )
thanks


if it's a one time thing, can you just write a query in query analyzer to update the field you need? what field are you updating? what kind of update?

No comments:

Post a Comment