SQLJ / PLJAVA Tutorial

From ADempiere
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.

SQLJ - PLJAVA in PostgreSQL

SQLJ - is used to implement methods java inside the database


What is SQLJ SQLJ is the collection of java programming extensions. It allow to programmers using the Java programming language to embed statements that provide SQL database funtions. It can also define as SQLJ enables applications programmers to embed SQL operations in Java code


  • Create new class in sqlj/src

Image: 640 pixels


  • insert the new method in the new class (the method must be static)

Image: 640 pixels


  • create a new function in PostgreSQL

Image: 640 pixels

Image4.png

  • insert type and name of arguments in the parameters and click in add
  • in definition, insert path of method and type of argument

Image5.png


  • modify sqlj.ddr in …adempiere_stable/sqlj/postgresql
    • Example:
   CREATE OR REPLACE FUNCTION getamtinwords(amount VARCHAR)
   RETURNS VARCHAR 
   AS 'org.compiere.sqlj.AdempiereLBR.getAmtInWords(java.lang.String)'
   LANGUAGE 'java' VOLATILE;

Image: 640 pixels

  • run_build.bat or run_build.sh

  • replace or install the sqlj.jar
    • Example: select sqlj.replace_jar('file:/c:/workspace/adempiere_stable/sqlj/sqlj.jar','sqlj',true);
  • if necessary use set_classpath

Image: 640 pixels

Image: 640 pixels