0

I am writing the test cases in java using h2 as in memory database. and I need to create a package and inside it there is a procedure.

I am able to create a procedure using user defined funtions in h2 where I have create a java class and in it I have written the code to delete from a table.

Now, my code is calling this : PKG_ORCHESTRATOR.P_DEL_CONTROL_ORCHESTRATOR

I have written the user defined funtion for : P_DEL_CONTROL_ORCHESTRATOR

but since PKG_ORCHESTRATOR is not defined, I am getting error.

Could anyone please help me here.

Please let me know if I need to put more details.

Vikas
  • 107
  • 1
  • 10

1 Answers1

1

H2 doesn't have packages, but you can create a schema PKG_ORCHESTRATOR and define your alias in it.

CREATE SCHEMA PKG_ORCHESTRATOR;
CREATE ALIAS PKG_ORCHESTRATOR.P_DEL_CONTROL_ORCHESTRATOR FOR "full.class.Name.methodName";
CALL PKG_ORCHESTRATOR.P_DEL_CONTROL_ORCHESTRATOR(arguments);

If your procedure doesn't have arguments, you must write () after its name to invoke it anyway, otherwise it will not be recognized by the parser.

Evgenij Ryazanov
  • 6,960
  • 2
  • 10
  • 18
  • the package PKG_ORCHESTRATOR is already in another schema ( VR_OWNER). How can we do that ? – Vikas Nov 13 '19 at 12:02
  • Once again, there is no such thing as package in H2 (and in the SQL Standard too). This is an Oracle-specific feature. You cannot create a package with H2, and it cannot be placed anywhere. If you're required to use something like `PKG_ORCHESTRATOR.P_DEL_CONTROL_ORCHESTRATOR(arguments)` to call the routine, just create a fake schema `PKG_ORCHESTRATOR` as described in my answer and use it instead of package to place your routine `P_DEL_CONTROL_ORCHESTRATOR` into it. – Evgenij Ryazanov Nov 13 '19 at 12:35