Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 25th, 2007, 10:25 PM   #1
paulchwd
Hobbyist Programmer
 
paulchwd's Avatar
 
Join Date: Mar 2005
Posts: 139
Rep Power: 4 paulchwd is on a distinguished road
Question MySql Error

Hello All,

I cant seem to find any problems with this code, but MySQl throws a fit when I run it (lol)

--Invoice Database 

drop table description;
drop table invoice;
drop table website;
drop table customer;


CREATE TABLE Customer
(customerID   char(3)  Primary Key,
firstName     char(30),
lastName      char(30), 
company       char(50),
streetNumber  char(10),
streetName    char(30),
city          char(20),
prov          char(20),
postal        char(7),      
phone         char(14),      
phone2        char(14),     
cell          char(14),      
home          char(14),      
fax           char(14),      
customerDate  date     NOT NULL,
domain        char(40) REFERENCES website (domain));


CREATE TABLE website
(domain         char(40) PRIMARY KEY,
customerID      char(3)  REFERENCES Customer (customerID),
dateRegistered  date     NOT NULL,
dateExpires     date     NOT NULL,
amountPaid      number(6,2));


CREATE TABLE invoice
(invoiceNumber char(4)     PRIMARY KEY,
customerID     char(3)     REFERENCES customer (customerID),
dateIssued     date        NOT NULL,
dateDue        date        NOT NULL,
datePaid       date,
status         char(10)    CHECK (status IN ('paid','unpaid','part-paid')) NOT NULL,
descriptionID  char(4)     REFERENCES description (descriptionID) NOT NULL,
subTotal       number(6,2) NOT NULL,
PSTexempt      char(3),     
totalPST       number(6,2)
totalDue       number(6,2) NOT NULL,
comments       varchar2(3000));


CREATE TABLE description
(descriptionID char(4)        PRIMARY KEY,
invoiceNumber  char(4)        REFERENCES invoice(invoiceNumber) NOT NULL,
product        varchar2(1000) NOT NULL,
price          number(6,2)    NOT NULL,
PSTexempt      char(3)        CHECK (PSTexempt IN ('yes','no')) NOT NULL,
PSTamount      number(6,2));


Details:
MySql 5.027

Errors:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'number(6,2))' at line 6


ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL,descriptionID char(4) REFERENCES description (descriptionID) NOT NUL' at line 7


ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT NULL, product varchar2(1000) NOT NULL, price number(6,2) ' at line 3
paulchwd is offline   Reply With Quote
Old Feb 25th, 2007, 10:59 PM   #2
Mocker
Hobbyist Programmer
 
Mocker's Avatar
 
Join Date: Oct 2005
Location: Indiana
Posts: 218
Rep Power: 0 Mocker is an unknown quantity at this point
Send a message via AIM to Mocker
What is a number() data type? I've never heard of it
__________________
#programmingforums relay - http://thegupstudio.com/cgi-bin/pforelay.cgi
freelance scripts - http://ryanguthrie.com/index.html
Mocker is offline   Reply With Quote
Old Feb 25th, 2007, 11:30 PM   #3
paulchwd
Hobbyist Programmer
 
paulchwd's Avatar
 
Join Date: Mar 2005
Posts: 139
Rep Power: 4 paulchwd is on a distinguished road
Question 1 problem fixed

Thanks, your right, apparently number isn't a data type (although it is in Oracle). And I changed the varchar2 cols to text

but i still get the following errors:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near 'NULL,
descriptionID char(4) REFERENCES description (descriptionID) NOT NUL' at line 7


ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near 'NOT NULL,
product TEXT NOT NULL,
price DECIMAL(6,2) ' at line 3


changed code:

--Invoice Database 

drop table description;
drop table invoice;
drop table website;
drop table customer;


CREATE TABLE Customer
(customerID   char(3)  Primary Key,
firstName     char(30),
lastName      char(30), 
company       char(50),
streetNumber  char(10),
streetName    char(30),
city          char(20),
prov          char(20),
postal        char(7),      
phone         char(14),      
phone2        char(14),     
cell          char(14),      
home          char(14),      
fax           char(14),      
customerDate  date     NOT NULL,
domain        char(40) REFERENCES website (domain));


CREATE TABLE website
(domain         char(40) PRIMARY KEY,
customerID      char(3)  REFERENCES Customer (customerID),
dateRegistered  date     NOT NULL,
dateExpires     date     NOT NULL,
amountPaid      DECIMAL(6,2));


CREATE TABLE invoice
(invoiceNumber char(4)     PRIMARY KEY,
customerID     char(3)     REFERENCES customer (customerID),
dateIssued     date        NOT NULL,
dateDue        date        NOT NULL,
datePaid       date,
status         char(10)    CHECK (status IN ('paid','unpaid','part-paid')) NOT NULL,
descriptionID  char(4)     REFERENCES description (descriptionID) NOT NULL,
subTotal       DECIMAL(6,2) NOT NULL,
PSTexempt      char(3),     
totalPST       DECIMAL(6,2)
totalDue       DECIMAL(6,2) NOT NULL,
comments       TEXT);


CREATE TABLE description
(descriptionID char(4)        PRIMARY KEY,
invoiceNumber  char(4)        REFERENCES invoice(invoiceNumber) NOT NULL,
product        TEXT           NOT NULL,
price          DECIMAL(6,2)   NOT NULL,
PSTexempt      char(3)        CHECK (PSTexempt IN ('yes','no')) NOT NULL,
PSTamount      DECIMAL(6,2));

Last edited by paulchwd; Feb 25th, 2007 at 11:46 PM.
paulchwd is offline   Reply With Quote
Old Feb 26th, 2007, 4:03 PM   #4
paulchwd
Hobbyist Programmer
 
paulchwd's Avatar
 
Join Date: Mar 2005
Posts: 139
Rep Power: 4 paulchwd is on a distinguished road
Any thoughts anybody ? Thanks
paulchwd is offline   Reply With Quote
Old Feb 26th, 2007, 11:39 PM   #5
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 383
Rep Power: 4 xavier is on a distinguished road
Send a message via Yahoo to xavier
drop table description;
drop table invoice;
drop table website;
drop table customer;


CREATE TABLE Customer
(customerID   char(3)  Primary Key,
firstName     char(30),
lastName      char(30),
company       char(50),
streetNumber  char(10),
streetName    char(30),
city          char(20),
prov          char(20),
postal        char(7),      
phone         char(14),      
phone2        char(14),     
cell          char(14),      
home          char(14),
fax           char(14),
customerDate  date     NOT NULL,
domain        char(40) REFERENCES website (domain));


CREATE TABLE website
(domain         char(40) PRIMARY KEY,
customerID      char(3)  REFERENCES Customer (customerID),
dateRegistered  date     NOT NULL,
dateExpires     date     NOT NULL,
amountPaid      DECIMAL(6,2));


CREATE TABLE invoice
(invoiceNumber char(4)     PRIMARY KEY,
customerID     char(3)     REFERENCES customer (customerID),
dateIssued     date        NOT NULL,
dateDue        date        NOT NULL,
datePaid       date,
status_         char(10)   NOT NULL CHECK (status IN ('paid','unpaid','part-paid')),
descriptionID  char(4)     NOT NULL REFERENCES description (descriptionID) ,
subTotal       DECIMAL(6,2) NOT NULL,
PSTexempt      char(3),
totalPST       DECIMAL(6,2),
totalDue       DECIMAL(6,2) NOT NULL,
comments       TEXT);


CREATE TABLE description
(descriptionID char(4)        PRIMARY KEY,
invoiceNumber  char(4)        NOT NULL REFERENCES invoice(invoiceNumber) ,
product        TEXT           NOT NULL,
price          DECIMAL(6,2)   NOT NULL,
PSTexempt      char(3)        NOT NULL CHECK (PSTexempt IN ('yes','no')) ,
PSTamount      DECIMAL(6,2));

NOT NULL goes in front of CHECK or REFERENCES - this will help you : http://dev.mysql.com/doc/refman/5.0/...ate-table.html
__________________
Don't take life too seriously, it's not permanent !
xavier is offline   Reply With Quote
Old Feb 27th, 2007, 10:51 AM   #6
paulchwd
Hobbyist Programmer
 
paulchwd's Avatar
 
Join Date: Mar 2005
Posts: 139
Rep Power: 4 paulchwd is on a distinguished road
Exclamation

Thanks, i got rid of one of the errors, there is still one left though

new code:
--Invoice Database 

drop table description;
drop table invoice;
drop table website;
drop table customer;


CREATE TABLE Customer
(customerID   char(3)  Primary Key,
firstName     char(30),
lastName      char(30), 
company       char(50),
streetNumber  char(10),
streetName    char(30),
city          char(20),
prov          char(20),
postal        char(7),      
phone         char(14),      
phone2        char(14),     
cell          char(14),      
home          char(14),      
fax           char(14),      
customerDate  date     NOT NULL,
domain        char(40) REFERENCES website (domain));


CREATE TABLE website
(domain         char(40) PRIMARY KEY,
customerID      char(3)  REFERENCES Customer (customerID),
dateRegistered  date     NOT NULL,
dateExpires     date     NOT NULL,
amountPaid      DECIMAL(6,2));


CREATE TABLE invoice
(invoiceNumber char(4)      PRIMARY KEY,
customerID     char(3)      REFERENCES customer (customerID),
dateIssued     date         NOT NULL,
dateDue        date         NOT NULL,
datePaid       date,
invStatus      char(10)     NOT NULL CHECK (status IN ('paid','unpaid','part-paid')),
descriptionID  char(4)      NOT NULL REFERENCES description (descriptionID),
subTotal       DECIMAL(6,2) NOT NULL,
PSTexempt      char(3),     
totalPST       DECIMAL(6,2)
totalDue       DECIMAL(6,2) NOT NULL,
invComments       TEXT);


CREATE TABLE description
(descriptionID char(4)        PRIMARY KEY,
invoiceNumber  char(4)        NOT NULL REFERENCES invoice(invoiceNumber),
product        TEXT           NOT NULL,
price          DECIMAL(6,2)   NOT NULL,
PSTexempt      char(3)        NOT NULL CHECK (PSTexempt IN ('yes','no')),
PSTamount      DECIMAL(6,2));

Error

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near 'totalDue DECIMAL(6,2) NOT NULL,
invComments TEXT)' at line 12
Query OK, 0 rows affected (0.02 sec)
paulchwd is offline   Reply With Quote
Old Feb 27th, 2007, 1:00 PM   #7
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 383
Rep Power: 4 xavier is on a distinguished road
Send a message via Yahoo to xavier
If you copy paste my exact code, you'll have no error. Also, how about looking at the error yourself ? You're missing a comma at line 11
__________________
Don't take life too seriously, it's not permanent !
xavier is offline   Reply With Quote
Old Feb 27th, 2007, 1:19 PM   #8
paulchwd
Hobbyist Programmer
 
paulchwd's Avatar
 
Join Date: Mar 2005
Posts: 139
Rep Power: 4 paulchwd is on a distinguished road
Oh I cant thank you enough Xavier. Really appreciate it. Sufficed to say i got a clean run
paulchwd is offline   Reply With Quote
Old Feb 27th, 2007, 1:37 PM   #9
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 383
Rep Power: 4 xavier is on a distinguished road
Send a message via Yahoo to xavier
No problem, but it would help you more if you have the patience to check out the documentation. Best of luck to you
__________________
Don't take life too seriously, it's not permanent !
xavier is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
syntax error in Mysql... ktsirig PHP 1 Feb 3rd, 2007 1:30 PM
Header file internal errors kruptof Coder's Corner Lounge 2 Jan 14th, 2007 1:12 PM
C# corruption!!! Kilo C++ 32 May 21st, 2006 8:44 PM
Masm rsnd Assembly 4 May 20th, 2006 9:05 PM
libraries matko C 1 Jan 22nd, 2006 2:12 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:29 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC