stored-procedures

MS SQL: Use a stored procedures result set in another query?

I have a stored procedure I don't want to modify. It's rather large and complex, and I don't want to add any more confusion to it. So what I would like to do is have another store procedure that calls on the big one, and uses the result set to perform further selects / joins etc. ...

MySql calling stored function from within a stored procedure causing error

I'm getting a 1064 error when trying to call a stored function from within a stored procedure. It only happens on the line where I try to do this: SET account_id = get_account_id(user);. What is the problem and how can I fix it? Account ID Stored Functions: CREATE DEFINER=`aaron`@`%` FUNCTION `get_account_id`(user VARCHAR(255)) RETUR...

Mysql Recursive Stored Procedure...Limit 0 reached...can't change the max_sp_recursion_depth variable

UPDATE: Ok, I was able to debug this and found that the by doing this select @@max_sp_recursion_depth I can see that the variable is set at 15, however, when I run the call back to itself with CALL single_limb_portfolio_list(xaccount_id, xparent_portfolio_id); I get the error stating the Recursive Limit 0 was reached, but it never iterat...

Mysql Stored procedures

How stored procedures are fast in Mysql . Where it is suitable to use stored procedures (insert,update,select) How can we make stored procedure of a complex query returning 100000 rows and how can we get these records on php form. any example of such stored procedure using select query returning multiple rows ? ...

When and how SQL Server disposes variables from memory in stored procedures?

When we create a stored procedure propably we create some variable like this : DECLARE @UserCount INT We use that variable in stored procedure. But we don't dispose that variable at the end of stored procedure. We dispose Cursors with DEALLOCATE but we don't write ant lines for variables which we create. Another stuation is we creat...

Is it possible to use two SCOPE_IDENTITY calls in the same procedure?

The way I want my stored procedure to work is this, the user passes all of the customer data, name, phone, and all of address info into the procedure, then I want to perform an insert into the address table, get the id generated from that insert, use that id in another insert for the customer table then return the customer id to the user...

Detect that an UPDATE has failed in PostgreSQL SQL-procedure (not PlPgSQL)

Hello, to mimic the MySQL-REPLACE statement (aka UPSERT) I need to try to UPDATE a record and if that fails - INSERT it. But how can I detect that the UPDATE has failed in my SQL procedure? begin transaction; create table pref_users ( id varchar(32) primary key, first_name varchar(32), last_name ...

SQL procedure where clause to list records

I have a stored procedure that will query and return records based on if items are available or not. That part is easy, Im simply passing in a variable to check where available is yes or no. But what I want to know is how do I throw a everything clause in there (i.e available, not available, or everything)? The where clause right now i...