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
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
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
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
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
> >
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
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
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
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 }.
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 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
-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;
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.
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
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.
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
Paul Lambert wrote:
I've got a function defined in PL/PgSQL to update some fields in a
record where the criteria for pulling out some other values from a table
is dynamic.
I define a string called account_criteria to which I assign a normal SQL
WHERE clause based on some work done earlier in
I've got a function defined in PL/PgSQL to update some fields in a
record where the criteria for pulling out some other values from a table
is dynamic.
I define a string called account_criteria to which I assign a normal SQL
WHERE clause based on some work done earlier in the function. I then
On Monday 27 November 2006 06:31 pm, Mulham freshcode wrote:
> Hi Adrian,
>
> Thanks very much for your help...it is a pity you can't do this in plpgsql
> coz i have almost every thing else I need, and I hate to use yet another
> language. What does it take to add this mechanism to the language? Is
Hi Adrian,
Thanks very much for your help...it is a pity you can't do this in plpgsql coz
i have almost every thing else I need, and I hate to use yet another language.
What does it take to add this mechanism to the language? Is any one planning to
add it? It can come it handy I bet.
Thanks ag
On Sunday 26 November 2006 02:45 pm, Adrian Klaver wrote:
>
> I am afraid I can't make it work either.
I could not make it work with pl/pgsql, but I did manage to come up with a
solution using pl/pythonu.
The function is as follows-
CREATE OR REPLACE FUNCTION dat_col_py(text) RETURNS text AS
$Bo
On Friday 24 November 2006 08:17 pm, Mulham freshcode wrote:
> Hi Adrian,
>
> I have number of similar tables that have different number of fields
> (similar in functionality). An in my stored procedure am trying to select a
> row from one of these tables (that i don't know in advance, hence the us
Hi Adrian,
I have number of similar tables that have different number of fields (similar
in functionality). An in my stored procedure am trying to select a row from one
of these tables (that i don't know in advance, hence the use of record) and
return the data in the form of a table that has c
Adrian Klaver <[EMAIL PROTECTED]> writes:
> On Thursday 23 November 2006 08:45 pm, Tom Lane wrote:
>> This should work --- in PG 8.1 or later.
> The documentation for pl/pgsql in 8.1 and higher says different.
> http://www.postgresql.org/docs/8.1/interactive/plpgsql-statements.html#PLPGSQL-STAT
On Thursday 23 November 2006 10:54 pm, Mulham freshcode wrote:
> Hi Tom,
>
> Thanks for the help. Am using version 8.0 and it seems like RECORD is not
> that dynamic still. I tried with the FOR ... IN EXECUTE ... LOOP and it
> does the trick. But am still finding it hard to move forward with this.
On Friday 24 November 2006 06:55 am, Andreas Kretschmer wrote:
> Adrian Klaver <[EMAIL PROTECTED]> schrieb:
> > On Thursday 23 November 2006 08:45 pm, Tom Lane wrote:
> > > Mulham freshcode <[EMAIL PROTECTED]> writes:
> > > > execute sql_str1 into svc_data_rec ;
> > > >
> > > > svc_data_rec is a RE
Adrian Klaver <[EMAIL PROTECTED]> schrieb:
> On Thursday 23 November 2006 08:45 pm, Tom Lane wrote:
> > Mulham freshcode <[EMAIL PROTECTED]> writes:
> > > execute sql_str1 into svc_data_rec ;
> > >
> > > svc_data_rec is a RECORD, which is supposed to be dynamic.
> >
> > This should work --- in PG
On Thursday 23 November 2006 08:45 pm, Tom Lane wrote:
> Mulham freshcode <[EMAIL PROTECTED]> writes:
> > execute sql_str1 into svc_data_rec ;
> >
> > svc_data_rec is a RECORD, which is supposed to be dynamic.
>
> This should work --- in PG 8.1 or later. In older versions you'd have
> to fool arou
Hi Tom,
Thanks for the help. Am using version 8.0 and it seems like RECORD is not that
dynamic still. I tried with the FOR ... IN EXECUTE ... LOOP and it does the
trick. But am still finding it hard to move forward with this. I have the name
of table field in a varchar variable that i got fro
Mulham freshcode <[EMAIL PROTECTED]> writes:
> execute sql_str1 into svc_data_rec ;
> svc_data_rec is a RECORD, which is supposed to be dynamic.
This should work --- in PG 8.1 or later. In older versions you'd have
to fool around with a FOR ... IN EXECUTE ... loop.
regar
Hello Adrian,
Here is my execute string,
sql_str1 = 'select * from ' || svc_tbl_name || ' where uid = ' || sub_id ;
execute sql_str1 into svc_data_rec ;
svc_data_rec is a RECORD, which is supposed to be dynamic. If I need to define
the structure of the record then there will be no point in usin
On Thursday 23 November 2006 09:19 am, Mulham freshcode wrote:
> Hi,
> Thanks very much for all the suggestions. Like Andreas said i have to
> use EXECUTE to do this. That was my guess too but i was putting the INTO
> cluase into the string before executing it. This is a step forward. The
> pro
Hi,
Thanks very much for all the suggestions. Like Andreas said i have to use
EXECUTE to do this. That was my guess too but i was putting the INTO cluase
into the string before executing it. This is a step forward. The problem now is
getting the into to work with a record. Am using a RECORD
--- Andreas Kretschmer <[EMAIL PROTECTED]> wrote:
> Richard, the plain SQL "INSERT INTO " is an other thing as the
> original problem...
>
> He is in a PL/pgsql - function and he should rewrite this to use EXECUTE
> ... INTO
>
I see, I am not even a novice yet when it comes PL/pgsql. Thanks f
Mulham freshcode <[EMAIL PROTECTED]> writes:
>Am new to sql scripting so this might be a stupid question. Am getting an
> error while trying to do the following
> SELECT INTO svc_data_rec * from svc_tbl_name where 'uid' = sub_id;
The error message shows that this is getting rewritten into
>
Richard Broersma Jr <[EMAIL PROTECTED]> schrieb:
> > Hi guys,
> >
> >Am new to sql scripting so this might be a stupid question. Am getting
> > an error while trying
> > to do the following
> >
> > SELECT INTO svc_data_rec * from svc_tbl_name where 'uid' = sub_id;
> >
> > where svc_data_
> Hi guys,
>
>Am new to sql scripting so this might be a stupid question. Am getting an
> error while trying
> to do the following
>
> SELECT INTO svc_data_rec * from svc_tbl_name where 'uid' = sub_id;
>
> where svc_data_rec is defined as record and svc_tbl_name is a varchar that
> holds
am Wed, dem 22.11.2006, um 0:28:15 -0800 mailte Mulham freshcode folgendes:
> Hi guys,
>
>Am new to sql scripting so this might be a stupid question. Am getting an
> error while trying to do the following
>
> SELECT INTO svc_data_rec * from svc_tbl_name where 'uid' = sub_id;
>
> where svc
Hi guys,
Am new to sql scripting so this might be a stupid question. Am getting an
error while trying to do the following
SELECT INTO svc_data_rec * from svc_tbl_name where 'uid' = sub_id;
where svc_data_rec is defined as record and svc_tbl_name is a varchar that
holds the name of a table
Hi.
I have this problem in a plpgsql function:
SELECT INTO myvar col FROM table WHERE ...;
IF THEN
do something
ELSE IF THEN
do something else
ELSE
do other things
If I know that myvar IS NULL OR GET DIAGNOSTICS
ROW_COUNT is zero.
Is there a way to know if the que
5
PMTo: pgsql-sql@postgresql.org;
pgsql-general@postgresql.orgSubject: [SQL] 'Select INTO" in Execute
(dynamic query )
Hi
What’s wrong with this code
(ERROR:
syntax error at or near "INTO" at character
8)?
Problem: I want to put A1, A2
values i
Hi
What’s wrong with this code (ERROR: syntax error at or near
"INTO" at character 8)?
Problem: I want to put A1, A2 values in two variables
vara, varb.
CREATE OR REPLACE FUNCTION test(text)
RETURNS VARCHAR AS $$
Declare
vara
VARCHAR(10) :='';
varb
On Monday 12 January 2004 01:09, beyaRecords - The home Urban music wrote:
> Hi,
> I want to copy a sequence of rows from one table into another table. I
> have tried select into but this will only work if the table you are
> copying to does not already exist. How do I copy to a table that does
> a
Hi,
I want to copy a sequence of rows from one table into another table. I
have tried select into but this will only work if the table you are
copying to does not already exist. How do I copy to a table that does
already exist?
regards
Uzo
---(end of broadcast)
I am testing my SQL commands in pgaccess before I put them into my C++ code.
Trying to copy a table using...
SELECT * INTO TABLE copy_stuff FROM the_stuff
It creates the view but no table called copy_stuff exists after I run it. Why?
I can use...
CREATE TABLE copy_stuff AS SELECT * FROM the_stuff
45 matches
Mail list logo