|
-
Nov 9th, 2000, 07:56 AM
#1
Thread Starter
Lively Member
Has anyone got an example of using PREPARED SQL in conjunction with cursors? I've used them before with Informix but I don't know what the syntax is for SQL Server - I've found loads of references on Microsite site but no actual examples.
I do not know the syntax for PREPAREing SQL, and neither do I know the syntax for FETCHing a row while passing in the parameter.
I want to prepare a cursor where the join is based on values determined at run time. Something like....
Code:
PREPARE sSQL as
SELECT title, cat_no FROM titles t, order o
WHERE o.order_no = ?
DECLARE cur1 CURSOR FOR sSQL
...
FETCH cur1 USING @sOrdNo
INTO @sTitle, @sCatNo
Thanking you in advance....
Anakim
It's a small world but I wouldn't like to paint it.
-
Nov 9th, 2000, 08:06 AM
#2
Thread Starter
Lively Member
-
Nov 9th, 2000, 08:54 AM
#3
Fanatic Member
Well tell us then
I know how to do it, but not everyone might...
Paul.
Not nearly so tired now...
Haven't been around much so be gentle...
-
Nov 9th, 2000, 10:06 AM
#4
Thread Starter
Lively Member
-
Nov 9th, 2000, 10:50 AM
#5
Fanatic Member
Ok then
I do it from the client side - something like
Code:
cmd.CommandText = "SELECT Titles FROM Books WHERE title_id=?"
cmd.CommandType = adCmdText
cmd.Prepared = True
set prm = cmd.CreateParameter("title_id", adChar, adParamInput, 6, "AB1234")
cmd.Parameters.Append prm
cmd.Execute
cmd("title_id") = "BC4567"
cmd.Execute
etc.
cmd is a Command object and prm is a Parameter object
Well?
Cheers,
Paul.
Not nearly so tired now...
Haven't been around much so be gentle...
-
Nov 9th, 2000, 11:13 AM
#6
Thread Starter
Lively Member
-
Nov 10th, 2000, 09:30 AM
#7
Fanatic Member
Well, I could have worked it out - it was implicit in your post, but that was much too hard!
Cheers,
Paul.
Not nearly so tired now...
Haven't been around much so be gentle...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|