Hi Everyone,
I have asked our DBA at work and h is not too sure either... so I
thought it best to on the list.
Basically, what I am after is a way to copy the contents of one record
into another.
Something like select into; but where the destination record already
exists, as opposed to cr
am Thu, dem 20.03.2008, um 20:57:53 +1100 mailte Gavin 'Beau' Baumanis
folgendes:
> Hi Everyone,
>
> I have asked our DBA at work and h is not too sure either... so I
> thought it best to on the list.
>
> Basically, what I am after is a way to copy the contents of one record
> into another.
On Thu, Mar 20, 2008 at 4:19 PM, A. Kretschmer <
[EMAIL PROTECTED]> wrote:
> am Thu, dem 20.03.2008, um 20:57:53 +1100 mailte Gavin 'Beau' Baumanis
> folgendes:
> > Hi Everyone,
> >
> > I have asked our DBA at work and h is not too sure either... so I
> > thought it best to on the list.
> >
> > B
HI Gurjeet,
You're right.
But what information do you need to know?
The copy is inside the same table, so I don't understand why it (the
required query ) would require any joins.
Ie. I want to copy the contents of a row (but for the id column - of
course) into a record in the same table.
-BEGIN PGP SIGNED MESSAGE-
Hash: RIPEMD160
> Ie. I want to copy the contents of a row (but for the id
> column - of course) into a record in the same table.
BEGIN;
CREATE TEMP TABLE tempfoo AS SELECT * FROM foo WHERE id = 123;
UPDATE tempfoo SET id = 456;
DELETE FROM foo WHERE id = 456;
On Thu, Mar 20, 2008 at 4:39 PM, Gavin 'Beau' Baumanis <
[EMAIL PROTECTED]> wrote:
> HI Gurjeet,
> You're right.
>
> But what information do you need to know?
>
> The copy is inside the same table, so I don't understand why it (the
> required query ) would require any joins.
>
> Ie. I want to copy
Gavin 'Beau' Baumanis wrote:
The copy is inside the same table, so I don't understand why it (the
required query ) would require any joins.
Maybe you should use FROM clause in the update that references a
row-valued subquery?
craig=# create table x ( id serial, val integer );
NOTICE: CREATE
On Thu, Mar 20, 2008 at 5:35 PM, Craig Ringer <[EMAIL PROTECTED]>
wrote:
>
> craig=# explain update x set val = foundrow.val from ( select val from x
> where id = 4123 ) as foundrow where id = 5912 ;
>
Thats nifty.
--
[EMAIL PROTECTED]
[EMAIL PROTECTED] gmail | hotmail | indiatimes | yahoo }.
Hi Everyone,
I want to thank everyone for their help / suggestions...
I really appreciate it.
Though I think I have found a winner.
craig=# update x set val = foundrow.val from ( select val from x
where id = 2 ) as foundrow where id = 1 ;
UPDATE 1
Very elegant, very clean...
Very nice!
T
craig=# update x set val = foundrow.val from ( select val from x
where id = 2 ) as foundrow where id = 1 ;
UPDATE 1
Thinking about it, it'd actually be better written as:
UPDATE x SET val = foundrow.val FROM ( SELECT val FROM x AS x2 WHERE
x2.id = 2 ) AS foundrow WHERE id = 1;
... be
Gavin 'Beau' Baumanis wrote:
The copy is inside the same table, so I don't understand why it (the
required query ) would require any joins.
Ie. I want to copy the contents of a row (but for the id column - of
course) into a record in the same table.
I think what you want is something like
On Thu, Mar 20, 2008 at 5:40 PM, Joe <[EMAIL PROTECTED]> wrote:
> Gavin 'Beau' Baumanis wrote:
> >
> > The copy is inside the same table, so I don't understand why it (the
> > required query ) would require any joins.
> >
> > Ie. I want to copy the contents of a row (but for the id column - of
> >
Gurjeet Singh wrote:
Except that it doesn't work... Did you try to execute that query; I am
assuming not.
It does, or at least a query written to work the same way works fine for
me. Not only that, but at least in the presence of a unique index the
query planner optimises it to the same quer
Hello list,
I am a bit confused. See the code below:
BEGIN;
SAVEPOINT sp1;
INSERT INTO test(id,runde) VALUES(2, 0);
--if there is a unique key violstion:
ROLLBACK TO sp1;
UPDATE test SET id = 1000 WHERE runde = 0;
COMMIT;
When I first run this statement, I do not get any error message, but also
Hello list,
I am a bit confused. See the code below:
BEGIN;
SAVEPOINT sp1;
INSERT INTO test(id,runde) VALUES(2, 0);
--if there is a unique key violstion:
ROLLBACK TO sp1;
UPDATE test SET id = 1000 WHERE runde = 0;
COMMIT;
When I first run this statement, I do not get any error message, but also
Jan Peters wrote:
If I run the transaction block from above again I get first a unique key violation (that is ok, because
that's what I trying to check for) but there is NO rollback to sp1, only the "Unique Key" error
message and after that I get the dreaded "current transaction is aborted" err
Gurjeet Singh wrote:
Except that it doesn't work... Did you try to execute that query; I am
assuming not.
Of course I did, do you think I create results by editing them into my
email?
The script:
delete from t1;
insert into t1 values (1, 123, 'first record');
insert into t1 values (2, 456, 's
Hello Craig,
> Jan Peters wrote:
> > If I run the transaction block from above again I get first a unique key
> violation (that is ok, because that's what I trying to check for) but
> there is NO rollback to sp1, only the "Unique Key" error message and after
> that
> I get the dreaded "current tr
On Thu, Mar 20, 2008 at 7:08 PM, Joe <[EMAIL PROTECTED]> wrote:
> Gurjeet Singh wrote:
> > Except that it doesn't work... Did you try to execute that query; I am
> > assuming not.
> Of course I did,
My bad... I did not run your query either, and based my assumption on my
previous attempt that ha
Jan Peters wrote:
Yes, you are correct: I just want to issue an insertion of a row at the very beginning of an
application start. So, when the table "test" is empty, the row with "runde =
0" should be inserted. If this row is already present, it should be updated.
This is quite common - yo
On Mar 20, 2008, at 7:10 AM, Joe wrote:
Gavin 'Beau' Baumanis wrote:
The copy is inside the same table, so I don't understand why it
(the required query ) would require any joins.
Ie. I want to copy the contents of a row (but for the id column -
of course) into a record in the same tabl
Hello Craig,
>
> Maybe you should tell the readers of this list a little more about what
> you're trying to do and why?
> --
ok, so I'll do that: I am programming a small economic Java simulation/serious
game that has to calculate the GDP after 12 rounds. For doing this, I need the
capital of
"Jan Peters" <[EMAIL PROTECTED]> writes:
> If I run the transaction block from above again I get first a unique
> key violation (that is ok, because that's what I trying to check for)
> but there is NO rollback to sp1, only the "Unique Key" error message
> and after that I get the dreaded "current
Hello Tom,
> so the problem must be in something you didn't show us. What exactly
> are you doing to decide that you need to roll back? Also, none of these
> statements (except the CREATE) would take an exclusive lock on test, so
> there must be something else going on that you didn't show us.
Hm,
Tom, your're right, it works in the console, but not in the editor window,
strange...
--
Pt! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your s
Yes, Tom,
it looks like this:
Locked Transaction:458553
I misread that. Sorry for that, I am actually a Geographer and just "using" the
tools at hand. So I was not clear enough, it is a lock, but it's just the one
of the transaction, right. That still does not explain why the Query Editor
loc
On Thu, Mar 20, 2008 at 1:44 PM, Tena Sakai <[EMAIL PROTECTED]> wrote:
> Just a postscript. It is important to check
> both ways. Because (sometimes) vice versa is
> not necessarily true. Case in point below:
Yes, I'm well aware of that. Still, you should UNION the result of
both exceptions
Hi Jonah,
> Still, you should UNION the result of
> both exceptions into a single result set.
Great suggestion. Many thanks.
Regards,
Tena Sakai
[EMAIL PROTECTED]
-Original Message-
From: Jonah H. Harris [mailto:[EMAIL PROTECTED]
Sent: Thu 3/20/2008 12:21 PM
To: Tena Sakai
Cc: pgsql-
Hi Jonah,
Just a postscript. It is important to check
both ways. Because (sometimes) vice versa is
not necessarily true. Case in point below:
blitzen=> select * from foo
blitzen-> except
blitzen->select * from moo;
alleleid | markerid | value | datecreated | datereplaced
--+
Hi, I've been working on a generic date partitioning system and I
think I've reached something that can't be done, but I thought I'd
post a question to the masses in the hope that I'm missing something.
The basic idea of what I'm doing is some userland scripts that will
accept a table name
>
> A sample of the current results data would be like
> datesales
> 2008-03-07 100.00
> 2007-03-10 150.00
> 2007-03-18 50.00
>
> and what I'm trying to do is fill in the missing dates with sales
> values of 0.
what I do is have a table called days t
31 matches
Mail list logo