0

If relevant, I'm using IBM i V7R1M0.

I have some code in C#:

var generateSqlSql = $@"
CALL QSYS2.GENERATE_SQL(
    '{obj.Name}',
    '{obj.Library}',
    'VIEW',
    CREATE_OR_REPLACE_OPTION => '1',
    HEADER_OPTION => '0',
    COMMENT_OPTION => '1',
    PRIVILEGES_OPTION => '0',
    LABEL_OPTION => '0'
)";
...
//get results
//split on semicolon
//change library
//write back to database

The sql that it's then trying to write is:

CREATE OR REPLACE VIEW AMMLIBC.BBI_USER_MY_VIEW FOR SYSTEM NAME         BBIU_00001 ( 
/* view columns */ ) 
AS 
/*view definition */
RCDFMT BBIU_00001 

When I try to run it, it gives the following error:

iDB2SQLErrorException: SQL7029 New name BBIU_00001 is not valid.

...Why? What's causing this, and how do I make it work?

0

Found the problem.

The view already existed in both the original library and the target library, but with different system names.

Adding this line fixed the problem:

SYSTEM_NAME_OPTION => '0',

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.