Valentina SQL: INSERT and binding

Chris Sheffield cm_sheffield at yahoo.com
Tue Jan 13 12:04:33 CST 2004


Thanks, Ken.  That ought to do the trick.

Chris

--- Ken Ray <kray at sonsothunder.com> wrote:
> > 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/ 
> 
> 
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina


__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus


More information about the Valentina mailing list