Dave,
I guess what he (and I) would like to know is that if there is a way to know
that the SQL actually updated the record, not if it ran, I know (by passed
experience) that SQL has some returns code (100=no record found, etc) which
are store in a returned variable... in other languages after an SQL
statement is ran you actually have access to those variables returned as an
structure of SQL (.ErrorCode, .ErrText,among others) if you look at
.ErrorCode and is empty you can know that everyhting was right otherwise
.ErrText will have a description of the error... is there such a thing in
CF?
Bismarck Perez
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 13, 2000 1:43 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE: SQL Success Return Codes
> <cfquery name = "MyQuery" datasource =
> "OurDataSource">
> UPDATE EMPLOYEES
> SET SALARY = 70000
> WHERE EMP_NAME = 'MEE'
> </cfquery>
>
> Assuming the EMP_NAME was 'ME' instead of 'MEE', the
> update will not take place. The Database return code
> woud be 'zero rows updated'.
>
> Is there a way to know whether the update was
> successful? Like in the above SQL can we come to know
> that the update did not actually take place.
It seems to me that the update will be successful whether you specify 'ME'
or 'MEE'. Success simply means that the SQL statement ran, did what you told
it to do, and didn't return an error. For example, if I run that query in
the SQL Server Query Analyzer, I'll get the same message either way: "No
rows returned ...".
If you wanted to know how many records are modified, you might be able to
return the number using a trigger. For example, you can do this in SQL
Server 7:
CREATE TRIGGER HowMany
ON EMPLOYEES
FOR UPDATE
AS
SELECT MyCount = @@ROWCOUNT
Then, below the CFQUERY tag, you could find out how many records had been
updated:
<cfoutput>#MyQuery.MyCount#</cfoutput> records updated!
Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444
----------------------------------------------------------------------------
--
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.