Matei Florescu
Matei Florescu

Reputation: 1195

Execute statements from a file in DB2 SQL PL

I want to execute some CREATE TABLE/INSERT/UPDATE statements from a file in a DB2 SQL PL stored procedure. Something like:

 CREATE PROCEDURE UPDATE_SAL (...)
  LANGUAGE  SQL
  BEGIN
    ....
    CALL/EXECUTE 'file.sql'
    ....
  END

How can I do this? I tried to find something in the DB2 documentation but did not find anything useful.

Upvotes: 0

Views: 413

Answers (1)

AngocA
AngocA

Reputation: 7693

It is not possible. That option does not exist in DB2.

However, you can read files in DB2 with the built-in modules. In that way, you can parse a given file (read line per line until separator), create dynamic statements with the read data, and then execute them.

I have thought about this problem: https://github.com/angoca/db2tools/issues/9

Upvotes: 1

Related Questions