Skip to main content

Question about running multiple sql scripts

  • December 4, 2015
  • 1 reply
  • 4 views

mikep17

Disclaimer:  I'm new to Vertica.  

I have a shell script that runs a SQL script with vsql

i.e. 

runVSQL.sh:

<code>

#/bin/sh

vsql -f FILELIST.sql

</code>

 

FILENAME contains a list of other SQL scripts to run. 

i.e.

FILELIST.sql:

<code>

\i insert.sql

</code>

 

This works fine when the SQL scripts it's running contains DDL to create schema objects i.e. CREATE table ..... 

but when I try to run DML

i.e. 

insert.sql:

<code>

INSERT INTO SomeTable (something1,something2) VALUES ( somevalue1,somevalue2 );

</code>

 

vsql fails complaining about syntax.... Syntax error at or near "INSERT" at character 1

I'm sure it's something silly, but what am I missing?  Am I going about this all wrong?

Any input would be  great.

TIA

 

1 reply

mikep17
  • Author
  • New Participant
  • December 4, 2015

Also, just to add, If I run the insert.sql ( vsql -f insert.sql ) script directly, it works fine.. it only fails when called from another SQL script