Thursday, December 4, 2008

Create a table from PowerScript

Use EXECUTE IMMEDIATE. Set Autocommit to true because DDL SQL has to be executed outside of transaction.
SQLCA.AutoCommit = True
ls_sql = "create table #tmp (abc varchar(255))"
EXECUTE IMMEDIATE :LS_SQL USING SQLCA;

To alter a table, use the same idea:
ls_sql = 'ALTER TABLE dba.tbl_name ADD col_name'
EXECUTE IMMEDIATE :LS_SQL USING SQLCA;

No comments:

Custom Search