Re: select on multiple tables

Поиск
Список
Период
Сортировка
От Rene Pijlman
Тема Re: select on multiple tables
Дата
Msg-id amp2ot4jddiqc25smtte1j40usn8v2eh8k@4ax.com
обсуждение исходный текст
Ответ на RE: select on multiple tables  ("Carterette, Ben" <bcarterette@mail.liberty.k12.mo.us>)
Ответы RE: select on multiple tables
Список pgsql-jdbc
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

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: "Carterette, Ben"
Дата:
Сообщение: RE: select on multiple tables
Следующее
От: "Lucas, Fred"
Дата:
Сообщение: Accessing multiple Databases at the same time