Skip site navigation (1) Skip section navigation (2)

Make update query appear as a select

From: terry(at)greatgulfhomes(dot)com
To: "Postgres (E-mail)" <pgsql-docs(at)postgresql(dot)org>
Subject: Make update query appear as a select
Date: 2002-06-17 14:33:11
Message-ID: 003f01c2160b$e8ae8d00$ (view raw, whole thread or download thread mbox)
Lists: pgsql-docs
I need to do either an update, or insert.  Rather then get a lock, get a
recordcount, and then perform an UPDATE/INSERT based on the result of my
count, I was hoping to just do the update, and if nothing happened then I
know I need to do an insert...

So, the application is written in ColdFusion, and someone suggested doing
<cfquery name="update_recent"
	UPDATE user_recent_list
	SET    access_stamp = now()
	WHERE   user_id = '#variables.local_user_id#'
		AND app_name = '#variables.local_app_name#';
	SELECT @@rowcount as rows_updated;

But this part:
	SELECT @@rowcount as rows_updated;
Does not work on Postgres.  Does anyone know what the equivalent statement
is for Postgres?


Terry Fielder
Network Engineer
Great Gulf Homes / Ashton Woods Homes

pgsql-docs by date

Next:From: Bruce MomjianDate: 2002-06-20 04:33:29
Subject: Re: Updated Russian Version of FAQ
Previous:From: Florian HelmbergerDate: 2002-06-17 14:28:12
Subject: Re: Postgres DB recompilation

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group