调用存储过程db2
A. 在C#NET中怎样调用db2存储过程
1、找开sql server 2005,创建表名为abc的表,表的设计如图。 2、给表中加入三行数据,如图。 3、创建一个名为“pro_abc”的存储过程,内容如图。 4、在程序中的配置文件,配置数据库链接字符串,如图。
B. db2 调用存储过程,报错:SQL1646N 无法访问sqllib
帮一下包试试?
db2 terminate
db2 CONNECT TO dbname user USERID using PASSWORD
db2 BIND path\db2schema.bnd BLOCKING ALL GRANT PUBLIC SQLERROR CONTINUE
db2 BIND path\@db2ubind.lst BLOCKING ALL GRANT PUBLIC ACTION ADD
db2 BIND path\@db2cli.lst BLOCKING ALL GRANT PUBLIC ACTION ADD
db2 terminate
where dbname represents the name of a database to which the files should be bound, and where path is the full path name of the directory where the bind files are located, such as INSTHOME\sqllib\bnd where INSTHOME represents the home directory of the DB2 instance. db2ubind.lst and db2cli.lst contain lists of required bind files used by DB2 database procts. Packages that are already bound will return an SQL0719N error. This is expected.
C. DB2存储过程
db2 -td@ -vf a.db2
这一句中@的意思是读取文件中的分隔,每遇到一个@号会将之前的SQL语句做为单独一段来执行,你的存储过程中有使用了这个符号,则执行时将创建存储过程的语句给分拆开了,所以执行会同语法错误,你这一段中只需要两个@号,第一句连接数据库后用一个,最后用一个,中间的改成“;”号。
connect to toolsdb@
CREATE PROCEDURE testProced(
in in_name varchar(20),
out out_name varchar(20)
)
LANGUAGE SQL
BEGIN
select a into out_name from bb where a1 = in_name;
END@