[SQL] How to Select a Tupl by Nearest Date

2008-07-22 Thread Christian Kindler
Hello Assume I have a table like create table foo ( id serial, date foodate, primary key(id) ); with 2 tupls insert into foo(foodate) values('2008-07-07'); --id = 1 insert into foo(foodate) values('2008-07-04'); -- id = 2 What I need is to select the nearest tupl by a given date and I do

Re: [SQL] How to Select a Tupl by Nearest Date

2008-07-22 Thread Christian Kindler
Help Christian Original-Nachricht Datum: Tue, 22 Jul 2008 11:06:07 +0200 Von: A. Kretschmer [EMAIL PROTECTED] An: pgsql-sql@postgresql.org Betreff: Re: [SQL] How to Select a Tupl by Nearest Date am Tue, dem 22.07.2008, um 10:42:56 +0200 mailte Christian Kindler folgendes

[SQL] execute plpgsl like normal sql

2008-05-09 Thread Christian Kindler
Hi Is there a possibility to execute pl/pgsql syntax like normal sql simmilar to sql+ from oracle? The question is: if I want to execute soemthing like this: --File foo.sql: begin for id in select id from mytable loop update myothertable set payed = true where fk_id = id; end loop; end;

Re: [SQL] execute plpgsl like normal sql

2008-05-09 Thread Christian Kindler
Thanks! Chris Original-Nachricht Datum: Fri, 9 May 2008 23:14:44 +1000 Von: imad [EMAIL PROTECTED] An: Christian Kindler [EMAIL PROTECTED] Betreff: Re: [SQL] execute plpgsl like normal sql Anonymous blocks are not supported in PostgreSQL. -- GMX startet ShortView.de

Re: [SQL] Helper aggregate function

2008-02-03 Thread Christian Kindler
hi in this case you have to use execute: select $1,count(*) from $2 group by $1 order by $1; execute into myResultSet 'select ' || $1 || ' from ' || $2 || ' group by ' || $1 || ' order by ' || $2; see plpgsql docs for detailed information christian On Sun, February 3, 2008

[SQL] statement-level trigger sample out there?

2007-11-29 Thread Christian Kindler
Hi Can anyone provide me a simple example of a statement-level trigger? Problem is I do not know how to access the old.*, new.* values. Thanks Chris -- GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS. Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail

[SQL]

2007-11-29 Thread Christian Kindler
Stehule On 29/11/2007, Christian Kindler [EMAIL PROTECTED] wrote: Hi Can anyone provide me a simple example of a statement-level trigger? Problem is I do not know how to access the old.*, new.* values. Thanks Chris -- GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS

Re: [SQL] statement-level trigger sample out there?

2007-11-29 Thread Christian Kindler
support it. Regards Pavel Stehule On 29/11/2007, Christian Kindler [EMAIL PROTECTED] wrote: Hi Can anyone provide me a simple example of a statement-level trigger? Problem is I do not know how to access the old.*, new.* values. Thanks Chris -- GMX FreeMail: 1 GB Postfach

Re: [SQL] Solution to retrieve first and last row for each minute

2007-08-22 Thread Christian Kindler
Hi! Do something like this http://fimi.cvs.sourceforge.net/fimi/database/defaults/indicators/myinttick2bar.sql?revision=1.3view=markup and replace the max / min calculation with a count calculation. Cheers Chris On Wed, August 22, 2007 9:25 am, roopa perumalraja wrote: Hi all, I have

Re: [SQL] Solution to retrieve first and last row for each minute

2007-08-22 Thread Christian Kindler
Its really slow but what you can do is something like the following: select count(a.*), b.* from foo.bar a, ( select price from foo.bar order by time asc limit 1 union select price from foo.bar order by time desc limit 1 ) as b group by b.price ... just do the wheres as you need ... Chris

Re: [SQL] how to move back in refcursor

2007-08-14 Thread Christian Kindler
Kindler [EMAIL PROTECTED] CC: pgsql-sql@postgresql.org Betreff: Re: [SQL] how to moce back in refcursor Christian Kindler [EMAIL PROTECTED] writes: -- move -1 in cur1; plpgsql supports that in CVS HEAD (8.3-to-be) but not in any existing release. You'll need to rethink your logic or do

[SQL] how to moce back in refcursor

2007-08-13 Thread Christian Kindler
Hi I have never worked with cursors but for now I have to step back on special events to calculate a difference. So I have this sample code tested but I can not move in my cursor. I have lokke at docs but this didn't help me. Can you say how to declare my cursor to step back? Thank You Chris

Re: [SQL] Comparing two slices within one table efficiently

2007-08-13 Thread Christian Kindler
Yes and you could make it even more speedy with the use table partitioning. http://www.postgresql.org/docs/8.1/interactive/ddl-partitioning.html select t1.domain_id as domain_id, t1.mta_id as mta_id, t1.run_id as run_id_1, t1.attribute1 as attribute1_1, t1.attribute2 as

Re: [SQL] Returnd Refcurser (unnamed portal x not fetchable

2007-08-10 Thread Christian Kindler
Sorry but this didn't help ... Can not return next ... so I changed the returns as too but same effect as the first function: drop table foo; create table foo(sirname text, name text); insert into foo values ('Mueller', 'Marcus'); drop function getfoo(char(1)); create or replace function

Re: [SQL] Returnd Refcurser (unnamed portal x not fetchable

2007-08-10 Thread Christian Kindler
Ohhh Yes! Thanks al lot. Sometimes you can't see the wood for the trees. Thanks! Chris Original-Nachricht Datum: Fri, 10 Aug 2007 00:31:03 -0600 Von: Michael Fuhr [EMAIL PROTECTED] An: Christian Kindler [EMAIL PROTECTED] CC: Penchalaiah P. [EMAIL PROTECTED], pgsql-sql

[SQL] Returnd Refcurser (unnamed portal x not fetchable

2007-08-10 Thread Christian Kindler
Hi! I have the Problem, that a function returns a refcursor and I am not able to fetch them. I tried in several ways. Can you please tell me how to get the cursor data. Thanks Chris PS this is what I have: create table foo(sirname text, name text); insert into foo values ('Mueller',

Re: [SQL] Count of rows

2007-08-03 Thread Christian Kindler
do this via execute in a stored procedure - something like this (written on the flow - untested!) returns setof text declare my_record record; my counter as bigint; begin for my_record in select tablename from pg_tables where schemaname = 'public' loop execute into counter