By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,586 Members | 2,487 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,586 IT Pros & Developers. It's quick & easy.

The Declare cursor SQL construct or statement is not supported.

P: n/a
Hi,

I try to construct a SQL code for a view to select a specific data
from a table, this query take the value of the filter from a text box
in a visual basic 6.0 form. my problem is when i DECLARE the variable
@AMP receive a error message that said "The Declare cursor SQL
construct or statement is not supported." What i do wrong? Please help
me. i attach the code.

DECLARE @AMP int;
SELECT Size, Type, Ampacity, Isulation, Temperature, Material
FROM dbo.Conductors
WHERE (Isulation LIKE 'THHN') AND (Material LIKE 'COPPER') AND
(Ampacity = @AMP)


Thanks!!!

Mar 24 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
ju**********@gmail.com wrote:
Hi,

I try to construct a SQL code for a view to select a specific data
from a table, this query take the value of the filter from a text box
in a visual basic 6.0 form. my problem is when i DECLARE the variable
@AMP receive a error message that said "The Declare cursor SQL
construct or statement is not supported." What i do wrong? Please help
me. i attach the code.

DECLARE @AMP int;
SELECT Size, Type, Ampacity, Isulation, Temperature, Material
FROM dbo.Conductors
WHERE (Isulation LIKE 'THHN') AND (Material LIKE 'COPPER') AND
(Ampacity = @AMP)
Not sure what you mean by view, is it view as in "create view ..."? If
it is I would advise against creating ddl objects on the fly. If this is
just a query, I would suggest that you use a prepared statement. I dont
see why you would have to declare anything for this particilar query.
Using a pseudo syntax:

ps = new prepared_statement(
"SELECT Size, Type, Ampacity, Isulation, Temperature, Material
FROM dbo.Conductors
WHERE Isulation = ?
AND Material = ?
AND Ampacity = ?")

ps.setparameter (1, 'THHN')
ps.setparameter (2, 'COPPER')
....
ps.executequery()

I dont know VB but I assume it has something atleast similar to a
prepared stmt
HTH
/Lennart
Mar 24 '07 #2

P: n/a
ju**********@gmail.com wrote:
Hi,

I try to construct a SQL code for a view to select a specific data
from a table, this query take the value of the filter from a text box
in a visual basic 6.0 form. my problem is when i DECLARE the variable
@AMP receive a error message that said "The Declare cursor SQL
construct or statement is not supported." What i do wrong? Please help
me. i attach the code.

DECLARE @AMP int;
SELECT Size, Type, Ampacity, Isulation, Temperature, Material
FROM dbo.Conductors
WHERE (Isulation LIKE 'THHN') AND (Material LIKE 'COPPER') AND
(Ampacity = @AMP)
Have a look at the DECLARE CURSOR syntax: http://tinyurl.com/2mnmgf

It would be something like:

DECLARE @AMP INT;

DECLARE cursName CURSOR FOR SELECT ... FROM ... WHERE ...;

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Mar 25 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.