"Pretend" update

Started by Perry Smithover 12 years ago4 messagesgeneral
Jump to latest
#1Perry Smith
pedzsan@gmail.com

With "make" I can do "make -n" and it just tells me what it would do but doesn't actually do anything.

How could I do that with SQL?

I want to write a really complicated (for me) SQL UPDATE statement. I'm sure I won't get it right the first time. Is there an easy way to not really make the changes?

I've thought about starting a transaction and then roll it back. That would undo the changes. But I won't be able to tell what the changes were.

Thank you for your time,
Perry

#2Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Perry Smith (#1)
Re: "Pretend" update

On 10/01/2013 10:16 AM, Perry Smith wrote:

With "make" I can do "make -n" and it just tells me what it would do but doesn't actually do anything.

How could I do that with SQL?

I want to write a really complicated (for me) SQL UPDATE statement. I'm sure I won't get it right the first time. Is there an easy way to not really make the changes?

I've thought about starting a transaction and then roll it back. That would undo the changes. But I won't be able to tell what the changes were.

Assuming you are not doing this in a function, you can. Do UPDATE, then
SELECT to see your changes or not and then ROLLBACK.

Thank you for your time,
Perry

--
Adrian Klaver
adrian.klaver@gmail.com

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Perry Smith
pedzsan@gmail.com
In reply to: Adrian Klaver (#2)
Re: "Pretend" update

On Oct 1, 2013, at 12:23 PM, Adrian Klaver <adrian.klaver@gmail.com> wrote:

On 10/01/2013 10:16 AM, Perry Smith wrote:

With "make" I can do "make -n" and it just tells me what it would do but doesn't actually do anything.

How could I do that with SQL?

I want to write a really complicated (for me) SQL UPDATE statement. I'm sure I won't get it right the first time. Is there an easy way to not really make the changes?

I've thought about starting a transaction and then roll it back. That would undo the changes. But I won't be able to tell what the changes were.

Assuming you are not doing this in a function, you can. Do UPDATE, then SELECT to see your changes or not and then ROLLBACK.

Ah... yes. I forgot you can see the changes within the same transaction. Dohhh...

Thank you very much
Perry

#4Victor Yegorov
vyegorov@gmail.com
In reply to: Perry Smith (#3)
Re: "Pretend" update

2013/10/1 Perry Smith <pedzsan@gmail.com>

On Oct 1, 2013, at 12:23 PM, Adrian Klaver <adrian.klaver@gmail.com>
wrote:

Assuming you are not doing this in a function, you can. Do UPDATE, then

SELECT to see your changes or not and then ROLLBACK.

Ah... yes. I forgot you can see the changes within the same transaction.
Dohhh...

It is possible to use RETURNING clause of the UPDATE statement and avoid
SELECT.

And yes, it is necessary to do this within a transaction and roll it back
after.

--
Victor Y. Yegorov