Attribute 'tablecolumn' not found and converting current.timestamp to current.date

Поиск
Список
Период
Сортировка
От Poul Kristensen
Тема Attribute 'tablecolumn' not found and converting current.timestamp to current.date
Дата
Msg-id 3AA79A75.E389EA83@vip.cybercity.dk
обсуждение исходный текст
Список pgsql-novice
Hi there,

I don't know if this is the right list but I don't know whereelse to
ask.

I'm a very novice getting table data from PG 7.0.2 using java.

I have this sql statement

"select Id, Titel, Description, FromDate, ToDate from tablename where
FromDate <=current.timestamp and   ToDate >=current.timestamp"

the FromDate and the ToDate are timestamp fields.

and get the following error => attribute "Id" not found.

I understand that PG   is case sensitive.


Next problem:

Is it possible to convert/ format  the selected timestamp field to a
date format within the
sqlstatement or should it be done in java?

Could you give me a hint of how to do this?

TIA

Poul

Here is the program - sorry if some syntaxsproblem - I had troubles
copyind into Netscape.


import java.io.*;
import java.util.Enumeration;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.net.*;

public class
testservlet extends HttpServlet{ Connection theConnection; private
ServletConfig config;

public void init(ServletConfig config) throws
ServletException{ this.config=config; }

public void service (HttpServletRequest req, HttpServletResponse res)
throws ServletException,
IOException {

HttpSession session = req.getSession(true);

res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("");
out.println("");
out.println("");
out.println("List");
out.println("");
out.println("");
out.println("");
out.println("");
out.println("");
out.println("");
try{
//Loading Sun's JDBC ODBC Driver
  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//Class.forName("postgresql.Driver");
//Connect to db Data source theConnection =
         DriverManager.getConnection("jdbc:odbc:pg");
Statement
theStatement=theConnection.createStatement();
ResultSet
  theResult=theStatement.executeQuery("select  Id, Titel, Description,
FromDate,ToDate from tablename where OnlineFra <= current.timestamp and
OnlineTil >= current.timestamp");
     //Select all records
//Fetch all the records and print in table
while(theResult.next()){
out.println();
out.println("some html");
 out.println("");
out.println("");
out.println("");
String s=theResult.getString(5);
out.println("");
out.println(""); }
theResult.close();
//Close the result
          set theStatement.close();
//Close statement theConnection.close();
//Close database Connection }
catch(Exception e){
                           out.println(e.getMessage());
//Print trapped error. }
out.println("some html
                column1
                                   column2
                                                      column3
                " + theResult.getString(2) + "
                                   " + theResult.getString(3) + "
                                                      " +
theResult.getString(4) + "

" + s + ">


"); out.println("



"); } public void destroy(){ } }


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

Предыдущее
От: Catalin CIOCOIU
Дата:
Сообщение: PGSQL vs Interbase
Следующее
От: "Daniel A. Melo"
Дата:
Сообщение: compilation error