[GENERAL] pgplsql, how to save row variable to a table row

2008-03-26 Thread josep porres
Hi, i'm learning how to work with rows (rowtype) , but I cannot find a way to insert one, once i filled up the fields, in a table. the thing is: I have some rows filled up with execute commands as you can see below. Once I've filled the row_tempf, how can I insert this row to the table

Re: [GENERAL] pgplsql, how to save row variable to a table row

2008-03-26 Thread Raymond O'Donnell
On 26/03/2008 11:59, josep porres wrote: row_tempf.field1 := value1; row_tempf.field2 := value3; ... row_tempf.fieldN := valueN; -- NOW INSERT row_tempf in the associated table -- ??? Easy! - insert into tablename ( column ... ) values (row_tempf.field1, row_tempf.field2, ... ); :-)

Re: [GENERAL] pgplsql, how to save row variable to a table row

2008-03-26 Thread josep porres
I've tried: EXECUTE 'INSERT INTO F2_TEMPFAC SELECT * FROM row_tempf'; but I've got not surprisingly: ERROR: relation row_tempf does not exist Estado SQL:42P01 Contexto:SQL statement INSERT INTO F2_TEMPFAC SELECT * FROM row_tempf PL/pgSQL function f2_facturar line 437 at EXECUTE statement I'm

Re: [GENERAL] pgplsql, how to save row variable to a table row

2008-03-26 Thread Raymond O'Donnell
On 26/03/2008 12:14, josep porres wrote: I'm going to try your suggestion, however it's a bit annoying because this table has a lot of fields. maybe i'm lazy to write all of them :P ... Heh heh I sometimes cut and paste SQL from the table definition window in PgAdmin, to save typing the

Re: [GENERAL] pgplsql, how to save row variable to a table row

2008-03-26 Thread Sam Mason
On Wed, Mar 26, 2008 at 01:14:07PM +0100, josep porres wrote: I've tried: EXECUTE 'INSERT INTO F2_TEMPFAC SELECT * FROM row_tempf'; I think that: INSERT INTO f2_tempfac SELECT (row_tempf).*; should do what you want. Unless you're doing something very fancy you don't want the execute

Re: [GENERAL] pgplsql, how to save row variable to a table row

2008-03-26 Thread Raymond O'Donnell
On 26/03/2008 12:26, Sam Mason wrote: INSERT INTO f2_tempfac SELECT (row_tempf).*; Does this depend on the column order in table f2_tempfac being the same as that in the SELECT that produced row_tempf? Or will row_tempf.foo automagically get matched with column f2_tempfac.foo, etc?

Re: [GENERAL] pgplsql, how to save row variable to a table row

2008-03-26 Thread Craig Ringer
Raymond O'Donnell wrote: On 26/03/2008 11:59, josep porres wrote: row_tempf.field1 := value1; row_tempf.field2 := value3; ... row_tempf.fieldN := valueN; -- NOW INSERT row_tempf in the associated table -- ??? Easy! - insert into tablename ( column ... ) values

Re: [GENERAL] pgplsql, how to save row variable to a table row

2008-03-26 Thread josep porres
INSERT INTO demo_tab SELECT demo_tab_row.*; I tried this before with no success. But I realized that it was because a problem with a constraint, no warnings about this at all. With the detailed insert i've got the constraint error. I was using the execute because I had a variable called the same

Re: [GENERAL] pgplsql, how to save row variable to a table row

2008-03-26 Thread John DeSoi
On Mar 26, 2008, at 8:59 AM, josep porres wrote: INSERT INTO demo_tab SELECT demo_tab_row.*; I tried this before with no success. But I realized that it was because a problem with a constraint, no warnings about this at all. With the detailed insert i've got the constraint error. I was