Start a new topic

Database connection from within a sql script

[This topic is migrated from our old forums. The original author name has been removed]

Hi, I am writing some fairly large database updates in SQL scripts. My problem is that I have to connect to three different databases to make all of these updates. Normally I would have to create 3 separate .sql files one for each database. Is there a way that I can put all my updates in one sql script and write a connection string so that I can connect to database A, run those statements, then disconnect, connect to database B and run those scripts, disconnect, and then connect to database C and run those statements and disconnect, all in one SQL file so I don't have to break it up into individual files? I am using DBVisualizer Pro 9.2.8 and connecting to DB2 LUW database type. Thanks for the help!
1 Comment

[This reply is migrated from our old forums.]

Re: Database connection from within a sql script
Hi, It is not possible from within the DbVisualizer GUI to run a script that dynamically change the database connection. A solution is that you invoke the dbviscmd command line interface for DbVisualizer in a shell script. Invoke it for each of the SQL scripts you want to run. You find more information about dbviscmd here: Regards Roger