日期:2014-05-16 浏览次数:21302 次
--oracle10g create table BREAKOUT ( OBJECTID INTEGER not null, GJ NVARCHAR2(10), RWIDTH NUMBER(38,8), RHEIGHT NUMBER(38,8) ); insert into BREAKOUT (OBJECTID,GJ,Rwidth,Rheight) values (1,'500X600',0,0); insert into BREAKOUT (OBJECTID,GJ,Rwidth,Rheight) values (2,'700X600',0,0); insert into BREAKOUT (OBJECTID,GJ,Rwidth,Rheight) values (3,'300X400',0,0); select * from BREAKOUT;
update breakout set RWIDTH=substr(gj,1,instr(gj,'X')-1),RHEIGHT=substr(gj,instr(gj,'X')+1,length(gj)-instr(gj,'X')); commit;
------解决方案--------------------
--是不是这个意思?? create table BREAKOUT ( OBJECTID INTEGER not null, GJ NVARCHAR(10), RWIDTH NUMERIC(38,8), RHEIGHT NUMERIC(38,8) ); insert into BREAKOUT (OBJECTID,GJ,Rwidth,Rheight) values (1,'500X600',0,0); insert into BREAKOUT (OBJECTID,GJ,Rwidth,Rheight) values (2,'700X600',0,0); insert into BREAKOUT (OBJECTID,GJ,Rwidth,Rheight) values (3,'300X400',0,0); UPDATE BREAKOUT SET RWIDTH=LEFT(GJ,CHARINDEX('X',GJ)-1), RHEIGHT=RIGHT(GJ,LEN(GJ)-CHARINDEX('X',GJ)) SELECT * FROM BREAKOUT --- OBJECTID GJ RWIDTH RHEIGHT 1 500X600 500.00000000 600.00000000 2 700X600 700.00000000 600.00000000 3 300X400 300.00000000 400.00000000