HP Nonstop sqlmx (SPJ) Stored Procedure in Javas Getting Started

Source: Internet
Author: User

Stored Procedure in Java (SPJ) HP Nonstop sqlmx, we can code Java program and regist it as a DB Stored Procedure, and then calling it. SPJ is a stored procedure whose body is a static Java method. The body is known as anSPJ Method. 1. Install JDK JDBC ... onto OSS evn;2. Create a class, the fuction must is " static", becuase we can access the method in the class without Instan Tiate.
  1. publicclassHelloWorld{
  2.     publicstaticvoid testFunc(int a,int b,String[] tst,int[] bigger){
  3.  
  4.         if(a > b)
  5.            bigger[0]= a;
  6.         else
  7.            bigger[0]= b;
  8.  
  9.         tst[0]="The bigger one is: ";
  10.     }
  11. }
3. FTP the. java file onto OSS; 4. compile it with javac command; 5. regist, to register Spjs into MX,
    You must be either the schema owner or the Super ID. Run below script in mxci to reigist the stored procedure.
  1. >>?SECTION "CREATE ENDER SPJs"
  2. >>CREATE PROCEDURE sos.ecui.testFunc(IN param_a INT, IN param_b INT, OUT tst VARCHAR(20), OUT bigger INT)
  3. +>EXTERNAL NAME ‘HelloWorld.testFunc‘
  4. +>EXTERNAL PATH ‘/home/ecui/java/test‘
  5. +>LANGUAGE JAVA
  6. +>PARAMETER STYLE JAVA
  7. +>MODIFIES SQL DATA;
  8.  
  9. --- SQL operation complete.
  10.  
  11. >> SHOWDDL SOS.ECUI.TESTFUNC;
  12.  
  13. CREATE PROCEDURE SOS.ECUI.TESTFUNC
  14.   (
  15.     IN PARAM_A INTEGER
  16.   , IN PARAM_B INTEGER
  17.   , OUT TST VARCHAR(20) CHARACTER SET ISO88591
  18.   , OUT BIGGER INTEGER
  19.   )
  20.   EXTERNAL NAME ‘HelloWorld.testFunc (int,int,java.lang.String[],int[])‘
  21.   EXTERNAL PATH ‘/home/ecui/java/test‘
  22.   LOCATION \P3DEV.$DATA01.ZSDZSGJ5.MKN46G00
  23.   LANGUAGE JAVA
  24.   PARAMETER STYLE JAVA
  25.   MODIFIES SQL DATA
  26.   DYNAMIC RESULT SETS 0
  27.   NOT DETERMINISTIC
  28.   ISOLATE
  29.   ;
  30.  
  31. --- SQL operation complete.
6. Grant privileges for invoking the Spjs and other users. 7. Call (or Invoke) the Spjs in sql/mx.  
  1. >>CALL sos.ecui.testFunc(2,4,?,?);
  2.  
  3. TST                   BIGGER
  4. --------------------  -----------
  5.  
  6. The bigger one is:              4
  7.  
  8. --- SQL operation complete.
  9. >>CALL sos.ecui.testFunc(20,4,?,?);
  10.  
  11. TST                   BIGGER
  12. --------------------  -----------
  13.  
  14. The bigger one is:             20
  15.  
  16. --- SQL operation complete.
 8. Delete this SPJ,
    1. >>DROP procedure SOS.ECUI.TESTFUNC;
    2.  
    3. --- SQL operation complete.



From for notes (Wiz)



HP Nonstop sqlmx (SPJ) Stored Procedure in Javas Getting Started

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.