在下面的程序中,procedure('newprocedure') 已成功创建,因为它返回 Success 但这一行 >>>> oresult oot = odb.ExecuteSQL("Begin newprocedur(:ENAME,:ROLLNO); End;"); 它失败并出现此错误>>>> ORA-06502:PL/SQL:数字或值错误:字符到数字转换错误“。请帮助我解决问题。
我的桌子看起来像这样
电子表格
卷名 1 凯特 3 扎克
`int _tmain(int argc, _TCHAR* argv[])
{
OStartup();
ODatabase odb;
oresult res = odb.Open("MICROSOFT", "OMNIPOS", "OMNIPOS");
char pSqlStmt[500];
memset(pSqlStmt,0,sizeof(pSqlStmt));
OSqlStmt osql;
///////////////////////////////procedure Creation/////////////////
strcpy(pSqlStmt,"create or replace PROCEDURE newprocedure(inEmpName IN VARCHAR2 ,outEmpno OUT NUMBER)\n AS \n");
strcat(pSqlStmt,"BEGIN\n");
strcat(pSqlStmt,"select ROLL into outEmpno from Egtable WHERE NAME = inEmpName;\n");
// strcat(pSqlStmt,"dbms_output.put_line('Roll'+outEmpno);\n");
strcat(pSqlStmt,"outEmpno:=outEmpno+1;\n");
strcat(pSqlStmt,"update Egtable set ROLL = outEmpno WHERE NAME = inEmpName;\n");
strcat(pSqlStmt,"END;\n");
oresult ot = odb.ExecuteSQL(pSqlStmt);
if (ot == OSUCCESS)
{
OValue val;
odb.GetParameters().Add("ENAME","Zac", OPARAMETER_INVAR, OTYPE_VARCHAR2);
odb.GetParameters().Add("ROLLNO",0, OPARAMETER_OUTVAR, OTYPE_NUMBER);
oresult oot = odb.ExecuteSQL("Begin newprocedure(:ENAME,:ROLLNO); End;");
oresult i = odb.GetParameters().GetParameter("ROLLNO").GetValue(&val);
cout<< "value is " << (const char*) val<<endl;
}
else
{
cout<<"ERR:"<<odb.GetServerErrorText();
}
odb.Close();
OShutdown();
}
`
提前致谢