db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dexter195 <dexter_...@yahoo.com>
Subject Re: sql format in *.sql files
Date Thu, 14 Feb 2008 13:08:34 GMT

Hi Bernt,

Thanks for the help. I have changed those quotes but im still getting the
same problem, that the semi colons arnt being recognised at the end of the
sql statements.

This is what im doing. Am i inserting this correctly?

Dexter

SQL File:

insert into MeasurementColumn values
('MTABLEID','DATANAME',1,'DATATYPE',2,3,4,5,'INDEXES','DESCRIPTION','DATAID','RELEASEID',6);

insert into MeasurementColumn values
('MTABLEID123','DATANAME',1,'DATATYPE',2,3,4,5,'INDEXES','DESCRIPTION','DATAID','RELEASEID',6);


// This method takes in a statement object and the SQL filename
// it then calls the readSQL file and then executes the statements contained
in the SQL file.
public void insertTestData( Statement stmnt, String strFileName ) throws
Exception
{
		String sqlInserts = readSQLFile( strFileName );
				
		try
		{
			{
				stmnt.execute( sqlInserts );	
			}
			
		}
		
		catch( Exception e )
		{
			e.printStackTrace();
		}

		System.out.println( "Table Information Inserted." );
		
} 


private static String readSQLFile( String strFileName )
{
		StringBuffer strFileContents = new StringBuffer();
		
		BufferedReader input = null;
			
		try
		{
			input = new BufferedReader( new FileReader(strFileName) );
			String line = null; 

			while ( (line = input.readLine() ) != null )
			{
				strFileContents.append( line );
				strFileContents.append( System.getProperty("line.separator") );
							
			}
		}

                catch Statements.......
}


ERROR 42X01: Syntax error: Encountered ";" at line 3, column 92.



Bernt M. Johnsen wrote:
> 
>>>>>>>>>>>>> dexter195 wrote (2008-02-14 04:20:13):
>> 
>> Hi
>> 
>> I have a load of sql files that i need to be able to import into derby. 
>> 
>> What delimiter do i need at the end of the statements in order for derby
>> to
>> see it as a seperate query. i presumed that this would be ; but this
>> doesnt
>> work. I've tried all variants i can think of but none of them work.
>> 
>> insert into MeasurementColumn values
>> ("test","test",1,"test",2,3,4,5,"test","test","test","test",6);
>> insert into MeasurementColumn values
>> ("test1","test1",1,"test1",2,3,4,5,"test1","test1","test1","test1",6);
>> 
>> ERROR 42X01: Syntax error: Encountered ";" at line 2, column 129.
> 
> The statement is syntactically incorrect. You should use ' not " to
> delimit strings in SQL, like this:
> 
> insert into MeasurementColumn values
> ('test','test',1,'test',2,3,4,5,'test','test','test','test',6);
> insert into MeasurementColumn values
> ('test1','test1',1,'test1',2,3,4,5,'test1','test1','test1','test1',6);
> 
> 
> -- 
> Bernt Marius Johnsen, Database Technology Group, 
> Staff Engineer, Derby/Java DB
> Sun Microsystems, Trondheim, Norway
> 
>  
> 

-- 
View this message in context: http://www.nabble.com/sql-format-in-*.sql-files-tp15479296p15480001.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Mime
View raw message