Create View giving SQL7029 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 =&gt; '1',
    HEADER_OPTION =&gt; '0',
    COMMENT_OPTION =&gt; '1',
    PRIVILEGES_OPTION =&gt; '0',
    LABEL_OPTION =&gt; '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?
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 =&gt; '0',