One way that seems to work - but I have not tested enough yet - is to put my sql statement that might operate on an empty result set (or produce one) in a BEGIN - END block with a new condition handler... but this still seems a bit less efficient. For example - this is the beginning of my...
I am developing stored procedures in SQL. Cursor operation NOT FOUND conditions are being handled with a CONTINUE HANDLER. The problem I have is that I have SQL Statements that are also potentially raising SQLSTATE 02000 - ones that might try an assignment to a variable with a SET or a SELECT...
Sorry for the delay... While my recordset comment is valid, it might not be in your example cuz you wanted the count by class... So, you have to retrieve multple recordsets. Be happy that you don't have to do this in Oracle. Anyway, take a look at the section titled "Generating Multiple...
Sure... You can throw that delete statement in a variable and then execute the variable...
Create Proc TST AS
declare @cmd varchar(2000)
alter table foo add ident INT identity
set @cmd = 'delete from foo where ident > (select min(ident) from foo foo2 where foo.number = foo2.number and foo.type...
If you don't care about recordsets and just want to use output parameters - which is the way I would do it for scalar values - then just declare two output parms and then use SET or SELECT to assing the scalar values to @variables... if you want more spefics let me know.
The advantage of this...
if you execute select @@version from one of the sql tools - or from any odbc type tool - it will tell you the version and type. For example:
Microsoft SQL Server 2000 - 8.00.194 (Intel X86) Aug 6 2000 00:57:48
Copyright (c) 1988-2000 Microsoft Corporation
Desktop Engine on Windows NT...
If you are not too space limited and the table is not too large, you could create an identity field and then use it in a correlated subquery:
alter table foo add ident INT identity
delete from foo where ident > (select min(ident) from foo foo2 where foo.number = foo2.number and foo.type =...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.