View Full Version: Sql In Shell Script

LawsonTalk > Coding, Program Errors and Bugs > Sql In Shell Script


Title: Sql In Shell Script
Description: SQL to spool data to a file


mmrobinette - April 28, 2008 04:24 PM (GMT)
All

I am looking to query a table that lies outside of Lawson using sql from a shell script. Is this possible? Any hints or tips?

schroncd - April 28, 2008 04:43 PM (GMT)
It's pretty simple.

o Have the shell script generate a .sql file containing the query

o initiate a SQL session inside the shell script calling the sql script

o make sure the sql output goes to a file

o have your shell script parse the file to get the data you want or make the decisions you require.

o cleanup your temporary files


g'luck!

mmrobinette - April 28, 2008 11:41 PM (GMT)
Awesome. I am going to give it a shot and i'll let yo know how it works out. ha.

3monkeys - April 30, 2008 06:40 PM (GMT)
The trick is getting that shell script to have the right environment variables set so you can access the database. You'd probably need the variables in your $LAWDIR/prodline/DATABASE file, or whatever database you're connecting to.

You didn't mention which flavor of RDBMS but if you don't get it to work I can send a small Oracle example.

-GW

mivankovich - May 1, 2008 12:35 PM (GMT)
Hi,

If this script is run on demand (not scheduled) and you want your users to be able to run it. Setup a tokendef app, enter the command to run the shell script in the command field, assign the token to the users security class and they'd be able to run the script on the fly.






Hosted for free by InvisionFree