Valentina SQL: INSERT and binding

Ken Ray kray at sonsothunder.com
Tue Jan 13 13:17:54 CST 2004


> In the ValentinaSQL doc it mentions using the INSERT
> (and other) statements with binding.  I would like to
> do this, but am not quite sure how it works.  I'm
> using the VXCMD with Revolution, but I'm accessing
> it's functions directly, not using Revolution's DB
> functions.
> 
> For example, if I want to add a new record to my
> database, how exactly would I build the query string? 

If you don't need to use binding, you can do this:

-- Assumes a "People" table with three fields: FirstName, LastName and
Phone
-- and the database reference stored in the global gMainDBRef

---- Step 1: Create an empty cursor
put Valentina("SQLSelect",gMainDBRef,"SELECT * FROM People WHERE
RecID=0") into tCurs

---- Step 2: Create the record as a tab-delimited string
put "Ken" & tab & "Ray" & tab & "555-1212" into tRec
get Valentina("Cursor_AddRecord",tCurs,tRec)

---- Step 3: Remove the cursor
get Valentina("Cursor_Remove",tCurs)

If you need to get the ID of the record you just created, it would look
like this:

put Valentina("SQLSelect",gMainDBRef,"SELECT RecID,* FROM People WHERE
RecID=0") into tCurs
put "" & tab & "Ken" & tab & "Ray" & tab & "555-1212" into tRec
get Valentina("Cursor_AddRecord",tCurs,tRec)
put Valentina("Cursor_GetField",tCurs,"RecID") into tRecID
get Valentina("Cursor_Remove",tCurs)

Basically, you get a cursor that contains the RecID field in it, pass it
as an empty column in the record you want to add, and then Valentina
fills in that column of the cursor when it adds the record. You can then
retrieve it with Cursor_GetField before you dispose of the cursor.

I haven't done much with binding, though...

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/ 




More information about the Valentina mailing list