Re: Esql/c Dynamic Index
Posted in 1997
You need to do something like: EXEC SQL BEGIN DECLARE SECTION; char prepstr[MAX_STMT_SIZE]; EXEC SQL END DECLARE SECTION; char table_name[MAX_TAB_NAME_LEN]; char index_name[MAX_IND_NAME_LEN]; char column_name_str[MAX_INDEX_NAME_LEN]; strcpy(index_name, "my_index"); strcpy(table_name, "my_table"); strcpy(column_name_str,"col1, col2, col3, ..."); strcpy(prepstr, "Create index %s on %s(%s)", index_name, table_name, column_name_str); EXEC SQL EXECUTE IMMEDIATE :prepstr; chk_sql_status(); -Bill } } Hi Folks, } } } I am using Informix OWS 7.20 for solaris. with esql/c 7.23. } In one of my esql/c program i am creating a table with indexes. } Creating table is fine, but creating index gives me problem. } I am trying to create index dynamically i.e using host variable in place } of index name. } SQL ERROR : 37000, PARAMS : Syntax error or access violation in } PREPARE or EXECUTE IMMEDIATE. } The create index stmt looks like this } EXEC SQL create index :index_name On table(column); } } I even used SET deferred_prepare disables / enabled etc.... } } Thanks for help in advance. } } Regards } } Praveen Mohan } Sunnyvale, CA } e-mail : praveen_mohanan@hotmail.com } tel no. 650.594.9899 x 217 } } } } } } } } } ______________________________________________________ } Get Your Private, Free Email at http://www.hotmail.com } -- Bill Ennis Voice: 312-474-7516 SSA Fax: 312-474-7460 500 W. Madison email: ennis@ssax.com ennis@accesschicago.net