Solved

Error Executing Database Query. Syntax error: Encountered "(" at line 10, column 37.

Posted on 2015-02-02
6
125 Views
Last Modified: 2015-02-08
I have to learn cold fusion for and upcoming project ... I'm trying to set up a simple database coldfsion11 apache derby embedded (I have no experience with apache derby) ... But I keep getting the same syntax error ... maybe a fresh set of eyes can tell me what I am doing wrong


 Error Executing Database Query.
Syntax error: Encountered "(" at line 10, column 37.
 
The error occurred in C:/ColdFusion11/cfusion/wwwroot/SRPT/DatabaseCreator.cfc: line 80
Called from C:/ColdFusion11/cfusion/wwwroot/SRPT/createdatabase.cfm: line 7
Called from C:/ColdFusion11/cfusion/wwwroot/SRPT/DatabaseCreator.cfc: line 80
Called from C:/ColdFusion11/cfusion/wwwroot/SRPT/createdatabase.cfm: line 7

78 : 		<cffunction name="createevent" access="public" returnType="String" >
79 : 			<cfset  droptable('locTab')>
80 : 		<cfquery datasource = "Reports">
81 : 		CREATE TABLE
82 : 			 locationTable(loctabID INTEGER
                                                    NOT NULL 
                                                 GENERATED ALWAYS AS IDENTITY,

<cffunction name="createevent" access="public" returnType="String" >
			<cfset  droptable('locTab')>
		<cfquery datasource = "Reports">
		CREATE TABLE
			 locationTable(loctabID INTEGERS NOT NULL GENERATED ALWAYS AS IDENTITY,
		    	usersID VARCHAR(50),
		    	WawaID VARCHAR(50),
		    	AccesLevel VARCHAR(50),
		    	date VARCHAR(50),
		    	name VARCHAR(50),
		    	postalcode VARCHAR(50),
		    	city VARCHAR(50),
		    	state VARHAR(50),
		    	zip VARCAHR(50))
			
		</cfquery>
			</cffunction>


 Error Executing Database Query.
Syntax error: Encountered "(" at line 10, column 43.
 
The error occurred in C:/ColdFusion11/cfusion/wwwroot/SRPT/DatabaseCreator.cfc: line 123
Called from C:/ColdFusion11/cfusion/wwwroot/SRPT/createdatabase.cfm: line 9
Called from C:/ColdFusion11/cfusion/wwwroot/SRPT/DatabaseCreator.cfc: line 123
Called from C:/ColdFusion11/cfusion/wwwroot/SRPT/createdatabase.cfm: line 9

121 : 			
122 : 		
123 : 		<cfquery datasource="Reports">
124 : 		CREATE TABLE
125 : 			Patient(PatientID INTEGER

<cffunction name="createincident" access="public" returntype="String" >
			
		
		<cfquery datasource="Reports">
		CREATE TABLE
			Incident (IncidentID INTEGER
				NOT NULL
			    GENERATED BY DEFAULT AS IDENTITY (START WITH 53)
		    	CONSTRAINT Incident_PK PRIMARY KEY,
		    	usersID VARCHAR(50),
		    	WawaID VARCHAR(50),
		    	loctabID VARCHAR(50),
		    	AccesLevel VARCHAR(50),
		    	date VARCHAR(50),
		    	time VARCHAR(50),
		    	incident_num VARCHAR(50),
		    	lastname VARCHAR(50),
		    	firstname VARCHAR(50)
		    	
			)
		</cfquery>
		
		
		</cffunction>

Open in new window

0
Comment
Question by:dolamitejenkins
  • 3
  • 2
6 Comments
 
LVL 39

Expert Comment

by:gdemaria
ID: 40585439
I don't even know if you can create a table through coldfusion - do you have "create" checked off for the data source in the CFIDE/Administrator?

Depending on which database there are some things I wonder if are legal, you're using "date" and "time" as column names, that may be reserved words.

I think it's odd to create and drop tables through your application - why not just make the tables and then delete and fill them instead of drop/create them?
0
 

Author Comment

by:dolamitejenkins
ID: 40585492
actually using lyndia to learn an the example does it this way but only creates 2 tables .... I will chech the date and time and see if that is the problem ... how else do you create a database in cold fusiom ... server side work in not my thing I'm trying to learn fast
0
 
LVL 39

Assisted Solution

by:gdemaria
gdemaria earned 200 total points
ID: 40585496
just connect to the database and create the table in there, nothing to do with coldfusion.   Then let coldfusion create and delete the records as needed.

Do you have more than one user accessing these report tables?  If so, you need to add/delete records by user, if you delete all, or drop the table, all the users will be effected, right?
0
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
LVL 52

Accepted Solution

by:
_agx_ earned 300 total points
ID: 40586637
>> actually using lyndia to learn an the example does it this way

I agree with GD. While technically you can create/drop tables through CF, normally you just connect to your database directly using a GUI tool.

To answer your question, you misspelled a few of the data types. That's the cause of the syntax error.


CREATE TABLE
     locationTable(loctabID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY,
     ...
     state VARCHAR(50),
     zip VARCHAR(50)
)


>> apache derby

I know you're following an example, but keep in mind you can use any database you want. The examples use Apache Derby database.because it's easy to embed. I've never used it outside of running examples.  If you'll ultimately be working with a different database like SQL Server or MySQL, you might want to start with that instead.
0
 

Assisted Solution

by:dolamitejenkins
dolamitejenkins earned 0 total points
ID: 40586936
great point thanks
0
 

Author Closing Comment

by:dolamitejenkins
ID: 40596624
Thank you
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
cfchart display 12 104
cfchart issue with html 6 143
Coldfusion update database with CFLOOP 5 64
Printing to a specific printer tray (HP 806dn printer) 3 116
Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question