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

2008-07-22 Thread Christian Kindler
ill be faster like a single function call (just the max function needs only 141ms) ... Thanks for your Help Christian Original-Nachricht > Datum: Tue, 22 Jul 2008 11:06:07 +0200 > Von: "A. Kretschmer" <[EMAIL PROTECTED]> > An: pgsql-sql@postgresql

[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 n

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 n

[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; Do

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 19:5

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

2007-11-29 Thread Christian Kindler
kind of auditing. Maybe. I > didn't use it. And I use Postgres five years. > > Pavel >> >> >> Pavel Stehule wrote: >> > Hello >> > >> > You cannot to access to values in statement trigger. Postgres doesn't >> > support it. >

[SQL]

2007-11-29 Thread Christian Kindler
idn't use it. And I use Postgres five years. > > Pavel >> >> >> Pavel Stehule wrote: >> > Hello >> > >> > You cannot to access to values in statement trigger. Postgres doesn't >> > support it. >> > >> > Regar

[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 --

Re: [SQL] get only rows for latest version of contents

2007-10-24 Thread Christian Kindler
Hi! not quick mut works select * from business b1 where b1.version_no = (SELECT max(version_no) FROM business b2. where b2.idnode = b1.idnode ) If you want to make this quiry faster du a regular join select b1.* from business b1, (SELECT

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] 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.3&view=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 ha

Re: [SQL] how to move back in refcursor

2007-08-13 Thread Christian Kindler
t;Christian 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

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.attribute

[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] Returnd Refcurser ( not fetchable

2007-08-09 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."

Re: [SQL] Returnd Refcurser ( not fetchable

2007-08-09 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 getfoo

[SQL] Returnd Refcurser ( not fetchable

2007-08-09 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', 'Marcus

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