2 Replies - 2164 Views - Last Post: 22 April 2009 - 06:27 AM Rate Topic: -----

#1 Jupiter   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 01-February 07

Problem with select date from a table in PostgreSQL

Posted 22 April 2009 - 01:40 AM

Hi to all reading this topic B)

Actually im getting an error which myself dont understand why im getting this. :huh:

Table Schema:

salesorder{ordernum, orderdte, libid, clerkid, deliverydte}

Code to create table salesorder:

CREATE TABLE salesorder
(
  ordernum integer NOT NULL,
  "OrderDte" date NOT NULL,
  libid integer NOT NULL,
  clerkid integer NOT NULL,
  "DeliveryDte" date NOT NULL,
  CONSTRAINT saleorder_pkey PRIMARY KEY (ordernum)
)



Populated with values:
ordernum: 13456
orderdate: 2009-04-02
libid: 244326
clerkid: 456
deliverydte: 2009-04-23

select statement:
select orderdte from salesorder where ordernum=13456;

Error:
ERROR:  column "orderdte" does not exist
LINE 11: select orderdte from salesorder where ordernum=13456;
				^

********** Error **********

ERROR: column "orderdte" does not exist
SQL state: 42703
Character: 234


well it is clear that this column exist but i dont know why im getting this :crazy:

Please help me... is my code for creating the table ok? :/
or how do i select the date? :huh:

Btw, im using PostgreSQL.
Thanks in advance ;)

This post has been edited by Jupiter: 22 April 2009 - 06:30 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Problem with select date from a table in PostgreSQL

#2 Trogdor   User is offline

  • D.I.C Addict
  • member icon

Reputation: 15
  • View blog
  • Posts: 627
  • Joined: 06-October 06

Re: Problem with select date from a table in PostgreSQL

Posted 22 April 2009 - 05:35 AM

If postgresql gets a capital letter or anything else then lowercaseletters, numbers and the _ character when defining a table, it will mark the fieldname as 'weird' and put quotes around it.
You need to use those quotes in your query:
select "OrderDte" from salesorder where ordernum=13456;
Was This Post Helpful? 1
  • +
  • -

#3 Jupiter   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 01-February 07

Re: Problem with select date from a table in PostgreSQL

Posted 22 April 2009 - 06:27 AM

CREATE TABLE tsalesorder
(
  oid integer NOT NULL,
  odte date NOT NULL,
  libid integer NOT NULL,
  clerkid integer NOT NULL,
  ddte date NOT NULL
);



ahh ok..now i've understand why when ived changed the field's name "OrderDte" and "DeliveryDte" to odte and ddte respectively [to small case] and excuting the query its ok now

Well thanks a lot for ur help..ive learn sth new today :D

This post has been edited by Jupiter: 22 April 2009 - 06:29 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1