RE: EASY: grabbing the id of a newly created item..

2005-02-01 Thread Calvin Ward
een the two requests waiting... - Calvin -Original Message- From: Ewok [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 01, 2005 11:04 AM To: CF-Talk Subject: RE: EASY: grabbing the id of a newly created item.. > It absolutely isn't your only option. And if you do the below you need

Re: EASY: grabbing the id of a newly created item..

2005-02-01 Thread Jochem van Dieten
Robertson-Ravo, Neil (RX) wrote: > We tend to avoid them since we use SP's for all our SQL anyway. We find it > easier to manage. Personally I don't like triggers - I think they are evil. Triggers that don't change data but just throw errors when the data is invalid are great. Triggers that chan

Re: EASY: grabbing the id of a newly created item..

2005-02-01 Thread Jeff Garza
Agreed!!! ;-) Jeff - Original Message - From: "Robertson-Ravo, Neil (RX)" <[EMAIL PROTECTED]> To: "CF-Talk" Sent: Tuesday, February 01, 2005 9:12 AM Subject: RE: EASY: grabbing the id of a newly created item.. > We tend to avoid them since we use SP'

RE: EASY: grabbing the id of a newly created item..

2005-02-01 Thread Dave Watts
> We tend to avoid them since we use SP's for all our SQL > anyway. We find it easier to manage. Personally I don't like > triggers - I think they are evil. If you can constrain database access to only allow SPs, that's fine. If you can't, triggers are extremely useful. For web applications, wh

RE: EASY: grabbing the id of a newly created item..

2005-02-01 Thread Robertson-Ravo, Neil (RX)
rom: "Robertson-Ravo, Neil (RX)" <[EMAIL PROTECTED]> To: "CF-Talk" Sent: Tuesday, February 01, 2005 8:50 AM Subject: RE: EASY: grabbing the id of a newly created item.. > Best to avoid triggers full stop. > > -Original Message- > From: Jeff Garza [ma

RE: EASY: grabbing the id of a newly created item..

2005-02-01 Thread COLLIE David
> What's "right" for one application is quite possibly overkill > for another. Did I mention it was access? > > **ducks** > Yeah the database is Access at the moment. And the application at the moment is using access... But it might get upgraded... The same priniciple might be used in another

Re: EASY: grabbing the id of a newly created item..

2005-02-01 Thread Jeff Garza
t; <[EMAIL PROTECTED]> To: "CF-Talk" Sent: Tuesday, February 01, 2005 8:50 AM Subject: RE: EASY: grabbing the id of a newly created item.. > Best to avoid triggers full stop. > > -Original Message- > From: Jeff Garza [mailto:[EMAIL PROTECTED] > Sent: 01 Fe

RE: EASY: grabbing the id of a newly created item..

2005-02-01 Thread Robertson-Ravo, Neil (RX)
Best to avoid triggers full stop. -Original Message- From: Jeff Garza [mailto:[EMAIL PROTECTED] Sent: 01 February 2005 15:41 To: CF-Talk Subject: Re: EASY: grabbing the id of a newly created item.. If you are using SQL Server 2000, I would recommend moving away from using @@IDENTITY as

RE: EASY: grabbing the id of a newly created item..

2005-02-01 Thread Ewok
ll always be the correct ID. - Calvin -Original Message- From: Ewok [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 01, 2005 10:01 AM To: CF-Talk Subject: RE: EASY: grabbing the id of a newly created item.. Wow, too much for so little, Just use Richard's method RUN YOUR INSERT QUERY Th

RE: EASY: grabbing the id of a newly created item..

2005-02-01 Thread Ewok
ay, February 01, 2005 10:13 AM To: CF-Talk Subject: RE: EASY: grabbing the id of a newly created item.. > Wow, too much for so little, Just use Richard's method > > RUN YOUR INSERT QUERY > > Then directly after the insert get the records ID... > > > SELECT MAX(The

RE: EASY: grabbing the id of a newly created item..

2005-02-01 Thread Robertson-Ravo, Neil (RX)
Best to avoid triggers full stop. -Original Message- From: Jeff Garza [mailto:[EMAIL PROTECTED] Sent: 01 February 2005 15:41 To: CF-Talk Subject: Re: EASY: grabbing the id of a newly created item.. If you are using SQL Server 2000, I would recommend moving away from using @@IDENTITY as

Re: EASY: grabbing the id of a newly created item..

2005-02-01 Thread Jeff Garza
rtson-Ravo, Neil (RX)" <[EMAIL PROTECTED]> To: "CF-Talk" Sent: Tuesday, February 01, 2005 8:20 AM Subject: RE: EASY: grabbing the id of a newly created item.. > SQL Server is simply @@IDENTITY > > > > -Original Message- > From: Ewok [mailto:[EMAIL PROTEC

RE: EASY: grabbing the id of a newly created item..

2005-02-01 Thread Robertson-Ravo, Neil (RX)
SQL Server is simply @@IDENTITY -Original Message- From: Ewok [mailto:[EMAIL PROTECTED] Sent: 01 February 2005 15:01 To: CF-Talk Subject: RE: EASY: grabbing the id of a newly created item.. Wow, too much for so little, Just use Richard's method RUN YOUR INSERT QUERY Then dir

RE: EASY: grabbing the id of a newly created item..

2005-02-01 Thread COLLIE David
> Wow, too much for so little, Just use Richard's method > > RUN YOUR INSERT QUERY > > Then directly after the insert get the records ID... > > > SELECT MAX(TheID) as LatestID FROM TABLENAME > Sorry but have to chime in here rather than lurking OK it'll work, but what happens if you hav

RE: EASY: grabbing the id of a newly created item..

2005-02-01 Thread Calvin Ward
ct ID. - Calvin -Original Message- From: Ewok [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 01, 2005 10:01 AM To: CF-Talk Subject: RE: EASY: grabbing the id of a newly created item.. Wow, too much for so little, Just use Richard's method RUN YOUR INSERT QUERY Then directly

RE: EASY: grabbing the id of a newly created item..

2005-02-01 Thread Ewok
source. For the most part, access locks itself when it needs to. -Original Message- From: Barney Boisvert [mailto:[EMAIL PROTECTED] Sent: Monday, January 31, 2005 2:02 PM To: CF-Talk Subject: Re: EASY: grabbing the id of a newly created item.. That's a horrible way to do it. Qui

RE: grabbing the id of a newly created item..

2005-02-01 Thread Calvin Ward
CTED] Sent: Tuesday, February 01, 2005 2:18 AM To: CF-Talk Subject: Re: grabbing the id of a newly created item.. That's something you should know about your DB. There are reasons to use transactions even if your DB doesn't support them. For instance, if you need 100% assurance that a series

Re: grabbing the id of a newly created item..

2005-01-31 Thread Barney Boisvert
That's something you should know about your DB. There are reasons to use transactions even if your DB doesn't support them. For instance, if you need 100% assurance that a series of statements will be executed on a single connection, and no other statements will be interspersed between them. If

Re: EASY: grabbing the id of a newly created item..

2005-01-31 Thread Mike Kear
I always use the ident_current('tablename') function in SQLServer2000, but then again I'm not likely to change that in the forseeable future. But another way to do it, that would be independent of database would be to select based on the criteria you just inserted such as: INSERT into tablename

RE: EASY: grabbing the id of a newly created item..

2005-01-31 Thread Dave Watts
> > > That's only reliable inside a transaction. Don't leave that > > > part out. > > > > Actually, depending on your database, a transaction may not > > be required just as Barney states. For example, if you're > > using MS Access, the entire table is locked when you write > > to it, so a tra

Re: EASY: grabbing the id of a newly created item..

2005-01-31 Thread Rick Root
Dave Watts wrote: >> >>That's only reliable inside a transaction. Don't leave that >>part out. > > > Actually, depending on your database, a transaction may not be required just > as Barney states. For example, if you're using MS Access, the entire table > is locked when you write to it, so a tr

Re: grabbing the id of a newly created item..

2005-01-31 Thread Barney Boisvert
Does Access let you do multiple statements in a single CFQUERY tag like SQL Server? Not a stored proc, but close, because they'll run in the same connection. Should be sufficient for this scenario cheers, barneyb. On Mon, 31 Jan 2005 15:41:10 -0500, Calvin Ward <[EMAIL PROTECTED]> wrote: > Sor

RE: grabbing the id of a newly created item..

2005-01-31 Thread Calvin Ward
Sorry, got my wires crossed on that one. I still prefer the UUID approach (or use a stored procedure - not available in Access). - Calvin -Original Message- From: Dave Watts [mailto:[EMAIL PROTECTED] Sent: Monday, January 31, 2005 3:00 PM To: CF-Talk Subject: RE: grabbing the id of a

RE: grabbing the id of a newly created item..

2005-01-31 Thread Calvin Ward
Me either, but one can never be sure! -Original Message- From: Joe Rinehart [mailto:[EMAIL PROTECTED] Sent: Monday, January 31, 2005 2:33 PM To: CF-Talk Subject: Re: grabbing the id of a newly created item.. > cflock won't work across multiple servers > in a load balanced

Re: grabbing the id of a newly created item..

2005-01-31 Thread Protoculture
So how would I use the code below in context of an insert statement? select @@identity from tableName ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours s

Re: grabbing the id of a newly created item..

2005-01-31 Thread Jochem van Dieten
Barney Boisvert wrote: > MyISAM tables don't support transactions. Exactly. But if you try to use a cftransaction on them, no error is thrown. So you only find out much later that rollbacks didn't work etc. Jochem ~| Logware (

Re: grabbing the id of a newly created item..

2005-01-31 Thread Barney Boisvert
MyISAM tables don't support transactions. Or are you saying if you use CFTRANSACTION on MyISAM tables, it blows up? I've never seen that behaviour either, though I don't know if I've tried it with CFMX, only BD (because BD doesn't do the single threading of requests to connections thing). cheers

Re: grabbing the id of a newly created item..

2005-01-31 Thread Jochem van Dieten
Barney Boisvert wrote: >> What the database does with it is >> something entirely different, and MySQL is the usual suspect if >> something blows up, not Access. > > What do you mean, Jochem? Aside from some quirks with temporary > tables and ALTER TABLE statements in 4.0, I've not run into issue

RE: EASY: grabbing the id of a newly created item..

2005-01-31 Thread Dave Watts
> > That's a horrible way to do it. Quite inefficient. > > > > A better route is to check your DB's docs and see how they > > expose the last inserted sequence value. In MySQL it's > > LAST_INSERT_ID(), with MS SQL Server its one of three > > @IDENTITY variables. Run your INSERT, and then sele

Re: grabbing the id of a newly created item..

2005-01-31 Thread Barney Boisvert
> What the database does with it is > something entirely different, and MySQL is the usual suspect if > something blows up, not Access. What do you mean, Jochem? Aside from some quirks with temporary tables and ALTER TABLE statements in 4.0, I've not run into issues with MySQL's transaction capab

RE: grabbing the id of a newly created item..

2005-01-31 Thread Dave Watts
> In either case, cftransaction isn't guaranteed (it's only a > recommendation, and does it work with Access?) ... I don't think this is correct. When you specify BEGIN TRANSACTION within an SQL batch (which is the raw SQL equivalent of the CFTRANSACTION tag), it isn't a recommendation, but rathe

Re: grabbing the id of a newly created item..

2005-01-31 Thread Jochem van Dieten
Calvin Ward wrote: > In either case, cftransaction isn't guaranteed (it's only a recommendation, > and does it work with Access?) cftransaction is not a recommendation, it sends transaction commands to the database. What the database does with it is something entirely different, and MySQL is the

Re: grabbing the id of a newly created item..

2005-01-31 Thread Joe Rinehart
> cflock won't work across multiple servers > in a load balanced environment... And I hope no one uses Access for that! -Joe -- For Tabs, Trees, and more, use the jComponents: http://clearsoftware.net/client/jComponents.cfm ~|

RE: grabbing the id of a newly created item..

2005-01-31 Thread Calvin Ward
uary 31, 2005 1:38 PM To: CF-Talk Subject: Re: grabbing the id of a newly created item.. Ummm...don't you mean CFTRANSACTION...and not CFLOCK?? Bryan Stevenson B.Comm. VP & Director of E-Commerce Development Electric Edge Systems Group Inc. phone: 250.480.0642 fax: 250.480.1264 cell: 250

Re: EASY: grabbing the id of a newly created item..

2005-01-31 Thread Matt Robertson
> That's only reliable inside a transaction. Don't leave that part out. AND a named lock to choke the process down to a single user. Adding in all of that overhead makes for a serious potential bottleneck in performance, imho, so I never do it. If you can optimize for a single db platform then

Re: EASY: grabbing the id of a newly created item..

2005-01-31 Thread Jeff Garza
12:08 PM Subject: Re: EASY: grabbing the id of a newly created item.. > Barney Boisvert wrote: >> That's a horrible way to do it. Quite inefficient. >> >> A better route is to check your DB's docs and see how they expose the >> last inserted sequence value

Re: EASY: grabbing the id of a newly created item..

2005-01-31 Thread Barney Boisvert
Not necessarily. One of the SQL Server variables is a global variable, so you can call it anytime for the last ID, with no knowledge of who inserted it or even what table. If that's what you care about, then a transaction is irrelevant. WIth MySQL's LAST_INSERT_ID() it's tracked by connection (n

Re: EASY: grabbing the id of a newly created item..

2005-01-31 Thread Jim McAtee
tables. In a shared environment I'd use "myname_databasename_tablename". - Original Message - From: "Barney Boisvert" <[EMAIL PROTECTED]> To: "CF-Talk" Sent: Monday, January 31, 2005 12:01 PM Subject: Re: EASY: grabbing the id of a newly created

Re: EASY: grabbing the id of a newly created item..

2005-01-31 Thread Rick Root
Barney Boisvert wrote: > That's a horrible way to do it. Quite inefficient. > > A better route is to check your DB's docs and see how they expose the > last inserted sequence value. In MySQL it's LAST_INSERT_ID(), with MS > SQL Server its one of three @IDENTITY variables. Run your INSERT, and >

Re: EASY: grabbing the id of a newly created item..

2005-01-31 Thread Barney Boisvert
That's a horrible way to do it. Quite inefficient. A better route is to check your DB's docs and see how they expose the last inserted sequence value. In MySQL it's LAST_INSERT_ID(), with MS SQL Server its one of three @IDENTITY variables. Run your INSERT, and then select the value back out usi

Re: grabbing the id of a newly created item..

2005-01-31 Thread Matt Robertson
<[EMAIL PROTECTED]> wrote: > Ummm...don't you mean CFTRANSACTION...and not CFLOCK?? It should be both if using that kinda dated method. http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_17000 That article is a golden oldie but it explains the reasons why rather well. I personally

Re: grabbing the id of a newly created item..

2005-01-31 Thread Bryan Stevenson
Ummm...don't you mean CFTRANSACTION...and not CFLOCK?? Bryan Stevenson B.Comm. VP & Director of E-Commerce Development Electric Edge Systems Group Inc. phone: 250.480.0642 fax: 250.480.1264 cell: 250.920.8830 e-mail: [EMAIL PROTECTED] web: www.electricedgesystems.com ~

EASY: grabbing the id of a newly created item..

2005-01-31 Thread Richard Colman
-Original Message- From: Protoculture [mailto:[EMAIL PROTECTED] Sent: Monday, January 31, 2005 7:10 AM To: CF-Talk Subject: grabbing the id of a newly created item.. How would I modify an insert query to grab the id ( autonum, primary key ) of the item that I just inserted

RE: grabbing the id of a newly created item..

2005-01-31 Thread Matthew Small
That is correct, I used it a few years ago when Access 2000 came out. - Matt Small -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, January 31, 2005 12:03 PM To: CF-Talk Subject: RE: grabbing the id of a newly created item.. Actually IIRC this is now

RE: grabbing the id of a newly created item..

2005-01-31 Thread kola.oyedeji
> To: CF-Talk > Subject: RE: grabbing the id of a newly created item.. > > > I don't think there's a neat way of doing it for Access, I > > could be wrong though. > > http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=79 > > Couple of me

RE: grabbing the id of a newly created item..

2005-01-31 Thread Calvin Ward
-Talk Subject: Re: grabbing the id of a newly created item.. select @@identity from tableName will return the last inserted id, assuming mssql tw On Mon, 31 Jan 2005 16:09:10 -, Craig Dudley <[EMAIL PROTECTED]> wrote: > Which DB are you using? > > -Original Mess

RE: grabbing the id of a newly created item..

2005-01-31 Thread COLLIE David
> I don't think there's a neat way of doing it for Access, I > could be wrong though. http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=79 Couple of methods ... Could be rewritten in CF if needed -- dc ~| Logware (www.logware

RE: grabbing the id of a newly created item..

2005-01-31 Thread Craig Dudley
More like; Select Max(ID) as MyNewID FROM yourtablename -Original Message- From: Protoculture [mailto:[EMAIL PROTECTED] Sent: 31 January 2005 15:34 To: CF-Talk Subject: Re: grabbing the id of a newly created item.. Thanks Craig. Just to confirm that code.. Select For Max(ID

Re: grabbing the id of a newly created item..

2005-01-31 Thread Protoculture
Thanks Craig. Just to confirm that code.. Select For Max(ID) ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.

RE: grabbing the id of a newly created item..

2005-01-31 Thread Craig Dudley
otoculture [mailto:[EMAIL PROTECTED] Sent: 31 January 2005 15:17 To: CF-Talk Subject: Re: grabbing the id of a newly created item.. ACCESS ~| Logware (www.logware.us): a new and convenient web-based time tracking applicat

Re: grabbing the id of a newly created item..

2005-01-31 Thread Protoculture
what about using access ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:1

Re: grabbing the id of a newly created item..

2005-01-31 Thread Jim Campbell
If you're using SQL Server, you can put the insert in a procedure, wrap it in a transaction, and run something like this at the end: SET @NEWID = SCOPE_IDENTITY() This will return the most recent primary key created. - Jim Protoculture wrote: >How would I modify an insert query to grab the id

Re: grabbing the id of a newly created item..

2005-01-31 Thread Tony Weeg
t: 31 January 2005 15:10 > To: CF-Talk > Subject: grabbing the id of a newly created item.. > > How would I modify an insert query to grab the id ( autonum, primary key > ) of the item that I just inserted? > >

Re: grabbing the id of a newly created item..

2005-01-31 Thread Protoculture
ACCESS ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:192335 Archives:

RE: grabbing the id of a newly created item..

2005-01-31 Thread Craig Dudley
Which DB are you using? -Original Message- From: Protoculture [mailto:[EMAIL PROTECTED] Sent: 31 January 2005 15:10 To: CF-Talk Subject: grabbing the id of a newly created item.. How would I modify an insert query to grab the id ( autonum, primary key ) of the item that I just inserted

grabbing the id of a newly created item..

2005-01-31 Thread Protoculture
How would I modify an insert query to grab the id ( autonum, primary key ) of the item that I just inserted? ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/b