使用C接口访问Sybase ASE,有多种方式。见到itpub论坛上有人问起,索性做一个简单的demo。发现,使用SQL/C比Open Client接口更直观,比较适合喜欢偷懒的coder.下边介绍详细过程.
1. 数据库环境
数据库iihero, 有用户spring/spring1, 使用sa用户登录,执行如下脚本(test_proc.sql),目的是创建一个示例表及数据,并为它创建一个存储过程,给后边的程序用.
use iihero go setuser 'spring' go if exists ( select 1 from sysobjects where name = 'test_proc' ) drop proc test_proc go if exists ( select 1 from sysobjects where name = 't123') drop table t123 go create table t123(id int primary key, col2 varchar(32) not null) insert into t123 values(1, 'iihero') insert into t123 values(2, 'Sybase') insert into t123 values(3, 'ASE') go create proc test_proc (@id_min int, @num_t123 int output) with recompile as select @num_t123