Larry, that was an informative post - I'd forgotten about COUNT = INSERT.

In your point #2 though, wouldn't you run into the possibilty of editing someone else's insert using the same argument you made in #1?  I would think it's safer to use the intermediate variable.  Or, can you EDIT USING fwo_form WHERE COUNT = INSERT?

If so, then the question is:  How long is COUNT = INSERT valid?  Obviously till the next insert.  Will it survive a RETURN?  Will it carry to another piece of code?  Is it valid throughout an R:Base session for that user?  How 'bout till the next session of R:Base?  Do other SQL commands reset/null it?

Sorry, got a little carried away with the questions  :)

Regards,
Doug

Lawrence Lustig wrote:
-- Now I retrieve the auto-number PK fwo_no just generated by the INSERT
command
SET VAR vnew_fwono = fwo_no in fwo_file where count = LAST
EDIT USING fwo_form WHERE fwo_no = .vnew_fwono
    

Three notes to this:

1. Using WHERE COUNT = INSERT is more multi-user safe than COUNT = LAST since
another use may have added a record to the table after your INSERT and before
you edit the record.  COUNT = INSERT gets the last record _you_ added to the
table.

2. You can just do EDIT USING fwo_form WHERE COUNT = LAST instead of the
intermediate variable.

3. It's worthwhile to check the SQL code returned from the INSERT statement --
if the INSERT did not succeed for any reason the user will end up editing the
wrong record entirely and may not be aware of it.
--
Larry


  

Reply via email to