PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesPostgreSQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 5th, 2012, 08:24 PM
headshotsal headshotsal is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 2 headshotsal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 40 sec
Reputation Power: 0
Insert Fails When multi-row, fine otherwise

I have a lot of records to stuff into the DB (4.5 million). Instead of doing so individual queries, I wrote some Java code that creates batches of inserts out of my flat file. So, my query looks as follows:

Code:
INSERT INTO tempwords(wordID, wordSpelling, soundLocation, level)  SELECT '9341eb48-0b3d-4c7f-8de6-afa1e4843a60', 'fire', 'NOT_CONFIGURED', 0 UNION ALL SELECT '138fe8ec-181d-4ba0-b173-a779b22edb04', 'root', 'NOT_CONFIGURED', 0 UNION ALL SELECT 'f1fe4f78-b41a-44b9-b3f2-b35e9e533a5e', 'woman', 'NOT_CONFIGURED', 0  UNION ALL SELECT 'ca1d2317-e6a8-434c-9d2a-a8affba0b1e0', 'all', 'NOT_CONFIGURED', 0  UNION ALL SELECT '3d6bc860-6a43-4ee4-bb53-7057033f8149', 'drink', 'NOT_CONFIGURED', 0  UNION ALL SELECT 'ee18c4a5-3301-49f8-abd0-fe816a94bf76', 'eat', 'NOT_CONFIGURED', 0  UNION ALL SELECT '6dba8770-9b66-4e45-8baf-7741b86daa0e', 'hear', 'NOT_CONFIGURED', 0  UNION ALL SELECT '88e53f3a-1176-497e-aa5a-0351b9d32312', 'see', 'NOT_CONFIGURED', 0  UNION ALL SELECT 'b8e64614-4a60-416d-8f52-d63478d16aa3', 'bite', 'NOT_CONFIGURED', 0  UNION ALL SELECT '7b6db544-54cf-4dc1-9516-8d75c2f0444a', 'what', 'NOT_CONFIGURED', 0


When I run it that way, PostgreSQL complains saying:

ERROR: column "wordid" is of type uuid but expression is of type text

It also tells me I'll need to re-write or cast the expression. I don't know why or what to do to fix this. However, if I run the same inserts one at a time, I get no complaints.

The following code is the same data as one row of the multi insert query and I insert it with success.

Code:
INSERT INTO tempwords(wordID, wordSpelling, soundLocation, level)  VALUES('9341eb48-0b3d-4c7f-8de6-afa1e4843a60', 'fire', 'NOT_CONFIGURED', 0)


Can someone help me understand what's wrong and how to fix it, please?

Reply With Quote
  #2  
Old July 5th, 2012, 08:33 PM
headshotsal headshotsal is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 2 headshotsal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 40 sec
Reputation Power: 0
I found documentation that shows PostgreSQL does it differently. I've fixed this problem now. SQL syntax is different in PostgreSQL on this one. It is like so, instead:

INSERT INTO tempwords(wordID, wordSpelling, soundLocation, level)
VALUES('9341eb48-0b3d-4c7f-8de6-afa1e4843a60', 'fire', 'NOT_CONFIGURED', 0),
('138fe8ec-181d-4ba0-b173-a779b22edb04', 'root', 'NOT_CONFIGURED', 0),
('f1fe4f78-b41a-44b9-b3f2-b35e9e533a5e', 'woman', 'NOT_CONFIGURED', 0)

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > Insert Fails When multi-row, fine otherwise

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap