473,412 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Postgresql and scripting

I took the white space between characters out of my script 'create.txt4' and
ran it on database 'test'. There were errors:

26
27 -- Create Orders Table
28
29 CREATE TABLE Orders
30 (
31 Order_num int NOT NULL,
32 Order_date datetime NOT NULL,
33 cust_id char(10) NOT NULL
34 );

CREATE TABLE
psql:create.txt4:34: ERROR: type "datetime" does not exist

Does this mean this datatype doesn't exist on this line (34) or that it
doesn't exist at all? If it doesn't exist at all what is the correct
datatype to use here?

Also:

66
67 -- Define Foreign Keys
68 ALTER TABLE OrderItems ADD CONSTRAINT FK_OrderItems_Orders FOREIGN
KEY(order_num) REFERENCE Orders(order_num);
69 ALTER TABLE OrderItems ADD CONSTRAINT FK_OrderItems_Products FOREIGN KEY
(prod_id) REFERENCE Products(prod_id);
70 ALTER TABLE Orders ADD CONSTRAINT FK_Orders_Customers FOREIGN KEY (cust_id)
REFERENCE Customers(cust_id);
71 ALTER TABLE Products ADD CONSTRAINT FK_Products_Vendors FOREIGN KEY
(vend_id) REFERENCE Vendors(vend_id);

generates these errors:
psql:create.txt4:68: ERROR: syntax error at or near "REFERENCE" at character
83
psql:create.txt4:69: ERROR: syntax error at or near "REFERENCE" at character
84
psql:create.txt4:70: ERROR: syntax error at or near "REFERENCE" at character
77
psql:create.txt4:71: ERROR: syntax error at or near "REFERENCE" at character
79

What, where is the syntac error??

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #1
5 2977
Jerome Lyles <su******@hawaii.rr.com> writes:
psql:create.txt4:34: ERROR: type "datetime" does not exist Does this mean this datatype doesn't exist on this line (34) or that it
doesn't exist at all? If it doesn't exist at all what is the correct
datatype to use here?


It doesn't exist at all (any more). That's an obsolete equivalent for
the more standard datatype TIMESTAMP WITH TIME ZONE.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #2
On Wednesday 08 September 2004 02:44 am, ts*******@gmail.com wrote:
Use timestamp instead of datetime.

Where you have "REFERENCE", use "REFERENCES"

Thank you tsarevich that solved it. I'm trying to 'SELECT' out of the tables
now but I'm getting another syntax error:-)

test-# SELECT prod_name FROM Products;
ERROR: syntax error at or near "SELECT" at character 14

What is this error?
Thanks,
Jerome
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,

On Wed, 8 Sep 2004, Jerome Lyles wrote:
Thank you tsarevich that solved it. I'm trying to 'SELECT' out of the tables
now but I'm getting another syntax error:-)

test-# SELECT prod_name FROM Products;
ERROR: syntax error at or near "SELECT" at character 14


test-# SELECT prod_name FROM Products;
^

The dash indicates that another command before this line has been written
but not ended with semicolon. An example:

test=# SELECT
test-# SELECT * from datetest ;
ERROR: syntax error at or near "SELECT" at characte

You should check the previous line.

Regards,

- --
Devrim GUNDUZ
devrim~gunduz.org devrim.gunduz~linux.org.tr
http://www.tdmsoft.com
http://www.gunduz.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFBP1Z4tl86P3SPfQ4RAlw6AKDmamve8PTNClFWnZh/49QxwcsH8wCeM4G3
fEYyFVT5z8DIw5VNgbBudKM=
=TSSn
-----END PGP SIGNATURE-----

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #4
Ben
Dunno about your version of psql, but in mine, the "-#" prompt means that
you haven't finished your statement yet. "=#" means psql is ready to start
accepting a new statement.

On Wed, 8 Sep 2004, Jerome Lyles wrote:
On Wednesday 08 September 2004 02:44 am, ts*******@gmail.com wrote:
Use timestamp instead of datetime.

Where you have "REFERENCE", use "REFERENCES"

Thank you tsarevich that solved it. I'm trying to 'SELECT' out of the tables
now but I'm getting another syntax error:-)

test-# SELECT prod_name FROM Products;
ERROR: syntax error at or near "SELECT" at character 14

What is this error?
Thanks,
Jerome
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #5
On Wednesday 08 September 2004 08:59 am, Devrim GUNDUZ wrote:
Hi,

On Wed, 8 Sep 2004, Jerome Lyles wrote:
Thank you tsarevich that solved it. I'm trying to 'SELECT' out of the
tables now but I'm getting another syntax error:-)

test-# SELECT prod_name FROM Products;
ERROR: syntax error at or near "SELECT" at character 14


test-# SELECT prod_name FROM Products;
^

The dash indicates that another command before this line has been written
but not ended with semicolon. An example:

test=# SELECT
test-# SELECT * from datetest ;
ERROR: syntax error at or near "SELECT" at characte

You should check the previous line.

Regards,


Thanks, I'll remember this. The command I ran before was SELECT test * which
I thought would show me all the tables in test. Running 'SELECT prod_name
FROM Products;' gave me the syntax error and cancelled the previous
instruction. It worked after I ran it again, along withseveral others.
Thanks again to all,
Jerome

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Otis Green | last post by:
Vote for or against a new newsgroup proposal. To summarize what you need to do, just send an empty e-mail to postgresql-ballot@netagw.com You will receive a ballot by e-mail. Follow the...
0
by: Bill J. | last post by:
I have to update a PostgreSQL linked server through MSSQL2K. I first configured the connection with ODBC as follows and I can do queries with no problem: EXEC sp_droplinkedsrvlogin @rmtsrvname...
0
by: Bill J. | last post by:
I have to update a PostgreSQL linked server through MSSQL2K. I first configured the connection with ODBC as follows and I can do queries with no problem: EXEC sp_droplinkedsrvlogin @rmtsrvname...
29
by: Mainlander | last post by:
An ISP I belong to uses Majordomo for their mailing list system. I'd like to encourage them to move to a system that uses a database, preferably psql which they already run on their server....
74
by: John Wells | last post by:
Yes, I know you've seen the above subject before, so please be gentle with the flamethrowers. I'm preparing to enter a discussion with management at my company regarding going forward as either...
7
by: Jerome Lyles | last post by:
I'm trying to create and populate some study tables using a couple of scripts that came with my 'SQL in 10 minutes' book. This is how I tried to run the script to create and populate tables in a...
0
by: Greg Sabino Mullane | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This is a PGP-signed copy of the checksums for following PostgreSQL versions: 7.4.5 7.4.4 7.3.7
0
by: John Wells | last post by:
Guys, I have an opening currently for the following position. If interested, email me at john.wells__replace_this_with_at__timco.aero. Although relo is stated as not covered, I may be able to...
4
by: Erwin Moller | last post by:
Hi, I was surprised to see that my fav. database offers PHP as a scripting language Procedural language (eg stored procedures). Untill now I always used PgPL/SQL for that. Offered by command...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.