Re: [SQL] plpgsql - Insert from a record variable?

2004-06-21 Thread Tom Lane
"Phil Endecott" <[EMAIL PROTECTED]> writes: > I think what I really need is an introspection mechanism > so that I can loop over each element of the record and construct the > insert as a string. Maybe this is possible using a different > server-side language? pltcl can probably handle this; I'm

Re: [SQL] plpgsql - Insert from a record variable?

2004-06-21 Thread basic
Phil Endecott wrote: > !! execute ''column_values := > !! column_values || quote_literal(r.'' || cr.column_name || '')''; I'm guessing you want something like FOR rec IN EXECUTE ''select column_values || quote_literal(r.'' || cr.column_name || '') alias column_values''; LOOP column_values

Re: [SQL] plpgsql - Insert from a record variable?

2004-06-21 Thread Phil Endecott
I wrote: > perhaps rather than inspecting the record variable to see what fields > it contains, I can look at the table to see what columns it contains This is my effort. It doesn't work, because I can only EXECUTE SQL statements, not PLPGSQL statements. I need to EXECUTE an assignment statement

Re: [SQL] plpgsql - Insert from a record variable?

2004-06-21 Thread Phil Endecott
Phil> Insert from a record variable? Riccardo> Try insert into table select r.*; Tom> in 7.5 Tom> insert into table select r.*; Tom> insert into table values(r.*); Tom> so long as r is declared to be of a named rowtype (not just Tom> RECORD) Thanks! Unfortunately I need record, rather

Re: [SQL] [JDBC] Prepare Statement

2004-06-21 Thread Jie Liang
Does plperl catch the plan also? Thanks. Jie Liang -Original Message- From: Kris Jurka [mailto:[EMAIL PROTECTED] Sent: Friday, June 18, 2004 2:47 PM To: Jie Liang Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [JDBC] Prepare Statement On Fri, 18 Jun 2004, Jie Liang wrote: >

Re: [SQL] subselect prob in view

2004-06-21 Thread Gary Stainburn
On Monday 21 Jun 2004 3:19 pm, Tom Lane wrote: > Gary Stainburn <[EMAIL PROTECTED]> writes: > > from requests r, users u, request_types t, > > request_states s, dealerships d, departments de, customers c > > left outer join (select co_r_id, count(co_r_id) from comments > >

Re: [SQL] subselect prob in view

2004-06-21 Thread Tom Lane
Gary Stainburn <[EMAIL PROTECTED]> writes: > from requests r, users u, request_types t, > request_states s, dealerships d, departments de, customers c > left outer join (select co_r_id, count(co_r_id) from comments group > by co_r_id) co on > co.co_r_id = r.r_

Re: [SQL] Function Parameters - need help !!!

2004-06-21 Thread Richard Huxton
Pradeepkumar, Pyatalo (IE10) wrote: Well this is right for the local variablesbut what about the function parameters. Okay, I will make it more simplesay I want to write a function like this CREATE FUNCTION test(integer,integer) RETURNS INTEGER AS ' DECLARE param1 ALIAS FOR $1; param2

Re: [SQL] Function Parameters - need help !!!

2004-06-21 Thread Phil Endecott
Hi, Quote from Section 37.11 of the manual: # There are no default values for parameters in PostgreSQL. # You can overload function names in PostgreSQL. This is often used to work around the lack of default parameters. So for your example: > CREATE FUNCTION test(integer,integer) RETURNS INTEG

Re: [SQL] Function Parameters - need help !!!

2004-06-21 Thread Pradeepkumar, Pyatalo (IE10)
Well this is right for the local variablesbut what about the function parameters. Okay, I will make it more simplesay I want to write a function like this CREATE FUNCTION test(integer,integer) RETURNS INTEGER AS ' DECLARE param1 ALIAS FOR $1; param2 ALIAS FOR $2; BEGIN ---

[SQL] subselect prob in view

2004-06-21 Thread Gary Stainburn
Hi folks, I've got the view: create view nrequest_details as select r.r_id, r_registration, r.r_chassis, r.r_vehicle, r.r_fuel,r.r_pack_mats, r.r_delivery, r_delivery::date-now()::date as r_remaining, r.r_created, r.r_completed, d.d_des, de.de_des, u.u_id,

Re: [SQL] Strange behaviour updating primary key column.

2004-06-21 Thread Richard Huxton
Luis Neves wrote: In the above table why does the query: UPDATE "story" SET id = (id + 1500); fails with: "ERROR: duplicate key violates unique constraint 'story_pkey'" (I have 6000 records in the table with "id" spanning from 1 to 6000) I find this behaviour strange, SQL is a set based language,

Re: [SQL] Function Parameters - need help !!!

2004-06-21 Thread V i s h a l Kashyap @ [Sai Hertz And Control Systems]
Dear Pradeep , CREATE PROC PP_ReadPointByValue @SessionID int = NULL, --these r default parameters SessionID INT := NULL; @SPSID int = 1,--default value SPSID int := 1 ; @ParameterName nvarchar (50) = NULL, -- if NULL read all parameters ParameterName varchar(50) := NULL ; @NumValue real

[SQL] feature request

2004-06-21 Thread sad
hello it might be stupid... sometimes i am starving UPDATE OR INSERT command thnx ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [SQL] pivot-like transformation

2004-06-21 Thread Torsten Lange
Joe Conway schrieb: Torsten Lange wrote: Hello, I have a table with measurement values and columns like this: analyses(id, sample_id, parameter[temperatur...], value, unit[?C...], error) With PL/PgSQL at the end I want try to perform a pivot-like arrangement of these dat