User Tools

Site Tools


voltdb_storedprocedures

Stored Procedures in der VoltDB

Mit Java

  • erzeuge Java-File:
import org.voltdb.*;

public class <class_name> extends VoltProcedure {
  public final SQLStmt <func_name> = new SQLStmt(
    " SELECT *"
    + " FROM foo WHERE bar=?"
    + " ORDER BY whatever ASC;" );
    
  public VoltTable[] run(int bar_value)
    throws VoltAbortException {
    voltQueueSQL( <func_name>, bar_value );
    return voltExecuteSQL();
  }
}
  • kompilieren
javac -cp "$CLASSPATH:/opt/voltdb/voltdb/*"  <name>.java
  • packen
jar cvf <name>.jar *.class
  • Klassen in die VoltDB laden (sqlcmb in /opt/voltdb/bin)
sqlcmd --user=admin --password=<pwd>
1> load classes <name>.jar;
sqlcmd --user=admin --password=<pwd>
1> CREATE PROCEDURE FROM CLASS <class_name>;
voltdb_storedprocedures.txt · Last modified: 2024/04/11 14:23 by 127.0.0.1