Ejemplo n.º 1
0
  /**
   * Foreign function. Dynamically executes an AMOSQL statement. Declare as create function
   * jeval(charstring)->object as foreign "JAVA:EvalTest/javaEval";
   */
  public void javaEval(CallContext cxt, Tuple tpl) throws AmosException {

    Scan tmpScan;
    Tuple t;

    // Pick up the argument
    String query = tpl.getStringElem(0);

    try {
      System.out.println("Executing " + query);
      tmpScan = cxt.connection().execute(query);

      while (!tmpScan.eos()) {
        t = tmpScan.getRow();
        tpl.setElem(1, t.getOidElem(0));
        cxt.emit(tpl);
        tmpScan.nextRow();
      }
    } catch (AmosException e) {
      throw (e);
    }
  }
Ejemplo n.º 2
0
  /**
   * Foreign function. Thows an Amos II error Declare as create function jerror(charstring)->object
   * as foreign "JAVA:EvalTest/jerror";
   */
  public void jerror(CallContext cxt, Tuple tpl) throws AmosException {
    String msg = tpl.getStringElem(0);

    throw (new AmosException(msg));
  }