ibm+i+to+mysql_IBM 的数据库Informix 常用代语法

Informix 日期类型

datetime year to second  格式为 2003-08-05 10:00:00

datetime year to day  格式为 2003-08-05

Informix 数据类型说明

在定义一个字段时,使用char(x)后。如果字段放入的内容不足x长,就会以空格填充,在代码操作时,需要trim()去掉多佘的空格,sql server 2005 也有以上情况。

varchar(x) ,x 的最大值是255, 所以它存放的数据是有限的。这个时候,就需要使用lvarcahr(x) ,版本9.4以后可以加长度 x, 那么在hibernate 中怎么映射并使用lvarchar(x)  呢, 这个问题纠结了好久,还替换了hibernate 的核心包,如果要使用lvarchar(x),和以前一样的映射,如果在查询语句时,不能写SQL语句,只能写HQL 语句.

Informix 存储过程中 使用 let 赋值

define cur_dtime_var datetime year to second;

let cur_dtime_var = current; -- 使用let 目赋值

Informix 修改表中字段的值,不可以给某个表起别名,如:update atable a  set a.name='stuName' where a.id=1;   这就会出错,informix 会报语法错误,不能给表atable 起别名 a.

但在其他的数据中,以上update 语句是正确的,如在mysql 中是可以正确的执行。

Informix 存储过程学习示例,只供自己学习之用

create procedure myproc1() -- 隐式的语句块的开始

define x int ;

let x =17;

insert into table1 values (x,'zs');

begin -- 显示的语句块开始

define y int;

let y = 18;

insert into table2 values (y,'ls');

end -- 显示的语句块结束

end procedure; -- 隐式的语句块的结束

create procedure continue_ex()

returning int;

define i int;

for i=1 to 20

insert into testtb1 values(i);

if i=6 then

continue for; -- 当i=6 时,跳过最内层的循环

end if;

return i with resume; -- 返回i 然后再重新循环

end for;

end procedure;

-- 存储过程如何返回记录集已经测试成功了,

drop procedure tmp;

create procedure tmp()

returning decimal(12,2),decimal(12,2),varchar(20);

define a,b decimal(12,2);

define c varchar(20);

select * from gskb into temp tmp;

foreach select sjf_je,cbm_cert,station into a,b,c from tmp

return a,b,c with resume;

end foreach;

end procedure

informix 中的自增长

drop table zrjCarParmConfTmp;

alter table zrjCarParmConfTmp modify mainid SERIAL(1) not null;

create table zrjCarParmConfTmp (

mainid SERIAL not null,

comcode CHAR(8),

primary key (mainid)

constraint PK_ZRJCARPARMCONFT

);

select * from zrjCarParmConfTmp;

insert into zrjCarParmConfTmp values(0,'11111111');

insert into zrjCarParmConfTmp (comcode) values('11111112');

informix 截取 前几位数据 和调用 存储过程示例

execute PROCEDURE PRO_zrjUncarBaseTmp('32059800','20130101','20141201');

execute PROCEDURE PRO_zrjUncarBaseTmp('32059800',TO_DATE('20130101','%Y%m%d'),TO_DATE('20141201','%Y%m%d'));

select * from zrjUncarBaseTmp where comcode like '320555343'[1,4]||'%';

@call newreinsdb_dat:zbyanfa.pro_zrjuncarbasetmp(${sp_comcode_in||(null)||String||nullable ds=0 dt=VARCHAR dir=in}$, ${sp_bgndate||(null)||Date||nullable ds=0 dt=DATE dir=in}$, ${sp_enddate||(null)||Date||nullable ds=0 dt=DATE dir=in}$);select TO_CHAR(today,'%Y%m%d') from systables where tabid=1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值