Re: [SQL] function expression in FROM may not refer to other relations of same query level

2004-08-11 Thread Philippe Lang
Hello, Whats wrong with just using CASE: select id, usr, code, case when code = 1 then 'A' else 'Z' end as line1, case when code = 1 then 'A' else 'Z' end as line2 from tbl; The code I showed in my last mail was actually test code only. The logic is more complicated, and I'm not

[SQL] Inserts with incomplete rows... NOT NULL constraints

2004-08-11 Thread Lars Erik Thorsplass
Am trying to migrate some old data to a new database schema. I have dumped the old data as SQL statements. The new datastructure just contains some added fields to a few tables. My plan was to just create a new database with the new structure, dump the content only as SQL insert statements. And

Re: [SQL] Inserts with incomplete rows... NOT NULL constraints

2004-08-11 Thread Peter Eisentraut
Am Mittwoch, 11. August 2004 14:35 schrieb Lars Erik Thorsplass: I would expect NULL fields not specified in the insert to get NULL inserted automatically. But that fields which are NOT NULL in the table structure gets inserted a NULL value too seems odd. More accurately, the default value is

[SQL] Displaying two tables side by side

2004-08-11 Thread David Garamond
How can you display two tables side by side? Example: select * from t1; a | b ---+--- 2 | 2 3 | 5 4 | 7 9 | 0 select * from t2; c | d ---+--- 4 | 5 7 | 3 3 | 2 1 | 1 2 | 0 Intended output: a | b | c | d ---+---+---+--- 2 | 2 | 4 | 5 3 | 5 | 7 | 3 4 | 7 | 3 | 2 9 | 0 | 1 | 1 |

Re: [SQL] Displaying two tables side by side

2004-08-11 Thread Andreas Haumer
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi! David Garamond wrote: How can you display two tables side by side? Example: select * from t1; a | b ---+--- 2 | 2 3 | 5 4 | 7 9 | 0 select * from t2; c | d ---+--- 4 | 5 7 | 3 3 | 2 1 | 1 2 | 0 Intended output: a

Re: [SQL] Displaying two tables side by side

2004-08-11 Thread Michael Kleiser
select ( select a from t1 where CAST(t1.oid AS int) - CAST( (select min(oid) from t1) AS int ) = t_all.rownum ) AS a , ( select b from t1 where CAST(t1.oid AS int) - CAST( (select min(oid) from t1) AS int ) = t_all.rownum ) AS a , ( select c from t2 where CAST(t2.oid AS int) - CAST( (select

Re: [SQL] Wierded error in recursive function; debugging ideas?

2004-08-11 Thread Josh Berkus
Joe, There is no in_array() function in Postgres that I'm aware of -- you sure that isn't array_in()? Yep. That's a cut-and-paste of the exact log message. The rest of that error message doesn't seem to be there in 7.4 either. Can we see the function? Sure: CREATE OR REPLACE FUNCTION

Re: [SQL] Displaying two tables side by side

2004-08-11 Thread Rod Taylor
Depending on the size of your structures, something like the below may be significantly faster than the subselect alternative, and more reliable than the ctid alternative. CREATE TYPE result_info AS (a integer, b integer, c integer, d integer); CREATE OR REPLACE FUNCTION parallelselect()

Re: [SQL] Displaying two tables side by side

2004-08-11 Thread David Garamond
Andreas Haumer wrote: You could try to use PosgreSQL's ctid system column to join on like this: test=# select *,ctid from t1; a | b | ctid - ---+---+--- 2 | 2 | (0,1) 3 | 5 | (0,2) 4 | 7 | (0,3) 9 | 0 | (0,4) test=# select *,ctid from t2; c | d | ctid - ---+---+--- 4 | 5 | (0,1) 7

Re: [SQL] reply to setting

2004-08-11 Thread Bruno Wolff III
On Sat, Aug 07, 2004 at 09:33:08 +0530, Kenneth Gonsalves [EMAIL PROTECTED] wrote: hi, any reason why the default reply-to on this list should not be set to the list? I keep replying to postings only to find later that the reply goes to the OP and not to the list. reply-all button results

Re: [SQL] sleep function

2004-08-11 Thread John DeSoi
On Aug 10, 2004, at 10:57 AM, Bruce Momjian wrote: I can't think of one, no. I think you will have to use one of the server-side languages and call a sleep in there. This is no good in the real world since it pounds the CPU, but it worked well enough for my testing purposes. Best, John DeSoi,

[SQL] Wierd Error on update

2004-08-11 Thread Thomas Seeber
Hi All, I am relative PostGres newbie, so if there is a simple answer to this question, please feel free to send me a link or explaination. I am running Postgres 7.3 on a intel Linux Redhat 7.3 base. I am getting two errors which are a bit confounding. ERROR: pg_class_aclcheck:relation

Fwd: [SQL] Inserts with incomplete rows... NOT NULL constraints

2004-08-11 Thread Lars Erik Thorsplass
Sorry about that, forgot to send to the list. -- Forwarded message -- From: Lars Erik Thorsplass [EMAIL PROTECTED] Date: Wed, 11 Aug 2004 22:18:24 +0200 Subject: Re: [SQL] Inserts with incomplete rows... NOT NULL constraints To: Peter Eisentraut [EMAIL PROTECTED] Am Mittwoch,

Re: [SQL] Displaying two tables side by side

2004-08-11 Thread Gaetano Mendola
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Andreas Haumer wrote: | test=# select * from t1 right outer join t2 on (t1.ctid=t2.ctid); full outer join is better in this case. Regards Gaetano Mendola -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.4 (MingW32) Comment: Using GnuPG with

Re: [SQL] reply to setting

2004-08-11 Thread Joe Conway
Bruno Wolff III wrote: On Sat, Aug 07, 2004 at 09:33:08 +0530, Kenneth Gonsalves [EMAIL PROTECTED] wrote: any reason why the default reply-to on this list should not be set to the list? I keep replying to postings only to find later that the reply goes to the OP and not to the list. reply-all

Re: [SQL] reply to setting

2004-08-11 Thread Rod Taylor
faster than ones sent through the lists. It is also possible that the direct replies might be handled differently by the recipient (e.g. a filter may put them in different folders). This is very true. In fact, I get mildly annoyed when people *don't* include the direct reply to me,

Re: [SQL] Wierded error in recursive function; debugging ideas?

2004-08-11 Thread Joe Conway
Josh Berkus wrote: [2] Wrong datatype for second argument in call to in_array SQL: SELECT sf_event_decendants(66645,111) Are you sure this message isn't coming from some PHP middleware, e.g. peardb or something. See: http://us2.php.net/manual/en/function.in-array.php Joe

Re: [SQL] Wierd Error on update

2004-08-11 Thread Tom Lane
Thomas Seeber [EMAIL PROTECTED] writes: I am running Postgres 7.3 on a intel Linux Redhat 7.3 base. Original 7.3 release, or (I hope) 7.3.something? I am getting two errors which are a bit confounding. ERROR: pg_class_aclcheck:relation 474653086 not found Are there any views involved? Is

Re: [SQL] Wierded error in recursive function; debugging ideas?

2004-08-11 Thread Josh Berkus
Joe, Are you sure this message isn't coming from some PHP middleware, e.g. peardb or something. See: http://us2.php.net/manual/en/function.in-array.php Hm ... possible. Will check with my PHP guy. Would explain why I've not been able to track down the error. -- -Josh Berkus A

Re: [SQL] UPDATE FROM problem, multiple updates of same row don't seem to work

2004-08-11 Thread Bruno Wolff III
On Mon, Aug 09, 2004 at 15:16:29 -0500, David Stanaway [EMAIL PROTECTED] wrote: Here is an example: CREATE TABLE tablea( id int PRIMARY KEY, flag int ); CREATE TABLE tableb( aid int REFERENCES tablea(id), flag int ); INSERT INTO tablea VALUES(1,0); INSERT INTO tablea

Re: [SQL] UPDATE FROM problem, multiple updates of same row don't seem to work

2004-08-11 Thread Bruno Wolff III
On Wed, Aug 11, 2004 at 20:50:28 -0500, David Stanaway [EMAIL PROTECTED] wrote: I had thought about that, but this is a simpler case of what I need to do. The operations for each column in the update are dependent on the current and new values of each row being merged. Currently I am