473,569 Members | 2,991 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.txt 4: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_O rders FOREIGN
KEY(order_num) REFERENCE Orders(order_nu m);
69 ALTER TABLE OrderItems ADD CONSTRAINT FK_OrderItems_P roducts FOREIGN KEY
(prod_id) REFERENCE Products(prod_i d);
70 ALTER TABLE Orders ADD CONSTRAINT FK_Orders_Custo mers FOREIGN KEY (cust_id)
REFERENCE Customers(cust_ id);
71 ALTER TABLE Products ADD CONSTRAINT FK_Products_Ven dors FOREIGN KEY
(vend_id) REFERENCE Vendors(vend_id );

generates these errors:
psql:create.txt 4:68: ERROR: syntax error at or near "REFERENCE" at character
83
psql:create.txt 4:69: ERROR: syntax error at or near "REFERENCE" at character
84
psql:create.txt 4:70: ERROR: syntax error at or near "REFERENCE" at character
77
psql:create.txt 4: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*******@postg resql.org

Nov 23 '05 #1
5 2993
Jerome Lyles <su******@hawai i.rr.com> writes:
psql:create.txt 4: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.o rg devrim.gunduz~l inux.org.tr
http://www.tdmsoft.com
http://www.gunduz.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFBP1Z4tl8 6P3SPfQ4RAlw6AK Dmamve8PTNClFWn Zh/49QxwcsH8wCeM4G 3
fEYyFVT5z8DIw5V NgbBudKM=
=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
2162
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 instructions and vote. _______________________________________________________________________ FIRST CALL FOR VOTES (of 2)
0
3840
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 = 'PostgreSQL', @locallogin = NULL GO EXEC sp_DropServer 'PostgreSQL' GO
0
2165
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 = 'PostgreSQL', @locallogin = NULL GO EXEC sp_DropServer 'PostgreSQL' GO
29
3138
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. Anything out there in Php?
74
7904
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 a MySql shop or a Postgresql shop. It's my opinion that we should be using PG, because of the full ACID support, and the license involved. A...
7
382
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 database named test: test-# \i create.txt psql:create.txt:1: ERROR: syntax error at or near "" at character 1 Here is the top of the script:...
0
1641
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
1418
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 fight for that given a very qualified candidate. Company: TIMCO Aviation Services Location: US-NC-Greensboro Base Pay: N/A
4
2369
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 prompt: http://www.commandprompt.com/community/plphp/ Did anybody in here use it?
0
8138
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7679
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6287
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3657
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2117
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
946
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.