Wednesday 12 April 2023

SQL Running in OAF Page

 

1)    Create one Webui page.



package qair.oracle.apps.qaghr.selfservice.dataload.webui;

 

import java.io.Serializable;

import oracle.apps.fnd.common.VersionInfo;

import oracle.apps.fnd.framework.OAApplicationModule;

import oracle.apps.fnd.framework.OAException;

import oracle.apps.fnd.framework.webui.OAControllerImpl;

import oracle.apps.fnd.framework.webui.OAPageContext;

import oracle.apps.fnd.framework.webui.beans.OAWebBean;

 

public class QAGGenericDataLoadCO extends OAControllerImpl

{

  public static final String RCS_ID = "$Header$";

  public static final boolean RCS_ID_RECORDED = VersionInfo.recordClassVersion("$Header$", "%packagename%");

 

  public void processRequest(OAPageContext pageContext, OAWebBean webBean)

  {

    super.processRequest(pageContext, webBean);

  }

 

  public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)

  {

    super.processFormRequest(pageContext, webBean);

    if (pageContext.getParameter("QryButton") != null) {

      OAApplicationModule am = pageContext.getApplicationModule(webBean);

      String Query = pageContext.getParameter("TxtQuery");

      Serializable[] param = { Query };

      am.invokeMethod("getquery", param);

      throw new OAException("Record saved successfully", (byte)3);

    }

  }

}

 



 

package qair.oracle.apps.qaghr.selfservice.dataload.server;

 

import java.io.PrintStream;

import java.sql.CallableStatement;

import java.sql.SQLException;

import oracle.apps.fnd.framework.OAException;

import oracle.apps.fnd.framework.OAViewObject;

import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;

import oracle.apps.fnd.framework.server.OADBTransaction;

import oracle.jbo.Row;

 

public class QAGGenericDataLoadAMImpl extends OAApplicationModuleImpl {

    /**This is the default constructor (do not remove)

     */

    public QAGGenericDataLoadAMImpl() {

    }

 

    public static void main(String[] args)

  {

    launchTester("qair.oracle.apps.qaghr.selfservice.dataload.server", "QAGGenericDataLoadAMLocal");

  }

 

  public QAGGenericDataLoadVOImpl getQAGGenericDataLoadVO1()

  {

    return (QAGGenericDataLoadVOImpl)findViewObject("QAGGenericDataLoadVO1");

  }

 

  public void createrow()

  {

    OAViewObject DataVO = getQAGGenericDataLoadVO1();

    Row row = DataVO.createRow();

    DataVO.setCurrentRow(DataVO.last());

    DataVO.next();

    DataVO.insertRow(row);

   // row.setNewRowState(-1);

  }

 

  public void getquery(String Query) {

    System.out.println("Query:" + Query);

    OADBTransaction txn = getOADBTransaction();

    CallableStatement cs = null;

    try {

      cs = txn.createCallableStatement(Query, 1);

      cs.executeUpdate(Query);

      cs.close();

      txn.commit();

    } catch (SQLException e) {

      throw new OAException("Error while executing the Query " + e.getMessage(), (byte)0);

    }

  }

}


No comments:

Post a Comment