X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (mx2.hub.org [200.46.204.254]) by postgresql.org (Postfix) with ESMTP id D1BBD11F696D for ; Wed, 12 Apr 2006 15:45:25 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: -1.503 X-Spam-Level: X-Spam-Status: No, score=-1.503 required=5 tests=[BAYES_00=-2.599, FORGED_RCVD_HELO=0.135, NO_REAL_NAME=0.961] Received: from postgresql.org ([200.46.204.71]) by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) with ESMTP id G7NAZ54W4TzI for ; Wed, 12 Apr 2006 15:45:16 -0300 (ADT) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 53BB211F61E6 for ; Wed, 12 Apr 2006 15:45:15 -0300 (ADT) Received: from resolution.com (unknown [65.18.201.170]) by svr4.postgresql.org (Postfix) with ESMTP id E43D05AF032 for ; Wed, 12 Apr 2006 18:45:15 +0000 (GMT) Received: (from resolutio@localhost) by resolution.com (8.12.10/8.11.2) id k3CIj6PO027365 for pgsql-sql@postgresql.org; Wed, 12 Apr 2006 14:45:06 -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: <1144867506.443d4ab2afcb8@www.resolution.com> Date: Wed, 12 Apr 2006 14:45:06 -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/102 X-Sequence-Number: 24911 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