选择显示字体大小

db2编程序技巧 (三)

  另一种为
      pcursor1: for loopcs1 as  cousor1  cursor  as
select  market_code  as market_code
           from tb_market_code
           for update
        do
        end for;
       这种方式的优点是比较简单,不用(也不允许)使用open,fetch,close。
  但不能使用with  hold 选项。如果在游标循环内要使用commit,rollback则不能使用这种方式。如果没有commit或rollback的要求,推荐使用这种方式(看来for这种方式有问题)。

修改游标的当前记录的方法
update tb_market_code set market_code='0' where current of cursor1;
不过要注意将cursor1定义为可修改的游标
  declare cursor1 cursor for select market_code from tb_market_code 
for update;

for update 不能和group by、 distinct、 order by、 for read only及union, except, or intersect但 union all除外)一起使用。



1.5 类似decode的转码操作
oracle中有一个函数  select decode(a1,'1','n1','2','n2','n3') aa1 from
db2没有该函数,但可以用变通的方法
select case a1 
when '1' then 'n1' 
when '2' then 'n2' 
else 'n3'
    end as aa1 from

1.6 类似charindex查找字符在字串中的位置
locate(‘y’,’dfdasfay’)
查找’y’ 在’dfdasfay’中的位置。

1.7 类似datedif计算两个日期的相差天数
days(date(‘2001-06-05’)) – days(date(‘2001-04-01’))
days 返回的是从  0001-01-01 开始计算的天数
1.8 写udf的例子
c写见sqllib\samples\cli\udfsrv.c

1.9 创建含identity值(即自动生成的id)的表
建这样的表的写法
create table test
     (t1 smallint not null
        generated always as identity
        (start with 500, increment by 1),
      t2 char(1));
在一个表中只允许有一个identity的column.


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons