{"id":929,"date":"2013-02-12T18:50:05","date_gmt":"2013-02-12T16:50:05","guid":{"rendered":"http:\/\/oracle.malin.pl\/?p=929"},"modified":"2013-02-12T18:50:05","modified_gmt":"2013-02-12T16:50:05","slug":"how-to-call-stored-plsql-function-or-procedure-in-oaf-controller","status":"publish","type":"post","link":"https:\/\/oracle.malin.pl\/?p=929","title":{"rendered":"How to call stored PLSQL function or procedure in OAF controller"},"content":{"rendered":"<p>Jak wywo\u0142a\u0107 procedur\u0119 albo funkcj\u0119 z bazy z poziomu kontrolera OAF<!--more--><\/p>\n<pre lang=\"java\">\r\npackage xx.oracle.apps.ar.creditmgt.application.webui;\r\n\r\nimport oracle.apps.ar.creditmgt.application.webui.creditApplicationCO;\r\nimport oracle.apps.fnd.framework.OAViewObject;\r\nimport oracle.apps.fnd.framework.webui.OAPageContext;\r\nimport oracle.apps.fnd.framework.webui.beans.OAWebBean;\r\nimport oracle.apps.fnd.framework.OAException;\r\nimport oracle.apps.fnd.framework.webui.beans.message.OAMessageLovInputBean;\r\nimport oracle.apps.fnd.framework.server.OADBTransaction;\r\n\r\nimport java.sql.CallableStatement;\r\nimport java.sql.SQLException;\r\nimport java.sql.Types;\r\n\r\npublic class xxcreditApplicationCO extends creditApplicationCO \r\n{\r\n\r\n    public void processFormRequest(OAPageContext oapagecontext, OAWebBean oawebbean)\r\n        {        \r\n\r\n  \t\t\tString s = (String)oapagecontext.getParameter(\"_FORM_SUBMIT_BUTTON\"); \r\n\r\n        OAMessageLovInputBean CurrencyHandle = (OAMessageLovInputBean)oawebbean.findChildRecursive(\"Arcmcurrency\");\t\t\t\t\r\n\r\n             if (s.equals(\"ArCmSubmit\") &amp;&amp; CurrencyHandle.getValue(oapagecontext) !=null)   \/\/ form submit\r\n             {\r\n                String Currency = CurrencyHandle.getValue(oapagecontext).toString();\r\n\r\n                OAViewObject xoaviewobject = (OAViewObject)oapagecontext.getApplicationModule(oawebbean).findViewObject(\"creditRequestsVO\");\r\n                oracle.jbo.Row row = xoaviewobject.first();\r\n                String SiteUseId = row.getAttribute(\"SiteUseId\").toString();\r\n\r\n                String outParamValue; \r\n                OADBTransaction txn  = oapagecontext.getApplicationModule(oawebbean).getOADBTransaction();\r\n                CallableStatement cs = txn.createCallableStatement(\"begin :1 := xx_ar_cmgt_util.VALIDATECURRENCY(:2,:3); end;\",1);\r\n\r\n                  try\r\n                  {\r\n                    cs.registerOutParameter(1, Types.VARCHAR);\r\n                    cs.setString(2,SiteUseId);\r\n                    cs.setString(3,Currency);\r\n                    cs.execute();\r\n                    outParamValue = cs.getString(1);\r\n                    cs.close();\r\n                  }\r\n                  catch (SQLException sqle)\r\n                  {\r\n                      throw OAException.wrapperException(sqle);\r\n                  }\r\n\r\n                if (outParamValue.equals(\"N\"))\r\n                {\r\n\/\/                 throw new OAException(Currency+\" is wrong currecy for this customer. Please choose other currency or setup customer for \" +Currency+\". \"+SiteUseId+\". \"+outParamValue, OAException.INFORMATION);\r\n\r\n                throw new OAException(Currency+\" is wrong currecy for this customer. Please choose other currency or setup customer for \" +Currency+\". \"+SiteUseId+\". \"+outParamValue, OAException.INFORMATION);\r\n\r\n                }\r\n\r\n         \t }\r\n        super.processFormRequest(oapagecontext, oawebbean);\r\n       }\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Jak wywo\u0142a\u0107 procedur\u0119 albo funkcj\u0119 z bazy z poziomu kontrolera OAF<\/p>\n","protected":false},"author":38,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[96],"tags":[164],"_links":{"self":[{"href":"https:\/\/oracle.malin.pl\/index.php?rest_route=\/wp\/v2\/posts\/929"}],"collection":[{"href":"https:\/\/oracle.malin.pl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oracle.malin.pl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oracle.malin.pl\/index.php?rest_route=\/wp\/v2\/users\/38"}],"replies":[{"embeddable":true,"href":"https:\/\/oracle.malin.pl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=929"}],"version-history":[{"count":1,"href":"https:\/\/oracle.malin.pl\/index.php?rest_route=\/wp\/v2\/posts\/929\/revisions"}],"predecessor-version":[{"id":930,"href":"https:\/\/oracle.malin.pl\/index.php?rest_route=\/wp\/v2\/posts\/929\/revisions\/930"}],"wp:attachment":[{"href":"https:\/\/oracle.malin.pl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=929"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oracle.malin.pl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=929"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oracle.malin.pl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}