SunQuest
           PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
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:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old April 15th, 2008, 05:17 PM
vol7ron vol7ron is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 22 vol7ron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 17 m
Reputation Power: 0
INSERT INTO Syntax

This is more of a syntax question, as I've found the solution while typing it out.

Code:
                     Table "temp.activelist"
  Column   |         Type          |          Modifiers           
-----------+-----------------------+------------------------------
 user      | character varying(25) | not null
 guest     | smallint              | not null default 0::smallint
 time      | integer               | not null
 view      | character varying(10) | 
 boardid   | integer               | 
 messageid | integer               | 
Indexes:
    "activelist_time_idx" btree ("time")
Code:
dbname=# INSERT INTO temp.activelist (time,guest,user) VALUES (2,3,4);
ERROR:  syntax error at or near "user" at character 42
LINE 1: INSERT INTO temp.activelist (time,guest,user) VALUES (2,3,4...
                                                ^
dbname=# INSERT INTO temp.activelist (time,guest,user) VALUES (2,3,'4');   
ERROR:  syntax error at or near "user" at character 42
LINE 1: INSERT INTO temp.activelist (time,guest,user) VALUES (2,3,'...
                                                ^
Code:
dbname=# INSERT INTO temp.activelist ("user",time,guest) VALUES (2, 3,'4');
INSERT 0 1

dbname=# INSERT INTO temp.activelist (time,guest,"user") VALUES (2,3,'4');
INSERT 0 1

dbname=# INSERT INTO temp.activelist ("time","guest","user") VALUES (2,3,4);
INSERT 0 1


The problem occurs when user is not in quotes. Is this a reserved word or is there something else going on?


Thanks for your help.
vol7ron

Reply With Quote
  #2  
Old April 15th, 2008, 05:37 PM
pgFrank's Avatar
pgFrank pgFrank is offline
So help me Codd
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Location: Brazil
Posts: 129 pgFrank User rank is Sergeant (500 - 2000 Reputation Level)pgFrank User rank is Sergeant (500 - 2000 Reputation Level)pgFrank User rank is Sergeant (500 - 2000 Reputation Level)pgFrank User rank is Sergeant (500 - 2000 Reputation Level)pgFrank User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 17 h 45 m 53 sec
Reputation Power: 18
user is a key word, find a better name.
__________________
PostgreSQL-manual

Reply With Quote
  #3  
Old April 15th, 2008, 05:54 PM
vol7ron vol7ron is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 22 vol7ron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 17 m
Reputation Power: 0
I'm installing a forum, so a better name cannot be used.

As you saw in my post, enclosing in quotes will help protect the field, so another name is not necessary.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > INSERT INTO Syntax


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway