one sure-fire way to check if the data exists in a table is to run a SELECT query to select that data. then check the recordcount of the select query - if it is 0 then no such data exists; otherwise the data is already there.
depending on your db and exact requirements you may be able to use db-specific ways to do it. i.e. MySQL has a ON DUPLICATE KEY UPDATE clause one can use in an INSERT query which will update rows instead of inserting new rows if specified PK value already exists in a table. but since you seem to need to notify user of exact action taken (insert or update) that may not be useful in your case... Azadi Saryev Sabai-dee.com http://www.sabai-dee.com/ Priya Koya wrote: > I appologise if I really confused you and I am still learning the Coldfusion > and I am unable to code in a proper way. > > These are my ColdFuion Fields in the Coldfusion page: > > FirstName, LastName,Address,PhoneNumber, EmployerID, DepartmentID , > DepartmentName, EmployerID, Branch > > Sql Database Tables: > > Table1: Employer > > FirstName, LastName,Address,PhoneNumber, EmployerID (Primary Key) > Daniel Ray NJ 123-123-2123 1234 > Ria Parks Nj 124-123-1234 1221 > > EmloyerID is the Primary key. > > Table2: Department > DepartmentID , DepartmentName, EmployerID, Branch, SNO(Unique Identifier) > 12 Economics 1234 NJ 111 > 13 Physics 1234 NJ 121 > 12 Economics 1221 PA 123 > > EmployerID can be repeated but not SNO should be unique. > > I need to do two things. > > 1. Depending on the entry of the formfield values. The database tables should > be either inserted or updated. If the row already exsist then the row should > be inserted and if exsist row should be updated. > > eg: I need to add the Chemistry DepartmentNAme to the EmployerID 1234. I need > to check before the insert statement whether or not the data in the table. > How do I really check this. > > 2. Once the action takes place either update or delete, I need to display the > list of the action taken place in the user session on the coldfusion page. > Session is just the user session here. > eg: DepartmentName for 1234 is insesrted > Salary for 1221 has been updated > . > . > . > Hope I am very clear now... > > > Thanks, > Priya > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:320262 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4