Re: [SQL] "How do I ..." SQL question

2005-01-17 Thread PFC
Return only four rows beginning at second row: SELECT count(*) AS count, name, year FROM a GROUP BY name, year ORDER BY count DESC, name ASC LIMIT 4 OFFSET 1; count name year --- -- -- 3 joe2004 s,e,e 2 bob2003 w,e 2 kim2003 s,s 2 sue

[SQL] "How do I ..." SQL question

2005-01-17 Thread zeus
Hi there: I have a "How do I..." SQL question regarding selecting distinct values from a field not included in an aggregated query when LIMIT is in effect, illustrated by the following example: Table a contains the names of individuals, the places they have visited and the year in which they were

Re: [SQL] query configuration for validate empty quote to zero

2005-01-17 Thread Yudie
The problem is not stop there, I had a table that can't be updated since then with this simply command: update prdttable set webinclude = '0' where prdtnumber = '6002' Again, the errors (invalid input syntax for integer: "") apears. Then I found this temporary solution to make replica to this rec

Re: [SQL] plpgsql and for with integer loopvar error

2005-01-17 Thread Stephan Szabo
On Sat, 15 Jan 2005, Ari Kahn wrote: > CREATE FUNCTION gets_nooky() returns numeric AS > ' > DECLARE > i integer; > gt1cnt record; > gt1 record; > cluster record; > cluster_cnt integer; > slocus integer; > minmax record; > > BEGIN > SELECT INTO gt1 * FROM c

Re: [SQL] query configuration for validate empty quote to zero

2005-01-17 Thread Tom Lane
"Yudie" <[EMAIL PROTECTED]> writes: > Now, if I use the same query it return an error: > invalid input syntax for integer: "" > Anyone know what's the problem?? None. That's an intentional change. The fact that it ever accepted '' as meaning 0 was a bug. regards, tom l

[SQL] query configuration for validate empty quote to zero

2005-01-17 Thread Yudie
We just changed the postgresql server and got some problem with sql command in our old server we can exexute this query:   SELECT * FROM product WHERE prdtnumber = ''   field prdtnumber data type is integer and the empty quote somehow can be assumed into 0 (zero) Now,  if I use the same qu

[SQL] plpgsql and for with integer loopvar error

2005-01-17 Thread Ari Kahn
I have a single column result that I want to loop through using an index. I also want to jump ahead in the result using the index (below: i:=i+cluster_cnt-1;) . However, I'm getting the following error. ERROR: syntax error at or near "SELECT" at character 9 CONTEXT: PL/pgSQL function "gets_noo

Re: [SQL] Inserting or Deleting conditionally

2005-01-17 Thread Richard Huxton
KÖPFERL Robert wrote: Hi, coming from imperative programming paradigma, I'm currently trying to express something like that in _SQL_: SQL is not an imperative language - each SQL statement is an expression to be evaluated. It should be atomic and like an API for a user. I'm therefore writing func

[SQL] Inserting or Deleting conditionally

2005-01-17 Thread KÖPFERL Robert
Hi, coming from imperative programming paradigma, I'm currently trying to express something like that in _SQL_: It should be atomic and like an API for a user. I'm therefore writing functions: CRETE FUNC... c := SELECT x,y,z FROM table_a WHERE... IF COUNT(c)=1 then INSERT / DELETE ... W

Re: [SQL] Record type in sql

2005-01-17 Thread KÖPFERL Robert
Yo can do s.t. similar, if the order in which you select the columns corresponds to the order your type is defined. So you'd gonna use: select intcol, textcol from table; > -Original Message- > From: Din Adrian [mailto:[EMAIL PROTECTED] > Sent: Montag, 17. Jänner 2005 13:31 > To: pgsql-sql

[SQL] Record type in sql

2005-01-17 Thread Din Adrian
Hello, I have a little problem I want to declare a type record for later use like that create type record_structure1 as (id int2, nume text); that is ok! next in a function I want to use something like that: select * from table as record_structure1 ? instead of writing select * from table as t1(id