> <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.

Reply via email to