X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id CC93511F68F0 for ; Wed, 12 Apr 2006 15:49:49 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: 0.55 X-Spam-Level: X-Spam-Status: No, score=0.55 required=5 tests=[NO_REAL_NAME=0.55] Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id JkK1sINENKvz for ; Wed, 12 Apr 2006 15:49:44 -0300 (ADT) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 2A37511F6748 for ; Wed, 12 Apr 2006 15:49:45 -0300 (ADT) Received: from resolution.com (unknown [65.18.201.170]) by svr4.postgresql.org (Postfix) with ESMTP id ABE795AF18F for ; Wed, 12 Apr 2006 18:49:45 +0000 (GMT) Received: (from resolutio@localhost) by resolution.com (8.12.10/8.11.2) id k3CIndbt028599 for pgsql-sql@postgresql.org; Wed, 12 Apr 2006 14:49:39 -0400 From: gurkan@resolution.com X-Authentication-Warning: resolution.com: resolutio set sender to gurkan@resolution.com using -f To: pgsql-sql@postgresql.org Subject: SQL help (Informix outer to EnterpriseDB outer) Message-ID: <1144867779.443d4bc3aaee0@www.resolution.com> Date: Wed, 12 Apr 2006 14:49:39 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: IMP/PHP IMAP webmail program 2.2.8 X-Originating-IP: 216.63.139.110 X-Archive-Number: 200604/83 X-Sequence-Number: 24892 Hi all, I have been working on converting our Informix DB to PostgreSQL. There are some differences with SQL syntax. I have done many outer conversion so far, but all has either one outer or simple one. But this one I do not know how to do it. I have searched but could not find similar to what I need. This is the one works on InformixDB (OUTER inv_contracts ) connects to three different tables (1. inv_contracts.inv_id = invention.id AND 2. inv_contracts.con_id = con.id AND 3. inv_contracts.contract_id IN (select id FROM contractDef WHERE phase_id = 2)) -----informix outer ----------- select count(user.id) FROM user, ascpDef AS stateDef, address, invention, user as con , OUTER inv_contracts WHERE address.type = 'User' AND address_id = 1 AND user.id = address.type_id AND state_id = stateDef.id AND invention.user_id = user.id AND invention.inv_number = '1994376-A' AND inv_contracts.inv_id = invention.id AND inv_contracts.con_id = con.id AND inv_contracts.contract_id IN (select id FROM contractDef WHERE phase_id = 2); ------------------------------ If there were only one table connection (say 1. inv_contracts.inv_id = invention.id AND ) I would have done it as (,invention LEFT OUTER JOIN inv_contracts ON inv_contracts.inv_id = invention.id) but I can do same or similar conversion for 2. and 3. I have attempted to do as below but not giving correct count. --------postgres------------------ select count(dbuser.id) FROM dbuser, ascpDef AS stateDef, address --, invention --, dbuser as con --, OUTER inv_contracts --1 --,invention LEFT OUTER JOIN inv_contracts ON inv_contracts.inv_id = invention.id --,dbuser as con LEFT OUTER JOIN inv_contracts ON inv_contracts.con_id = con.id --,contractDef LEFT OUTER JOIN inv_contracts ON inv_contracts.contract_id IN (select id FROM contractDef WHERE phase_id = 2) --1 gives ERROR: table name "inv_contracts" specified more than once -- --2 --,invention LEFT OUTER JOIN inv_contracts ON inv_contracts.inv_id = invention.id --,dbuser as con LEFT OUTER JOIN inv_contracts as inv2 ON inv2.con_id = con.id --,contractDef LEFT OUTER JOIN inv_contracts as inv3 ON inv3.contract_id IN (select id FROM contractDef WHERE phase_id = 2) --2 takes very long (cancelled/stoped by me) (informix returns 306229 within 10sec) --Cancel request sent --ERROR: canceling statement due to user request -- --3 --,inv_contracts LEFT OUTER JOIN invention ON inv_contracts.inv_id = invention.id --,inv_contracts as inv2 LEFT OUTER JOIN dbuser as con ON inv2.con_id = con.id --,inv_contracts as inv3 LEFT OUTER JOIN contractDef ON inv3.contract_id IN (select id FROM contractDef WHERE phase_id = 2) --3 takes very long (cancelled/stoped by me) (informix returns 306229 within 10sec) --Cancel request sent --ERROR: canceling statement due to user request -- --4 ,inv_contracts LEFT OUTER JOIN invention ON inv_contracts.inv_id = invention.id LEFT OUTER JOIN dbuser as con ON inv_contracts.con_id = con.id LEFT OUTER JOIN contractDef ON inv_contracts.contract_id IN (select id FROM contractDef WHERE phase_id = 2) --4 returns 1 but (informix returns 306229 within 10sec) WHERE address.type = 'User' AND address_id = 1 AND dbuser.id = address.type_id AND state_id = stateDef.id AND invention.user_id = dbuser.id AND invention.inv_number = '1994376-A'; ------------------------------- Thanks for help. ------------------------------------------------- This mail sent through IMP: www.resolution.com