You answered your own question in your last paragraph - you _can_ put
constants and expressions in your select statement.

Try something like this:

INSERT into tbl (MyUUID, name, VersionID)
SELECT '#CreateUUID()#', name, VersionID + 1
FROM tbl
WHERE MYUUID = '#form.MyUUID#'

Bob

-----Original Message-----
From: andrew kopelman [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 08, 2001 11:00 PM
To: CF-Talk
Subject: Problem with Insert Using Select


I want to insert new records into a table which has MyUUID as its primary
key as well as a column, VersionId, which needs to be updated.  Each new
record should be identical to the old record, except for a new MyUUID and an
incremented VersionID.  For example, this old record:

MyUUID:  BT784-PI89
MyName: Smith
VersionID: 1

should have its corresponding new record:
MyUUID:  A622T-U8FF
MyName: Smith
VersionID: 2

I can't use the query syntax:
INSERT into tbl (MyUUID, name, VersionID)
SELECT MyUUID, name, VersionID
FROM tbl
WHERE MYUUID = '#form.MyUUID#'

because that would be overwriting (making non-unique) the UUID, not to
mention the version number.

Is there a way to do the insert with the Select as well as a dynamically
generated uuid?  In other words, to simultaneously use the select for given
columns (MyName) and passed-in values for other columns(MyUUID, VersionID).

I need this to work with CF4.5; any ideas?

Thanks ahead of time,
Andrew Kopelman
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to