From: | "Dave Cramer" <Dave(at)micro-automation(dot)net> |
---|---|
To: | <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | RE: select on multiple tables |
Date: | 2001-08-21 00:11:37 |
Message-ID: | 00cf01c129d5$d83bb8d0$c201a8c0@inspiron |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Unfortunately id doesn't return A.c and B.c. Try it in psql...
One way to solve this is to fix the backend to return fully qualified
column names.
Dave
-----Original Message-----
From: pgsql-jdbc-owner(at)postgresql(dot)org
[mailto:pgsql-jdbc-owner(at)postgresql(dot)org] On Behalf Of Rene Pijlman
Sent: August 20, 2001 3:49 PM
To: Carterette, Ben
Cc: 'pgsql-jdbc(at)postgresql(dot)org'
Subject: Re: [JDBC] select on multiple tables
On Mon, 20 Aug 2001 12:50:22 -0500, you wrote:
>The SELECT is in a servlet, something like this:
>
>rs = stmt.executeQuery("SELECT * FROM " +
>request.getParameter("table1") + ", " +
>request.getParameter("table2")); session.setAttribute("result", rs);
>request.sendRedirect(request.getParameter("page2"));
>
>that's a simplification of what it does, but it's good enough for
>demonstration I think.
>
>The .jsp file that calls the servlet knows what tables it wants to read
>out of, and the .jsp file that the servlet redirects to knows what
>columns it wants. The servlet doesn't know anything and hopefully
>shouldn't care. I wanted to abstract it as much as possible.
How about using ResultSetMetaData.getColumnName() on the ResultSet to
dynamically query the column names? See:
http://java.sun.com/j2se/1.3/docs/api/java/sql/ResultSetMetaData.html
I don't know that this will (and should) return when you do SELECT *
from A, B and there is a column c in both tables. Hopefully it returns
A.c and B.c.
Regards,
René Pijlman
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
message can get through to the mailing list cleanly
From | Date | Subject | |
---|---|---|---|
Next Message | Steve Wampler | 2001-08-21 14:46:08 | Re: Unable to connect to database |
Previous Message | Rene Pijlman | 2001-08-20 22:57:22 | Re: Accessing multiple Databases at the same time |