RabbieBurns Posted May 20, 2015 Posted May 20, 2015 Im looking to create a bash script that I can call as a scheduled cron job to run a db2 command to manipulate a db2 database. I know bash and cron well enough to get this part, but I dont know the db2 command line interface enough I can run db2 connect to from the command line and establish a connection to the DB. What I need to do, is establish a connection to the DB, and then run an SQL command such as: INSERT INTO DB2INST1.TEST_SCHEDULE (TIME, "SYSTEM") VALUES (current_timestamp, 'RB_test'); Is there a way to run each of these SQL commands using the db2 command line? Do I need to save this query into a .sql and run a specific command to execute it? Hoping someone on here has some db2 from the bash cli experience who can help please
LosOjos Posted May 20, 2015 Posted May 20, 2015 I believe you can specify a script with '-f', so if you wrote your series of commands and saved them in script.sql (for example), you'd be able to run the lot like so: db2 -f script.sql DB2's Command Line Processor and Scripting
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now