General Question

Daisygirl's avatar

MySQL help!

Asked by Daisygirl (377points) September 16th, 2014

What am I doing wrong?

CREATE TABLE MARINA
(MARINA_NUM CHAR(4) PRIMARY KEY,
NAME CHAR(20),
ADDRESS CHAR(15),
CITY CHAR(15),
STATE CHAR(2),
ZIP CHAR(5) );
CREATE TABLE OWNER
(OWNER_NUM CHAR(4) PRIMARY KEY,
LAST_NAME CHAR(50),
FIRST_NAME CHAR(20),
ADDRESS CHAR(15),
CITY CHAR(15),
STATE CHAR(2),
ZIP CHAR(5) );
CREATE TABLE MARINA_SLIP
(SLIP_ID DECIMAL(4,0) PRIMARY KEY,
MARINA_NUM CHAR(4),
SLIP_NUM CHAR(4),
LENGTH DECIMAL(4,0),
RENTAL_FEE DECIMAL(8,2),
BOAT_NAME CHAR(50),
BOAT_TYPE CHAR(50),
OWNER_NUM CHAR(4) );
CREATE TABLE SERVICE_CATEGORY
(CATEGORY_NUM DECIMAL(4,0) PRIMARY KEY,
CATEGORY_DESCRIPTION CHAR(255) );
CREATE TABLE SERVICE_REQUEST
(SERVICE_ID DECIMAL(4,0) PRIMARY KEY,
SLIP_ID DECIMAL(4,0),
CATEGORY_NUM DECIMAL(4,0),
DESCRIPTION CHAR(255),
STATUS CHAR(255),
EST_HOURS DECIMAL(4,2),
SPENT_HOURS DECIMAL(4,2),
NEXT_SERVICE_DATE DATE );
INSERT INTO MARINA
VALUES
(‘1’,‘ALEXAMARA EAST’,‘108 2ND AVE’,‘BRINMAN’,‘FL’,‘32273’);
INSERT INTO MARINA
VALUES
(‘2’,‘ALEXAMARA CENTRAL’,‘283 BRANSTON’,‘W. BRINMAN’,‘FL’,‘32274’);
INSERT INTO OWNER
VALUES
(‘AD57’,‘ADNEY’,‘BRUCE AND JEAN’,‘208 CITRUS’,‘BOWTON’,‘FL’,‘31313’);
INSERT INTO OWNER
VALUES
(‘AN75’,‘ANDERSON’,‘BILL’,‘18 WILCOX’,‘GANDER BAY’,‘FL’,‘31044’);
INSERT INTO OWNER
VALUES
(‘BL72’,‘BLAKE’,‘MARY’,‘2672 COMMODORE’,‘BOWTON’,‘FL’,‘31313’);
INSERT INTO OWNER
VALUES
(‘EL25’,‘ELEND’,‘SANDY AND BILL’,‘462 RIVERSIDE’,‘RIVARD’,‘FL’,‘31062’);
INSERT INTO OWNER
VALUES
(‘FE82’,‘FEENSTRA’,‘DANIEL’,‘7822 COVENTRY’,‘KALEVA’,‘FL’,‘32521’);
INSERT INTO OWNER
VALUES
(‘JU92’,‘JUAREZ’,‘MARIA’,‘8922 OAK’,‘RIVARD’,‘FL’,‘31062’);
INSERT INTO OWNER
VALUES
(‘KE22’,‘KELLY’,‘ALYSSA’,‘5271 WATERS’,‘BOWTON’,‘FL’,‘31313’);
INSERT INTO OWNER
VALUES
(‘NO27’,‘NORTON’,‘PETER’,‘2811 LAKEWOOD’,‘LEWISTON’,‘FL’,‘32765’);
INSERT INTO OWNER
VALUES
(‘SM72’,‘SMELTZ’,‘BECKY AND DAVE’,‘922 GARLAND’,‘GLANDER BAY’,‘FL’,‘31044’);
INSERT INTO OWNER
VALUES
(‘TR72’,‘TRENT’,‘ASHTON’,‘922 CREST’,‘BAY SHORES’,‘FL’,‘31062’);
INSERT INTO MARINA_SLIP
VALUES
(‘1’,‘1’,‘A1’,‘40’,‘3800.00’,‘ANDERSON II’,’SPRITE 4000’,’AN75’);
INSERT INTO MARINA_SLIP
VALUES
(‘2’,’1’,’A2’,’40’,’3800.00’,’OUR TOY’,’RAY 4025’,’EL25’);
INSERT INTO MARINA_SLIP
VALUES
(‘3’,’1’,’A3’,’40’,’3600.00’,’ESCAPE’,’SPRITE 4000’,’KE22’);
INSERT INTO MARINA_SLIP
VALUES
(‘4’,’1’,’B1’,’30’,’2400.00’,’GYPSY’,’DOLPHIN 28’,’JU92’);
INSERT INTO MARINA_SLIP
VALUES
(‘5’,’1’,’B2’,’30’,’2600.00’,’ANDERSON III’,’SPRITE 3000’,’AN75’);
INSERT INTO MARINA_SLIP
VALUES
(‘6’,’2’,’1’,’25’,’1800.00’,’BRAVO’,’DOLPHIN 25’,’AD57’);
INSERT INTO MARINA_SLIP
VALUES
(‘7’,’2’,’2’,’25’,’1800.00’,’CHINOOK’,’DOLPHIN 22’,’FE82’);
INSERT INTO MARINA_SLIP
VALUES
(‘8’,’2’,’3’,’25’,’2000.00’,’LISTY’,’DOLPHIN 25’,’SM72’);
INSERT INTO MARINA_SLIP
VALUES
(‘9’,’2’,’4’,’30’,’2500.00’,’MERMAID’,’DOLPHIN 28’,’BL72’);
INSERT INTO MARINA_SLIP
VALUES
(‘10’,’2’,’5’,’40’,’4200.00’,’AXXON II’,’DOLPHIN 40’,’NO27’);
INSERT INTO MARINA_SLIP
VALUES
(‘11’,’2’,’6’,’40’,’4200.00’,’KARVEL’,’RAY 4025’,’TR72’);
INSERT INTO SERVICE_CATEGORY
VALUES
(‘1’,’ROUTINE ENGINE MAINTENANCE’);
INSERT INTO SERVICE_CATEGORY
VALUES
(‘2’,’ENGINE REPAIR’);
INSERT INTO SERVICE_CATEGORY
VALUES
(‘3’,’AIR CONDITIONING’);
INSERT INTO SERVICE_CATEGORY
VALUES
(‘4’,’ELECTRICAL SYSTEMS’);
INSERT INTO SERVICE_CATEGORY
VALUES
(‘5’,’FIBERGLASS REPAIR’);
INSERT INTO SERVICE_CATEGORY
VALUES
(‘6’,’CANVAS INSTALLATION’);
INSERT INTO SERVICE_CATEGORY
VALUES
(‘7’,’CANVAS REPAIR’);
INSERT INTO SERVICE_CATEGORY
VALUES
(‘8’,’ELECTRONIC SYSTEMS (RADAR, GPS, AUTOPILOTS, ETC.)’ );
INSERT INTO SERVICE_REQUEST
VALUES
(‘1’,’1’,’3’,’Air conditioner stops with code indicating low coolant level. Diagnose and repair.’,’Technocian has verified the problem. Air conditioning specialist has been called.’,’4’,’2’,’2007–7-12’);
INSERT INTO SERVICE_REQUEST
VALUES
(‘2’,’5’,’4’,’Fuse on port motor blown on two occasions. Diagnose and repair.’,’Open’,’2’,’0’,’2007–7-12’);
INSERT INTO SERVICE_REQUEST
VALUES
(‘3’,’4’,’1’,’Oil change and general routine maintenance (check fluid levels, clean sea strainers, etc.)’,’Service call has been scheduled’,’1’,’0’,’2007–7-16’);
INSERT INTO SERVICE_REQUEST
VALUES
(‘4’,’1’,’2’,’Engine oil level has been dropping off drastically. Diagnose and repair’,’Open’,’2’,’0’,’2007–7-13’);
INSERT INTO SERVICE_REQUEST
VALUES
(‘5’,’3’,’5’,’Open pockets at the base of two stantions.’,’Technician has completed the initial filling of the open pockets. Will complete the job after initial fill has had sufficient time to dry.’,’4’,’2’,’2007–7-13’);
INSERT INTO SERVICE_REQUEST
VALUES
(‘6’,’11’,’4’,’Electronic-flush system periodically stops functioning. Diagnose and repair.’,’Open’,’3’,’0’,‘2010–12-31’);
INSERT INTO SERVICE_REQUEST
VALUES
(‘7’,’6’,’2’,’Engine overheating. Loss of coolant. Diagnose and repair.’,’Open’,’2’,’0’,’2007–7-13’);
INSERT INTO SERVICE_REQUEST
VALUES
(‘8’,’6’,’2’,’Heater exchanger not operating correctly’,’Technician has determined that the exchanger is faulty. New exchanger has been ordered.’,’4’,’1’,’2007–7-17’);
INSERT INTO SERVICE_REQUEST
VALUES
(‘9’,’7’,’6’,’Canvas severely damaged in windstorm. Order and install new canvas’,’Open’,’8’,’0’,’2007–7-16’);
INSERT INTO SERVICE_REQUEST
VALUES
(‘10’,’2’,’8’,’Install new GPS and chart plotter’,’Scheduled’,’7’,’0’,’2007–7-12’);
INSERT INTO SERVICE_REQUEST
VALUES
(‘11’,’2’,’3’,’Air conditioning unit shuts down with HHH showing on the control panel’,’Technician not able to replicate the problem. Air conditioning unit ran fine through multiple tests. Owners to notify the technician if the problems recurs.’,’1’,’1’,‘2010–12-31’);
INSERT INTO SERVICE_REQUEST
VALUES
(‘12’,’4’,’8’,’Both speed and depth readings on data are significantly less then the owner thinks it should be’,’Technician has scheduled appointment with owner to attempt to verify the problem’,’2’,’0’,’2007–7-16’);
INSERT INTO SERVICE_REQUEST
VALUES
(‘13’,’8’,’2’,’Customer describes engine as making a clattering sound’,’Technician suspects problem with either propellar or shaft and has scheduled the boat to be pulled from the water for further investigation’,’5’,’2’,’2007–7-12’);
INSERT INTO SERVICE_REQUEST
VALUES
(‘14’,’7’,’5’,’Owner accidnet caused damage to forward portion of port side’,’Technician has scheduled repair’,’6’,’0’,’2007–7-13’);
INSERT INTO SERVICE_REQUEST
VALUES
(‘15’,’11’,’7’,’Canvas leaks around zippers in heavy rain. Install overlap around zippers to prevent leaks’,’Overlap has been created. Installation has been scheduled’,’8’,’3’,’2007–7-17’);

Query OK, 0 rows affected (0.10 sec)

Query OK, 0 rows affected (0.10 sec)

Query OK, 0 rows affected (0.07 sec)

Query OK, 0 rows affected (0.09 sec)

Query OK, 0 rows affected (0.07 sec)

Query OK, 1 row affected (0.03 sec)

Query OK, 1 row affected (0.04 sec)

Query OK, 1 row affected (0.03 sec)

Query OK, 1 row affected (0.04 sec)

Query OK, 1 row affected (0.04 sec)

Query OK, 1 row affected (0.03 sec)

Query OK, 1 row affected (0.03 sec)

Query OK, 1 row affected (0.04 sec)

Query OK, 1 row affected (0.03 sec)

Query OK, 1 row affected (0.03 sec)

Query OK, 1 row affected (0.03 sec)

Query OK, 1 row affected (0.03 sec)

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 ‘2010-
12–31’);
INSERT INTO SERVICE_REQUEST
VALUES
(æ7Æ,Æ6Æ,Æ2Æ,ÆEngine overheatin’ at line 3
mysql>

Observing members: 0 Composing members: 0

9 Answers

CWOTUS's avatar

You spelled “propeller” wrong, for one thing.

Table SERVICE_REQUEST has a primary key, SERVICE_ID, which is a DECIMAL field. In your attempt to load the table with the error record, the secondary key value you attempted to insert for SERVICE_ID, ‘7’ is a CHAR value. That’s a show-stopper.

funkdaddy's avatar

It’s hard to tell what formatting issues might be caused by fluther’s editor and what might be in your text. For example a lot of the dates seem to use different hyphen characters, which I’m assuming is caused by fluther being helpful and not intended for code.

That said usually it comes down to a special character or quotes not lining up properly. Make sure you’re pasting as plain text, using only single and double quotes. No curly quotes, no fancy formatting. You’re error message includes special characters, so I’d say it’s choking on those.

If that’s not it…

Two clues that might help, you’ve got the error message, that seems to point to the couple of lines below

INSERT INTO SERVICE_REQUEST
VALUES
(‘6’,’11’,’4’,’Electronic-flush system periodically stops functioning. Diagnose and repair.’,’Open’,’3’,’0’,‘2010–12–31’);
INSERT INTO SERVICE_REQUEST
VALUES
(‘7’,’6’,’2’,’Engine overheating. Loss of coolant. Diagnose and repair.’,’Open’,’2’,’0’,’2007–7–13’);

1) take out the hyphen in “Electronic-flush” (or escape it)... hyphen aren’t usually special characters, but it stands out and I don’t know what version of mysql you’re using
2) triple-check my quotes around the ‘7’,‘6’,‘2’ in the second line. They’re different here, but again, I’m not sure if that’s fluther causing the problem.

The other section to look at is you seem to get through 12 insert queries just fine, so the 13th is the first that puts anything into the MARINA_SLIP table

INSERT INTO MARINA_SLIP
VALUES
(‘1’,‘1’,‘A1’,‘40’,‘3800.00’,‘ANDERSON II’,’SPRITE 4000’,’AN75’);

So you may want to double check that line as well

Daisygirl's avatar

@CWOTUS – Ok, fixed the spelling error, but the book insists that I use a decimal value instead of a char value in that set. I assume since I’m the only one that can’t get past week 3’s assignment (yeah, we’re on week 5 now and I’m still stuck) that that error is acceptable.

@funkdaddy I took the hyphen out and triple checked the section again. Still getting the same error. I have the file in a plain text form so everything shown here is exactly what is on my notepad. Even the weird ”æ7Æ,Æ6Æ,Æ2Æ,Æ” is the same error I get in both MySQL and my notepad.

I’m so frustrated with this, this is my first programming class and I’m so lost!

LostInParadise's avatar

It looks good to me. Did you by any chance put a carriage return inside the quote? That could cause problems.

funkdaddy's avatar

If the error message is exactly as you pasted it here when you run it in the command line, you’re single quotes aren’t single quotes and appear to be different from one another.

Replace them manually and it should run, or at least go forward to the next error.

CWOTUS's avatar

@Daisygirl I’m afraid I may not have been clear enough in my statement.

I have no problem with the table’s primary key being a decimal value, and I would agree with that choice, but it seems to me that when you attempted to load ‘7’, you’re loading it as a character, not as a number. If you were going to load it as a number then you’d be doing that without the single-quote marks to bracket it.

In other words: LOAD 7 is not the same as LOAD ‘7’. The first statement, without the quote marks, will load 7 as a number value, and the second will load it as a character.

Daisygirl's avatar

Hey all!
I got a response from my teacher and @funkdaddy had the correct solution. I had to go back through and redo all of my quotes because when I loaded the text into word to correct a bunch of mistakes (which I thought doing find/replace would be quicker) Microsoft word changed my single quotes from ’ to ‘. Doesn’t look like much to me, but if you look at the first example ‘1’ then I guess there is a difference, and the program knows the difference and it doesn’t likey one bit. Thanks so much for everyone’s help! I won’t end up dropping the class and setting fire to the demon spawn book after all.

funkdaddy's avatar

@CWOTUS – mysql is really good at type conversion, it’s not the fastest way if you’re running thousands of queries, but it won’t error out for numbers delivered as strings (just if you’re interested, not correcting so much as pointing to the reference)

@Daisygirl – did you teacher recommend a tool for programming? There are some amazing ones and they will help you catch things like this and save you hours of frustration. Most are free, or free for students, and they usually tie into whatever programming language you’re using.

JetBrains makes some really good tools with a low learning curve initially but tons included that will be handy as you learn more. They’re ~$30 for students and worth all that and more.

Really just never let code touch Word or other word processors, it never comes out right.

Good luck with the class.

CWOTUS's avatar

Thanks, @funkdaddy. I’m not (yet) a MySQL user, but I’ve used Oracle’s PL/SQL and SQL-Plus – and managed bulk data uploads via Excel macros as a rule.

Excellent advice to avoid “word processors” and code. Yikes; I hadn’t even thought of that.

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther