Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 205DA133798E for ; Wed, 11 May 2011 07:24:23 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 28014-03 for ; Wed, 11 May 2011 10:24:16 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qy0-f174.google.com (mail-qy0-f174.google.com [209.85.216.174]) by mail.postgresql.org (Postfix) with ESMTP id 2B7EA133740B for ; Wed, 11 May 2011 07:24:16 -0300 (ADT) Received: by qyk7 with SMTP id 7so2218260qyk.19 for ; Wed, 11 May 2011 03:24:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=sS8OG4GDkdfRH4P7SW273Dz/e+51SbVfQruZwLw9Mn8=; b=X4mbFHK9ExVpIV+fHTm42+wX6YhRnIgxT1Rf0byNGx+NAhnSOuZnpkWyFGKgRRbkCp 3BAvbrgJfNHfk54NpgYp+Kktb7mPBCc7YySpWwDBj68xEgWxZoesuy1UiX+m4T567Aug XE9QvWN+UYP38bea7sBysFvwWrkp5ZLc6cCI0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=HJgC19kJD74+y87HDFM0YSfo41KyUVavwgkoAfKrxkde0HFffHKjzKZK7vJ4fHkLZp In71VB6J2NezlJ1ME4HhrJHqd0ntulkMxGt1maVFQJH22U23GixAexuyyw/4b19IaUwI FHKV14ehTV7JgUrvCWEZwj59iPcm9i8iW41tU= MIME-Version: 1.0 Received: by 10.229.191.207 with SMTP id dn15mr3433414qcb.183.1305109456395; Wed, 11 May 2011 03:24:16 -0700 (PDT) Received: by 10.229.183.16 with HTTP; Wed, 11 May 2011 03:24:16 -0700 (PDT) In-Reply-To: References: Date: Wed, 11 May 2011 18:24:16 +0800 Message-ID: Subject: Re: Question about odbc link to Oracle database from PostgreSQL From: Hsien-Wen Chu To: pgsql-admin@postgresql.org Cc: =?ISO-8859-1?Q?Hans=2DJ=FCrgen_Sch=F6nig?= Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.888 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RFC_ABUSE_POST=0.001, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201105/80 X-Sequence-Number: 37517 Hi Hans many thanks for the answer, my table structure on Oracle, but I still get error as following, Please could show me the correct SQL statement? many many thanks Hsien-Wen SQL> desc test; Name Null? Type ----------------------------------------- -------- -----------------------= ----- USER_NAME VARCHAR2(20) SCORE NUMBER SQL> tora=3D# select odbclink.query(1, 'SELECT USER_NAME,SCORE from test') as result(id int4, USER_NAME text, SCORE decimal); ERROR: syntax error at or near "(" LINE 1: ...y(1, 'SELECT USER_NAME,SCORE from test') as result(id int4, ... ^ tora=3D# select odbclink.query(1, 'SELECT USER_NAME,SCORE from test') as result(USER_NAME text, SCORE decimal); ERROR: syntax error at or near "(" LINE 1: ...y(1, 'SELECT USER_NAME,SCORE from test') as result(USER_NAME... ^ 2011/5/11 Hsien-Wen Chu : > Dear All > > I have a question regarding to odbc link, > > > I had a PostgreSQL database and an Oracle database, now I have created > a dblink to Oracle database base on odbc link. > > > in Oracle database, I created a user named ORATEST, and create a table > named TEST as ORATEST user. > > SQL> select user_name,score from test; > > USER_NAME =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SCORE > -------------------- ---------- > kevin =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A099 > fred =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 98 > > > > > > now I have created the database link to Oracle database over odbc link > and get success. > > > tora=3D# select odbclink.connect('orcl', 'oratest', 'oratest'); > =A0connect > --------- > =A0 =A0 =A0 1 > (1 row) > > tora=3D# select odbclink.connect('DSN=3Dorcl;UID=3Doratest;PWD=3Doratest;= '); > =A0connect > --------- > =A0 =A0 =A0 2 > (1 row) > > tora=3D# select * from odbclink.connections(); > =A0id | connected | dsn =A0| uid =A0| pwd =A0| =A0 =A0 =A0 =A0 =A0 connst= r > ----+-----------+------+------+------+----------------------------- > =A01 | t =A0 =A0 =A0 =A0 | orcl | oratest| oratest| > =A02 | t =A0 =A0 =A0 =A0 | =A0 =A0 =A0| =A0 =A0 =A0| =A0 =A0 =A0| DSN=3Do= rcl;UID=3Doratest;PWD=3Doratest; > =A03 | f =A0 =A0 =A0 =A0 | =A0 =A0 =A0| =A0 =A0 =A0| =A0 =A0 =A0| > =A04 | f =A0 =A0 =A0 =A0 | =A0 =A0 =A0| =A0 =A0 =A0| =A0 =A0 =A0| > > > > > but the problem is that I can not execute the SQL execute it. > > tora=3D# select odbclink.query(1, 'SELECT * FROM test') as > result(user_name text,score number); > ERROR: =A0syntax error at or near "(" > LINE 1: ... odbclink.query(1, 'SELECT * FROM test') as result(user_name..= . > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ^ > tora=3D# select * odbclink.query(1, 'SELECT * FROM test') ; > ERROR: =A0syntax error at or near "odbclink" > LINE 1: select * odbclink.query(1, 'SELECT * FROM test') ; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ^ > tora=3D# select * from odbclink.query(2,'SELECT SYSDATE FROM DUAL'); > ERROR: =A0a column definition list is required for functions returning "r= ecord" > LINE 1: select * from odbclink.query(2,'SELECT SYSDATE FROM DUAL'); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0^ > tora=3D# select * from odbclink.query(1,'SELECT SYSDATE FROM DUAL'); > ERROR: =A0a column definition list is required for functions returning "r= ecord" > LINE 1: select * from odbclink.query(1,'SELECT SYSDATE FROM DUAL'); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0^ > tora=3D# > > > does anyone mind to give me hint? > > > a big thanks > > Hsien-Wen >