[SQL]

2003-07-23 Thread Pavel Penak
unsubscribe-digest pgsql-sql ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] obtuse plpgsql function needs

2003-07-23 Thread Tom Lane
elein <[EMAIL PROTECTED]> writes: > So, other than C, plperl or pltcl is the way to go. > As long as they can input generic composite types > (I wasn't sure of that, but I should have known), Come to think of it, that is a problem: we don't have any way to declare a function as taking "any tuple

Re: TODO item for plpgsql Was Re: [SQL] obtuse plpgsql function needs

2003-07-23 Thread Robert Treat
On Wednesday 23 July 2003 19:06, Bruce Momjian wrote: > Robert Treat wrote: > > On Wed, 2003-07-23 at 15:38, [EMAIL PROTECTED] wrote: > > > FOR myrec IN EXECUTE myinfo LOOP > > > biglist := myrec.info; > > > END LOOP; > > > > One other thing, I hate when I have to do things like the above,

Re: TODO item for plpgsql Was Re: [SQL] obtuse plpgsql function needs

2003-07-23 Thread Bruce Momjian
Robert Treat wrote: > On Wed, 2003-07-23 at 15:38, [EMAIL PROTECTED] wrote: > > FOR myrec IN EXECUTE myinfo LOOP > > biglist := myrec.info; > > END LOOP; > > > > One other thing, I hate when I have to do things like the above, can we > get a TODO like: > > allow 'EXECUTE var INTO record'

[SQL] More plsql questions: updates on views

2003-07-23 Thread Jamie Lawrence
Hi all - I'm trying to work through using views in order to access multiple tables while allowing normal operations on them. To keep things simple, this is a stripped down version of what the structure for one of the views is like: create table base ( id serial primary key, own

[SQL] strange "order by" request

2003-07-23 Thread Frank Bax
Two tables - employee and timesheet simple enough. Each table is more complex than example before. timesheet contains multiple rows per day because the "other" fields are different for various rows on same day/employee. My selection criteria actually uses some of these other fields. lo_shift

TODO item for plpgsql Was Re: [SQL] obtuse plpgsql function needs

2003-07-23 Thread Robert Treat
On Wed, 2003-07-23 at 15:38, [EMAIL PROTECTED] wrote: > FOR myrec IN EXECUTE myinfo LOOP > biglist := myrec.info; > END LOOP; > One other thing, I hate when I have to do things like the above, can we get a TODO like: allow 'EXECUTE var INTO record' in plpgsql Robert Treat -- Build A Br

Re: [SQL] obtuse plpgsql function needs

2003-07-23 Thread Josh Berkus
Robert, > 2) would it be faster in pltcl? seems like it would if i didn't have to > do the catalog lookups, but is pltcl inherently faster anyways? Probably, yes. Execution of dynamic query strings in PL/pgSQL tends to be pretty slow. -- -Josh Berkus Aglio Database Solutions San Francisco

Re: [SQL] obtuse plpgsql function needs

2003-07-23 Thread Robert Treat
Questions for the group: 1) any way to do this without the ctid/oid? Sounds like I could do select a,b,msgmaker(*) from t1 where a=b; in pltcl (which was an early inclination I abandoned, perhaps prematurely) 2) would it be faster in pltcl? seems like it would if i didn't have to do the catalog l

Re: [SQL] time delay function

2003-07-23 Thread Robert Treat
On Tue, 2003-07-22 at 04:22, Christoph Haller wrote: > > > > Pseudo code: > > > > begin trans > > select * from table1 > > WAIT FOR 20 SECS > > update table1 set blah = 'blah' > > end transcation > > > > In pgplsql, Im looking for something like a function that I can use to > make the process to wa

Re: [SQL] obtuse plpgsql function needs

2003-07-23 Thread greg
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Perhaps something like this?. Called like thus: SELECT a,b,c,msgmaker('t1',ctid) FROM t1 WHERE a=b; CREATE OR REPLACE FUNCTION msgmaker(text,tid) RETURNS text AS ' DECLARE mytable ALIAS FOR $1; mytid ALIAS FOR $2; myctid TEXT; myque

Re: [SQL] obtuse plpgsql function needs

2003-07-23 Thread elein
So, other than C, plperl or pltcl is the way to go. As long as they can input generic composite types (I wasn't sure of that, but I should have known), they can access columns as array elements so you can loop through them. And they'll tell you the number of arguments. Ta da! elein On Wed, Jul 2

Re: [SQL] obtuse plpgsql function needs

2003-07-23 Thread Tom Lane
elein <[EMAIL PROTECTED]> writes: > You can do it in C, of course. Yeah. Also you could do it easily in plperl or pltcl (composite-type arguments get passed as perl hashes or Tcl arrays respectively). plpgsql does not have any facility for run-time determination of field names, so you're pretty m

Re: [SQL] obtuse plpgsql function needs

2003-07-23 Thread Josh Berkus
Elein, Robert, I think Robert can do this in 7.3.3, and in PL/pgSQL. But I'm not going any further on it until Robert clarifies his examples, because I'm not sure what he's talking about. In your example, Robert, you use "f1" to indicate both the column f1 and the value of the column f1.

Re: [SQL] obtuse plpgsql function needs

2003-07-23 Thread elein
How will you know in your function what the field names are (you won't) and how many fields to concat unless the function would only work on a fixed number of fields? If it only works on a fixed number of fields, you still have: myconcat( text, text, text, text ) called by sele

Re: [SQL] slow query

2003-07-23 Thread Markus Bertheau
I've forgotten to put data for the belegungen table in the test data set, I've corrected that now, an updated data set is available at the same URL: http://www.bab24.de/media/testdata.sql -- Markus Bertheau Cenes Data GmbH ---(end of broadcast)---

Re: [SQL] rule causes nextval() to be invoked twice

2003-07-23 Thread Dmitry Tkach
I think, your example would work if you replaced the new.id in the rule with curval ('main_id_seq'); ... but see Tom's earlier reply - this is still not a very good thing to do... For example, it won't work if you try to insert into main anything with explicitly specified id (not generated by th

Re: [SQL] obtuse plpgsql function needs

2003-07-23 Thread Robert Treat
On Wed, 2003-07-23 at 09:06, Robert Treat wrote: > On Tue, 2003-07-22 at 19:33, elein wrote: > > You'll need to pass the values down to your > > concat function (which I suggest you don't call concat) > > and have it return a text type. > > > > What exactly is your problem? I must be missing some

Re: [SQL] obtuse plpgsql function needs

2003-07-23 Thread Robert Treat
On Tue, 2003-07-22 at 19:33, elein wrote: > You'll need to pass the values down to your > concat function (which I suggest you don't call concat) > and have it return a text type. > > What exactly is your problem? I must be missing something. > The problem is that I need the function to be gene

Re: [SQL] rule causes nextval() to be invoked twice

2003-07-23 Thread A.Bhuvaneswaran
> Nevermind- that doesn't work either! Here's the new sample code: Rules are triggered before the event. You must do it in AFTER trigger. regards, bhuvaneswaran ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster