Announcement

Collapse
No announcement yet.

Sharing code between stored procedures

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • theschmitzer
    started a topic Sharing code between stored procedures

    Sharing code between stored procedures

    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?

  • theschmitzer
    replied
    Thanks I did that, and added to Schema

    CREATE PROCEDURE FROM CLASS ProcCommon;

    Seems to work.

    Leave a comment:


  • pmartel
    replied
    This is a known weakness in the current catalog compiler. It is designated ENG-4061 in the issues database.

    The future method for specifying additional library classes for use by stored procedures is still under discussion.

    IMO, the best workaround for this particular example until this issue is resolved in the product is to add an unused "run" method to the common base class.

    --paul

    Leave a comment:

Working...
X