Re: [SQL] scroll cursor bug or me?

2005-06-27 Thread Sim Zacks
It seems to me that scroll cursors are not valid in plpgsql. The following query in PGAdmin works. run one line at a time. begin work; declare bob scroll cursor for select * from testtbl; fetch forward 5 from bob; fetch prior from bob; rollback work; "Larry Morroni" <[EMAIL PROTECTED]> wrot

[SQL] ENUM like data type

2005-06-27 Thread MRB
Hi All, I have something in mind I'm not certain is do-able. I'm working with a lot of data from MySQL where the MySQL ENUM type is used. This is not a big problem per se but creating the proper lookup tables is becoming a bit tedious so I was hoping to make something better of it. Here is w

Re: [SQL] customising serial type

2005-06-27 Thread Stefan Becker
Am Dienstag, 21. Juni 2005 12:01 schrieben Sie: > hi,in a table with a serial datatype, how do i get the sequence to start at > a specific number like 10? Use START in the create sequence statement. # create sequence seq_xeingang increment 1 start 1000; ; CREATE TABLE xeingang ( id

[SQL] SELECT INTO returning more than one row

2005-06-27 Thread Zac
Hi. I have this problem in a plpgsql function: SELECT INTO myvar col FROM table WHERE ...; IF THEN do something ELSE IF THEN do something else ELSE do other things If I know that myvar IS NULL OR GET DIAGNOSTICS ROW_COUNT is zero. Is there a way to know if the que

[SQL] cross-table reference

2005-06-27 Thread Mukesh Ghatiya
Hi, I need to perform a query similar to SELECT table1.a.b.x table1.a.c.x from table1; In this case "a" is an attribute in 'table1' and is a foreign key to other table2 which has 'b', and 'c' as attributes, which again are foreign keys to table3. Is there any simple way of doing this other t

[SQL] Unique primary index?

2005-06-27 Thread orange_crush_068
What are the major differences between Unique, primary index & just plain index? When creating tables I nominate one of these, but not sure what the difference is? ---(end of broadcast)--- TIP 8: explain analyze is your friend

[SQL] Help with query, stuck :(

2005-06-27 Thread bumby
I have a table as Table "public.timereport" Column |Type | Modifiers --+-+ id | integer

[SQL] ORDER records based on parameters in IN clause

2005-06-27 Thread Riya Verghese
I have a stmt where the outer-query is limited by the results of the inner query. I would like the outer query to return records in the same order as the values provided in the IN clause (returned form the inner query). The inner_query is returning id’s ordered by count(id) , i.e by most

Re: [SQL] pg_attribute.attlen -1 for varchar e pbchar fields

2005-06-27 Thread Michael Fuhr
On Mon, Jun 27, 2005 at 02:27:41PM -0300, jimmy.olsen wrote: > > SELECT attname, atttypid, attlen > FROM pg_attribute > where atttypid IN(1042, 1043) > > The attlen column always returns -1 for bpchar and varchar columns. the > postgre version is 8.0.1. When I look the tables in pgAdmin the column

Re: [SQL] SELECT * FROM foo OFFSET -1 LIMIT 1

2005-06-27 Thread Greg Stark
Markus Bertheau <[EMAIL PROTECTED]> writes: > Offset for negative numbers means 0, as it seems. I think there is a > sensible meaning for negative offset numbers and wondered, what > arguments led to negative offsets being processed as 0 offset. Frankly I'm surprised it's not a syntax error. --

Re: [SQL] SELECT * FROM foo OFFSET -1 LIMIT 1

2005-06-27 Thread Markus Bertheau
Dnia 27-06-2005, Mo o godzinie 14:17 -0300, Martín Marqués napisał(a): > How do you skip -1 rows? You redefine OFFSET to mean "where in the result set to start returning rows" and give -1 the meaning that I described above. Please don't ask me, where in the result set position -1 is. I've stum

Re: [SQL] SELECT * FROM foo OFFSET -1 LIMIT 1

2005-06-27 Thread Martín Marqués
El Lun 27 Jun 2005 12:34, Markus Bertheau ☭ escribió: > Hi, > > is there a reason that > > SELECT * FROM t1 OFFSET -1 LIMIT 1 > > does not return 0 rows? Accordingly > > SELECT * FROM t1 OFFSET -1 LIMIT 2 > > should return 1 row, imo. From the docs: The LIMIT clause consists of two independ

Re: [SQL] How can I simply substatue a value in a query?

2005-06-27 Thread davide
Bryan Encina wrote: -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Roy Souther Sent: Monday, June 27, 2005 10:17 AM To: pgsql-sql@postgresql.org Subject: [SQL] How can I simply substatue a value in a query? I want to do a simple substatution of a value i

Re: [SQL] How can I simply substatue a value in a query?

2005-06-27 Thread Bryan Encina
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Roy Souther Sent: Monday, June 27, 2005 10:17 AM To: pgsql-sql@postgresql.org Subject: [SQL] How can I simply substatue a value in a query? I want to do a simple substatution of a value in a query. For example

Re: [SQL] How can I simply substatue a value in a query?

2005-06-27 Thread Jim Buttafuoco
try case for example select case when bool_column then 'Yes' else 'No end from your_table; -- Original Message --- From: Roy Souther <[EMAIL PROTECTED]> To: pgsql-sql@postgresql.org Sent: Mon, 27 Jun 2005 11:16:58 -0600 Subject: [SQL] How can I simply substatue a value in a que

Re: [SQL] How can I simply substatue a value in a query?

2005-06-27 Thread Sean Davis
   - Original Message - From: Roy Souther To: pgsql-sql@postgresql.org Sent: Monday, June 27, 2005 1:16 PM Subject: [SQL] How can I simply substatue a value in a query? I want to do a simple substatution of a value in a query. For example I have a boolean fiel

[SQL] pg_attribute.attlen -1 for varchar e pbchar fields

2005-06-27 Thread jimmy.olsen
Hi listers, I'm facing a problem getting information from meta tables. The command: SELECT attname, atttypid, attlen FROM pg_attribute where atttypid IN(1042, 1043) The attlen column always returns -1 for bpchar and varchar columns. the postgre version is 8.0.1. When I look the tables in pgAdm

[SQL] How can I simply substatue a value in a query?

2005-06-27 Thread Roy Souther
I want to do a simple substatution of a value in a query. For example I have a boolean field that wil return t or f for True and False. I would like it to return Yes or No. I don't want to have a 2x2 table to look up the output. I don't want to use stored procedue. I think there is a better wa

[SQL] SELECT * FROM foo OFFSET -1 LIMIT 1

2005-06-27 Thread Markus Bertheau ☭
Hi, is there a reason that SELECT * FROM t1 OFFSET -1 LIMIT 1 does not return 0 rows? Accordingly SELECT * FROM t1 OFFSET -1 LIMIT 2 should return 1 row, imo. Markus -- Markus Bertheau ☭ <[EMAIL PROTECTED]> ---(end of broadcast)--- TIP 1: su