[SQL] Set generating functions and subqueries

2006-03-10 Thread Markus Schaber
Hello, Today, I stumbled across the following: postgres=# select generate_series(1,2),'othercol'; generate_series | ?column? -+-- 1 | othercol 2 | othercol (2 rows) postgres=# select (select generate_series(1,2)),'othercol'; ERROR: more tha

Re: [SQL]

2006-03-10 Thread Markus Schaber
Hi, Klay, Klay Martens wrote: > I am really battling to figure out how to do the same in a postgres > function. http://www.postgresql.org/docs/8.1/static/queries-table-expressions.html#QUERIES-TABLEFUNCTIONS could be helpful. HTH Markus -- Markus Schaber | Logical Tracking&Tracing Internati

Re: [SQL] pg reserved words

2006-03-10 Thread Markus Schaber
Hi, Irina, Irina Gadassik wrote: > I am trying to create a table freeze and it seems "freeze" is a reserved > word, but I don't see it in > the list. Also in a different table I cann't create a column freeze. > However it is possible in MySQL and Ingres. It is a PostgreSQL specific reserved word

Re: [SQL] dbLink Query

2006-03-10 Thread Markus Schaber
Hi, Richard, Richard C wrote: > How do I install or setup the function dbLink so that I can use this > feature. In your PostgreSQL installation, there should be a contrib directory, that contains a file dblink.sql - execute it via psql against your database, and it installs the function definiti

[SQL] How can I selet rows which have 2 columns values cross equal?

2006-03-10 Thread Fay Du
Hi All: I have a table like this: Table test Id | a | b -++--- 1| 100| 101 2| 101| 100 3| 100| 3 4| 20 | 30 5| 11 | 13 6| 3 | 33 7| 30 | 20 I want to get row 1, 2,4 and 7 selected. Because their values of a and b are cross equal. i.e., for each pair of r

Re: [SQL] How can I selet rows which have 2 columns values cross equal?

2006-03-10 Thread Milorad Poluga
On Friday 10 March 2006 14:24, Fay Du wrote: >    Table test > Id   |  a | b > -++--- > 1    | 100| 101 > 2    | 101| 100 > 3    | 100| 3 > 4    | 20 | 30 > 5    | 11 | 13 > 6    | 3  | 33 > 7    | 30 | 20 > select a.* from test a, test b where a.a = b.b and a.b = b.a order by id Regard

Re: [SQL] How can I selet rows which have 2 columns values cross equal?

2006-03-10 Thread PFC
What are your conditions on a and b ? Can a be equal to b on a row ? If so, do you want this row ? If you want to avoid duplicates, I suggest first removing them, then adding a constraint CHECK( aapplication (or in an ON INSERT trigger), swap a and b if a>b. I added some values to your tabl

Re: [SQL] Set generating functions and subqueries

2006-03-10 Thread Tom Lane
Markus Schaber <[EMAIL PROTECTED]> writes: > postgres=# select (select generate_series(1,2)),'othercol'; > ERROR: more than one row returned by a subquery used as an expression > So it seems that set-returning functions "blow up" the resultset by > duplicating rows - so why is this not allowed fo

Re: [SQL] How can I selet rows which have 2 columns values cross equal?

2006-03-10 Thread Bruno Wolff III
On Fri, Mar 10, 2006 at 08:24:44 -0500, Fay Du <[EMAIL PROTECTED]> wrote: > Hi All: > I have a table like this: > >Table test > Id | a | b > -++--- > 1| 100| 101 > 2| 101| 100 > 3| 100| 3 > 4| 20 | 30 > 5| 11 | 13 > 6| 3 | 33 > 7| 30 | 20 > > I want t

[SQL] Locking row

2006-03-10 Thread Flavio Suguimoto
Hi all, I need to mark a row with a value in a column, but first i need to select the first row without this mark. But in some concurrents cases i mark the row twice. How can i lock the row to avoid others session get it? TABLE TICKET TICKET_NUMBER | MARK 1 |1 2 |0

Re: [SQL] Locking row

2006-03-10 Thread Larry Rosenman
Flavio Suguimoto wrote: > Hi all, > > I need to mark a row with a value in a column, but first i need to > select the first row without this mark. But in some concurrents cases > i mark the row twice. How can i lock the row to avoid others session > get it? > > TABLE TICKET > TICKET_NUMBER | MAR

[SQL] Advice on setting up a grid like view for spreadsheet users

2006-03-10 Thread Bryce Nesbitt
All; I have a need to create a view.  The data table does not exist yet, the question is on how to best set it up in postgres.  The resulting view has to be spreadsheet-like, and will be loaded directly via ODBC into Excel for number crunching.  Maybe something like:        R

[SQL] READ COMMITTE without START TRANSACTION?

2006-03-10 Thread ogjunk-pgjedan
Hello, I need to run some SELECT queries that take a while (10+ minutes) to complete, and I'm wondering about the isolation about the results I get. More precisely, while my SELECT is running, the DB is being updated by another application, and I am wondering which, if any, data changes my SEL

Re: [SQL] READ COMMITTE without START TRANSACTION?

2006-03-10 Thread Jaime Casanova
On 3/10/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hello, > > I need to run some SELECT queries that take a while (10+ minutes) to > complete, and I'm wondering about the isolation about the results I get. > More precisely, while my SELECT is running, the DB is being updated by > anothe

Re: [SQL] Locking row

2006-03-10 Thread Michael Fuhr
On Fri, Mar 10, 2006 at 02:57:51PM -0600, Larry Rosenman wrote: > Flavio Suguimoto wrote: > > I need to mark a row with a value in a column, but first i need to > > select the first row without this mark. But in some concurrents cases > > i mark the row twice. How can i lock the row to avoid others

Re: [SQL] How can I selet rows which have 2 columns values cross equal?

2006-03-10 Thread Michael Glaesemann
On Mar 10, 2006, at 22:24 , Fay Du wrote: I want to get row 1, 2,4 and 7 selected. Because their values of a and b are cross equal. i.e., for each pair of rows, a.Row1 = b.Row2 and b.Ro1 = a.Row2 a.Row4 = b.Row7 and b.Ro4 = a.Row7 You need to use subqueries: create table test ( id inte