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

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 an SPJ method.

1. install JDK JDBC ....... onto oss evn;

2. create a class, the fuction must be "static", becuase we can access the method in the class without instantiate.

  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 to 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.

来自为知笔记(Wiz)

时间: 2024-12-30 03:02:59

HP Nonstop SQLMX (SPJ) Stored Procedure in Javas Getting Started的相关文章

EntityFramework 学习 一 Stored Procedure

CREATE PROCEDURE [dbo].[GetCoursesByStudentId] -- Add the parameters for the stored procedure here @StudentId int = null AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Inse

Publishing Stored Procedure Execution in Transactional Replication

Replication 不仅可以将Table Article 或 SP Article 推送到subscription,而且还能将sp的execution推送到subscription.推送sp的execution是指将执行sp的command 推送到subscriber去执行, 而不是将sp执行之后产生的大量transaction推送到subscriber上.Transaction是逐个更新Table Article中的数据行. 推送sp的execution来同步subscription的数据

在JDBC中传递table参数给SQL server stored procedure

SQL Server JDBC驱动不支持直接传递Table参数给stored procedure 我的做法是先创建一个临时表,将需要插入的数据先插入到临时表里面,然后把这个临时表作为参数,传送给stored procedure.使用了Preparestatement来避免SQL注入问题. 先创建User Defined Table CREATE TYPE UserIdList AS TABLE( userId uniqueidentifier NOT NULL ); 再创建存储过程: CREAT

Stored Procedure 里的 WITH RECOMPILE 到底是干麻的?

原文:Stored Procedure 里的 WITH RECOMPILE 到底是干麻的? 在 SQL Server 创建或修改「存储过程(stored procedure)」时,可加上 WITH RECOMPILE 选项,但多数文档或书籍都写得语焉不详,或只解释为「每次执行此存储过程时,都要重新编译」.事实上,是指执行此一存储过程时,要强制重新产生「执行计划(execution plan)」,而不要从「缓存(cache)」去取得旧的「执行计划」. SQL Server 在评估与产生「执行计划」

SQL Server 在多个数据库中创建同一个存储过程(Create Same Stored Procedure in All Databases)

原文:SQL Server 在多个数据库中创建同一个存储过程(Create Same Stored Procedure in All Databases) 一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 遇到的问题(Problems) 实现代码(SQL Codes) 方法一:拼接SQL: 方法二:调用模板存储过程创建存储过程: 总结 扩展阅读 参考文献(References) 二.背景(Contexts) 在我的数据库服务器上,同一个实例

Retrieving Out Params From a Stored Procedure With Python

http://www.rodneyoliver.com/blog/2013/08/08/retrieving-out-params-from-a-stored-procedure-with-python/ AUG 8TH, 2013 I was hacking some python today which calls a stored procedure that sends back an out parameter to indicate whether or not it complet

Oracle Stored Procedure demo

1.how to find invalid status stored procedure and recompile them? SELECT OBJECT_NAME , status FROM user_objects WHERE OBJECT_TYPE = 'PROCEDURE'; Alter procedure schme.procedurename compile; 缺少练习的学习不是完整的学习,练习才是学习,总结才有思考.   SELECT OBJECT_NAME , STATUS

Oracle Java Stored Procedure + 包调用

1. 创建Java Stored Procedure create or replace and compile java source named "TestHello" as public class TestHello{   public static void test(){     System.out.println("Hello");   } } 2.创建JSP调用存过或方法(本例为在包创建的存过) create or replace package 

[原] XAF How to bind a stored procedure to a ListView in XAF

First, I suggest that you review the following topic to learn how to show a custom set of objects in a ListView: How to: Display a List of Non-Persistent Objects.To create non-persistent objects based on a stored procedure, use the Session.GetObjects