我想从用户那里阅读value
并在我的选择查询中使用它。如何在SQL查询中使用动态值?
我当前的代码给了我这个错误:
ORA-01002:提取失序
这是我的代码:
void buildQuery()
{
cout << "Enter flight no :";
cin >> value;
strcpy((char *)sql_statement.arr,"select fname from flights where
flno = " + value );
cout << "Query is " << (char *) sql_statement.arr<< endl;
}
void executeQuery()
{
sql_statement.len = strlen((char *) sql_statement.arr);
exec sql PREPARE S1 FROM :sql_statement;
exec sql declare C1 cursor FOR S1;
exec sql open C1 ;
while(1)
{
exec sql FETCH C1 INTO :fname;
if ( sqlca.sqlcode != 0)
{
cout << "past fetch..." <<endl;
break;
}
cout << "Employee Name is: = " << (char *)ename.arr << endl;
}
exec sql close C1;
}