How to include SQL within a script

Hi,

I have a script I am developing (actually more than 1 just now).

1st part - executes SQL in a 2nd script.
2nd part - reformats the output of the sql into a csv

Problem:

How am I able to run the SQL from the first script? I assume there is a sql command? I generally use isql when interrogating by myself but I have never had a need to add it to a script before.

Edit - I only want 1 script which deals with the entire process.

Check if this helps.

Linux Learning: Bash and Database connectivity.

not ideal, it is too long winded. I don't need credentials as the user running the script will already have read/write on the database. I am hoping there is an easier method...

I am hoping for a simple command to run the SQL within a shell script.

My current method works fine but I would like to merge it into 1 script. I basically echo the SQL to a 2nd file, 2ndfile.sql, then include the command to run that file within my 1st script.

What database is it ?

tyler_durden

this case it is an ingres DB

Check if this link helps you: Passing parameter through .sh file for creation generic database - Ingres Community Forums

It is from ingres community!

1 Like

Got it. The link is useful. More thorough than I need but the examples contain the solution. I appreciate your help.