db.proc()

阅读(826) 标签: 数据库, 存储过程,

描述:

调用数据库中的存储过程。

语法:

db.proc( sql, param:type:mode:variable, ... )

备注:

调用数据库中的存储过程,将存储过程中的输出变量返回到网格文件中。

将生成的变量输入到当前Context 中,并且可以在当前程序网中引用。

参数:

db

数据库连接。

sql

存储过程的执行语句,如call test(?,?)

param

输入参数值。

type

参数类型。

mode

取值为"i" "o" "i"表示输入参数,"o"表示输出参数。

variable

输出参数名,网格文件中可以通过参数名对存储过程执行结果引用。

type的取值为:

public final static byte DT_DEFAULT = (byte) 0; // 默认,自动识别

public final static byte DT_INT = (byte) 1;

public final static byte DT_LONG = (byte) 2;

public final static byte DT_SHORT = (byte) 3;

public final static byte DT_BIGINT = (byte) 4;

public final static byte DT_FLOAT = (byte) 5;

public final static byte DT_DOUBLE = (byte) 6;

public final static byte DT_DECIMAL = (byte) 7;

public final static byte DT_DATE = (byte) 8;

public final static byte DT_TIME = (byte) 9;

public final static byte DT_DATETIME = (byte) 10;

public final static byte DT_STRING = (byte) 11;

public final static byte DT_BOOLEAN = (byte) 12;

public final static byte DT_INT_ARR = (byte) 51;

public final static byte DT_LONG_ARR = (byte) 52;

public final static byte DT_SHORT_ARR = (byte) 53;

public final static byte DT_BIGINT_ARR = (byte) 54;

public final static byte DT_FLOAT_ARR = (byte) 55;

public final static byte DT_DOUBLE_ARR = (byte) 56;

public final static byte DT_DECIMAL_ARR = (byte) 57;

public final static byte DT_DATE_ARR = (byte) 58;

public final static byte DT_TIME_ARR = (byte) 59;

public final static byte DT_DATETIME_ARR = (byte) 60;

public final static byte DT_STRING_ARR = (byte) 61;

public final static byte DT_BYTE_ARR = (byte) 62;

public final static byte DT_CURSOR = (byte) 101;

public final static byte DT_AUTOINCREMENT = (byte) 102;

示例:

通过存储过程返回一条记录:

 

A

 

1

=orac.proc("{call RQ_TEST_CUR(?,?)}",:101:"o":table1,1:0:"i":)

2

=table1

A2通过使用A1中的输出变量来引用存储过程的执行结果,计算结果与A1相同。

存储过程内容如下:

通过存储过程返回多个序表:

 

A

 

1

=orac.proc("{call proAA(?,?)}",:101:"o":a,:101:"o":b)

[[7369,7499,7521,…],[1,2,3]], 返回由多个序表组成的序列,每个序表对应一个输出变量。

2

=A1(1)

返回A1序列中的第一个序表。

3

=a

A3 A4通过使用A1中的输出变量来获取存储过程对应的执行结果。

4

=b

存储过程内容如下:

相关概念:

db.execute()

db.query()