Sharing code between stored procedures
Feb 8, 2013
I have a java class ProcFoo and another one ProcFar.
I would like to share some code between them. So I created ProcCommon
public class ProcCommon extends VoltProcedure {
public void commonLogic() {
// Access volt db using query
}
};
public class ProcFoo extends ProcCommon {
public VoltTable[] run(...) {
commonLogic();
}
};
public class ProcBar extends procCommon {
public VoltTable[] run(...) {
commonLogic();
}
};
If I don't reference procCommon in the DDL, it does not get included in the catalog, causing a runtime error. If I do, though
CREATE PROCEDURE FROM CLASS ProcFoo;
CREATE PROCEDURE FROM CLASS ProcBar;
CREATE PROCEDURE FROM CLASS ProcCommon;
This fails b/c ProcCommon does not have a run()
What's the best practice?
I would like to share some code between them. So I created ProcCommon
public class ProcCommon extends VoltProcedure {
public void commonLogic() {
// Access volt db using query
}
};
public class ProcFoo extends ProcCommon {
public VoltTable[] run(...) {
commonLogic();
}
};
public class ProcBar extends procCommon {
public VoltTable[] run(...) {
commonLogic();
}
};
If I don't reference procCommon in the DDL, it does not get included in the catalog, causing a runtime error. If I do, though
CREATE PROCEDURE FROM CLASS ProcFoo;
CREATE PROCEDURE FROM CLASS ProcBar;
CREATE PROCEDURE FROM CLASS ProcCommon;
This fails b/c ProcCommon does not have a run()
What's the best practice?