Re: [SQL] order by when using cursors

2008-06-17 Thread Pavel Stehule
2008/6/18 Pavel Stehule <[EMAIL PROTECTED]>: > Hello > > it's known problem - column and variable names collision, so when you > use any SQL statement inside procedure you have to be carefully about > using variable names. > > postgres=# CREATE OR REPLACE FUNCTION testcur( OUT _a integer, OUT _b in

Re: [SQL] order by when using cursors

2008-06-17 Thread Pavel Stehule
Hello it's known problem - column and variable names collision, so when you use any SQL statement inside procedure you have to be carefully about using variable names. postgres=# CREATE OR REPLACE FUNCTION testcur( OUT _a integer, OUT _b integer ) RETURNS SETOF RECORD AS $$ DECLARE cur ref

[SQL] order by when using cursors

2008-06-17 Thread Patrick Scharrenberg
Hi! I did some experiments with cursors and found that my data doesn't get sorted by the "order by"-statement. Here is what I did: CREATE TABLE ta ( a integer NOT NULL, b integer NOT NULL ); insert into ta values(3,1); insert into ta values(1,2); insert into ta values(4,3

Re: [SQL] using calculated column in where-clause

2008-06-17 Thread Patrick Scharrenberg
Andreas Kretschmer wrote: >> Do I have to repeat the calculation (which might be even more complex > yes. Short and pregnant! :-) Thanks! Patrick -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] using calculated column in where-clause

2008-06-17 Thread Scott Marlowe
On Tue, Jun 17, 2008 at 2:46 PM, Patrick Scharrenberg <[EMAIL PROTECTED]> wrote: > Hi! > > I'd like to do some calculation with values from the table, show them a > new column and use the values in a where-clause. > > Something like this > select a, b , a*b as c from ta where c=2; > > But postgresq

Re: [SQL] using calculated column in where-clause

2008-06-17 Thread Andreas Kretschmer
Patrick Scharrenberg <[EMAIL PROTECTED]> schrieb: > Something like this > select a, b , a*b as c from ta where c=2; > > But postgresql complains, that column "c" does not exist. > > Do I have to repeat the calculation (which might be even more complex yes. Andreas -- Really, I'm not out to de

[SQL] using calculated column in where-clause

2008-06-17 Thread Patrick Scharrenberg
Hi! I'd like to do some calculation with values from the table, show them a new column and use the values in a where-clause. Something like this select a, b , a*b as c from ta where c=2; But postgresql complains, that column "c" does not exist. Do I have to repeat the calculation (which might b