Anil's Blog is Best Viewed on GOOGLE CHROME

Sunday, April 5, 2009

Calling Procedure

AM Code:

public String CreateInvoice(String pamount,String ptype,String pnum,String perror)
{

String perror = null;
try
{
Connection conn = getOADBTransaction().getJdbcConnection();
CallableStatement cstmt = conn.prepareCall("{call add_invoice_proc(?,?,?,?)}");
cstmt.setString(1,pamount);
cstmt.setString(2,ptype);
cstmt.setString(3,pnum);
cstmt.registerOutParameter(4,Types.VARCHAR);
System.out.println("before calling");
cstmt.execute();
perror = cstmt.getString(4);/*****getting the out parameter*****/
System.out.println("after calling");
System.out.println("error is "+perror);
cstmt.close();
}
catch(Exception e)
{
e.printStackTrace();
}

return perror;
}



public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
if (pageContext.getParameter("Insert")!=null)
{
String amount = pageContext.getParameter("InvoiceAmount");
String type = pageContext.getParameter("InvoiceTypeLookupCode");
String number = pageContext.getParameter("InvoiceNum");
String error = "";
OAApplicationModule am = pageContext.getApplicationModule(webBean);
Serializable [] params = {amount,type,number,error};
am.invokeMethod("CreateInvoice",params);
System.out.println("getting the out param in CO");
String returnmsg =(String)am.invokeMethod("CreateInvoice",params);
System.out.println("after getting");
System.out.println("errorstring is "+returnmsg);
if (returnmsg != null)
{
throw new OAException(returnmsg,OAException.ERROR);
}
if (returnmsg==null)
{
throw new OAException("Invoice created Successfully",OAException.CONFIRMATION);
}
}
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.