This discussion is archived
2 Replies Latest reply: Oct 30, 2012 4:33 AM by Herald ten Dam RSS

ExecuteSQL getting failed

970843 Newbie
Currently Being Moderated
Hi,
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();


}


In the above program procedure(' newprocedure') got succesfully created coz oresult return Success but this line >>>>
oresult oot = odb.ExecuteSQL("Begin newprocedur(:ENAME,:ROLLNO); End;"); getting failed, i didnt get the problem.Please helpme with solution.
And my table look like this

Egtable

Roll      Name
1     kate     
3     Zac

Please help me with solution.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points