插入一条记录到表中,但表名称保存在变量中,如何操作呢?
hykz 2001-06-05 10:04:00 我的方法为:
1)
string tablename,i_id,i_name
//嵌入SQL
Insert into :tablename (id,name) values(:i_id,:i_name);
上面的程序编译不通过。
2)
string Sql_Insert
SQLCA.AutoCommit = True
Sql_Insert = "INSERT INTO " + tablename + "(id,name)
VALUES (" + i_id + "," + i_name +")"
EXECUTE IMMEDIATE :Sql_Insert USING SQLCA;
SQLCA.AutoCommit = False
返回的SQLCODE为-1,也不行,请帮忙看看我的程序哪里写错了?谢谢