当前位置: 编程技术>移动开发
本页文章导读:
▪(转)oracle触发器-增 删 改 (转)oracle触发器----增 删 改
:new --为一个引用最新的列值;:old --为一个引用以前的列值; 这两个变量只有在使用了关键字 "FOR EACH ROW"时才存在.且update语句两个都有,而insert只有:new ,delect 只.........
▪ Ext.data.Store 小细节征集 Ext.data.Store 小细节收集
1. 常用的初始化方法新建一个store一般的方法如下(一般从服务器获得数据)
var storeRecord = new Ext.data.Record.create(
[
{name: 'id', type: 'string', mapping:'projectId'},
{name:.........
▪ CCSprite各种动作引见和使用 CCSprite各种动作介绍和使用
// 触摸屏
-(void) ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
for( UITouch *touch in touches ) {
CGPoint location = [touch locationInView: [touch view]];
location = [[CCDirector sh.........
[1](转)oracle触发器-增 删 改
来源: 互联网 发布时间: 2014-02-18
(转)oracle触发器----增 删 改
:new --为一个引用最新的列值;
:old --为一个引用以前的列值; 这两个变量只有在使用了关键字 "FOR EACH ROW"时才存在.且update语句两个都有,而insert只有:new ,delect 只有:old;
Old,New新解:
:new中存储的是T表更新内容中已经更新完成的字段;
:old中存储的是更新前的tid内容;
http://topic.csdn.net/u/20071027/22/e560007b-de46-4d34-9c13-f4fe1a08c89b.html
另,在使用触发器的过程中,会遇到ORA-04091的错误,这个错误与触发器中对基于进行了SELECT等操作有关。
create or replace trigger tri_card_ins
after insert on card
for each row
declare
T_COUNT number(10);
begin
select count(*) into T_COUNT from card c,bts b
where c.ne_name = b.bts_num and c.ne_name = :new.ne_name;
update bts s set s.trx_count =T_COUNT
where s.bts_num = :new.ne_name;
end tri_card_ins;
下面是错误信息。
[img]
[/img]
这个应该是不可以的。《精通Oracle 10g pl sql编程》
DML触发器使用注意事项:
当编写DML触发器时,触发器代码不能从触发器所对应的基表中读取数据。例如,如果要基于EMP表建立触发器,那么该触发器的执行代码不能包含对EMP表的查询操作。尽管在建立触发器时不会出现任何错误,但在执行相应触发操作时会显示错误信息。
你的问题应该是对CARD表建立的触发器,又查询CARD表。
提问人的追问 2011-07-01 09:25 那么如果我如要现实这样的功能,该怎么做啊?
回答人的补充 2011-07-01 13:47 实现这个功能应该有很多种方法。比如说可以在同一个SESSION里先执行INSERT的操作,再执行UPDATE.或者把整个逻辑写到一个存储过程里。
这样也可以在执行INSERT操作失败时都会回滚,而不会出现脏数据。
提问人的追问 2011-07-01 15:29 小弟刚接触oracle ,不太理解你说的session怎么使用。能给个例子吗?最好具体的点。谢谢啦。谢谢啦。
回答人的补充 2011-07-02 12:09 可以建一个中间表。
CREATE TABLE CARD_MAP (
NE_NAME VARCHAR2(20),
C_DATE DATE
);
修改触发器。应该可以答到你的要求
create or replace trigger tri_card_ins
after insert on card
for each row
declare
T_COUNT number(10);
begin
INSERT INTO CARD_MAP(NE_NAME,C_DATE) VALUES(:NEW.NE_NAME, SYSDATE);
select count(*) into T_COUNT from CARD_MAP c,bts b
where c.ne_name = b.bts_num and c.ne_name = :new.ne_name;
update bts s set s.trx_count =T_COUNT
where s.bts_num = :new.ne_name;
end tri_card_ins;
回答人的补充 2011-07-05 22:44 把触发修改一下。不需要每行触发。把你写的触发器中去除FOR EACH ROW
文章分别引自于:
1、http://www.iteye.com/topic/882897;
2、http://wenwen.soso.com/z/q300377397.htm?sp=2080;
:new --为一个引用最新的列值;
:old --为一个引用以前的列值; 这两个变量只有在使用了关键字 "FOR EACH ROW"时才存在.且update语句两个都有,而insert只有:new ,delect 只有:old;
Old,New新解:
:new中存储的是T表更新内容中已经更新完成的字段;
:old中存储的是更新前的tid内容;
http://topic.csdn.net/u/20071027/22/e560007b-de46-4d34-9c13-f4fe1a08c89b.html
//触发器名UserToTemp
create or replace trigger UserToTemp after insert or update or delete
on user_info for each row//对表user_info操作时触发以下事件
declare//声明变量
integrity_error exception;
errno integer;
errmsg char(200);
dummy integer;
found boolean;
sexy varchar2(20);
begin
if inserting then
select sex into sexy from user_info_test;//取出user_info_test表中的sex字段的值赋值给变量sexy
insert into User_info_temp(ID,UserName,PassWord,Createdate,Status) values(:NEW.ID,:NEW.UserName,sexy,:NEW.createdate,:NEW.status);//:NEW.UserName的值为表user_info新增加的数据
elsif updating then
update User_info_temp set ID=:NEW.ID,UserName=:NEW.UserName,PassWord=:NEW.PassWord,Status=:NEW.Status where id=:OLD.id;
elsif deleting then
delete from User_info_temp where id=:OLD.id;
end if;
exception
when integrity_error then
raise_application_error(errno, errmsg);
end;
另,在使用触发器的过程中,会遇到ORA-04091的错误,这个错误与触发器中对基于进行了SELECT等操作有关。
create or replace trigger tri_card_ins
after insert on card
for each row
declare
T_COUNT number(10);
begin
select count(*) into T_COUNT from card c,bts b
where c.ne_name = b.bts_num and c.ne_name = :new.ne_name;
update bts s set s.trx_count =T_COUNT
where s.bts_num = :new.ne_name;
end tri_card_ins;
下面是错误信息。
[img]
[/img]
这个应该是不可以的。《精通Oracle 10g pl sql编程》
DML触发器使用注意事项:
当编写DML触发器时,触发器代码不能从触发器所对应的基表中读取数据。例如,如果要基于EMP表建立触发器,那么该触发器的执行代码不能包含对EMP表的查询操作。尽管在建立触发器时不会出现任何错误,但在执行相应触发操作时会显示错误信息。
你的问题应该是对CARD表建立的触发器,又查询CARD表。
提问人的追问 2011-07-01 09:25 那么如果我如要现实这样的功能,该怎么做啊?
回答人的补充 2011-07-01 13:47 实现这个功能应该有很多种方法。比如说可以在同一个SESSION里先执行INSERT的操作,再执行UPDATE.或者把整个逻辑写到一个存储过程里。
这样也可以在执行INSERT操作失败时都会回滚,而不会出现脏数据。
提问人的追问 2011-07-01 15:29 小弟刚接触oracle ,不太理解你说的session怎么使用。能给个例子吗?最好具体的点。谢谢啦。谢谢啦。
回答人的补充 2011-07-02 12:09 可以建一个中间表。
CREATE TABLE CARD_MAP (
NE_NAME VARCHAR2(20),
C_DATE DATE
);
修改触发器。应该可以答到你的要求
create or replace trigger tri_card_ins
after insert on card
for each row
declare
T_COUNT number(10);
begin
INSERT INTO CARD_MAP(NE_NAME,C_DATE) VALUES(:NEW.NE_NAME, SYSDATE);
select count(*) into T_COUNT from CARD_MAP c,bts b
where c.ne_name = b.bts_num and c.ne_name = :new.ne_name;
update bts s set s.trx_count =T_COUNT
where s.bts_num = :new.ne_name;
end tri_card_ins;
回答人的补充 2011-07-05 22:44 把触发修改一下。不需要每行触发。把你写的触发器中去除FOR EACH ROW
文章分别引自于:
1、http://www.iteye.com/topic/882897;
2、http://wenwen.soso.com/z/q300377397.htm?sp=2080;
[2] Ext.data.Store 小细节征集
来源: 互联网 发布时间: 2014-02-18
Ext.data.Store 小细节收集
1. 常用的初始化方法
新建一个store一般的方法如下(一般从服务器获得数据)
2. 加载数据
3. 后台要返回对应的json格式的数据
Store会自动根据传递来的数据进行加载
根据
进行自动匹配,多余的就不匹配.丢弃
2. ext2.2 和 ext3.2 返回值success区别
Ext.data.Store 加载时候
ext2.2 不用管前台放回的是false还是true
ext3.2 如果前台放回success false 无法加载数据 一定要是true
3. stroe加载数据,传递额外信息.并获取
比如:加载数据的同时要向客户端传递查询的sql语句的实现
1. 常用的初始化方法
新建一个store一般的方法如下(一般从服务器获得数据)
var storeRecord = new Ext.data.Record.create(
[
{name: 'id', type: 'string', mapping:'projectId'},
{name: 'name', type: 'string', mapping:'projectName'},
{name: 'type', type: 'string', mapping:'type'}
]
);
var configProjectAll = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({ // 加载的远程url
url : 'findConfigProjectAll.action'
}),
autoLoad : false, // 是否自动加载 一般设置false 需要时候在加载
sortInfo : {field: 'name', direction: 'ASC'},//DESC 排序依据和升or降
reader : new Ext.data.JsonReader({
totalProperty : 'totalProperty',
root : 'root', // 服务器返回json的根信息
id :'projectId' // 值为对应的mapping的值
},
storeRecord // 要加载的数据
)
});
2. 加载数据
store创建好后,需要调用load()函数加载数据,
加载成功后才能对store中的数据进行操作。
load()调用的完整过程如下面的代码所示。
store.load({
// params是在store加载时发送的附加参数。
params: {start:0,limit:20},
// records参数表示获得的数据(是一个数组)
// options表示执行load()时传递的参数
// success表示是否加载成功(true or false)
// 上面参数具体的用法可以通过ff进行查看,一目了然
callback: function(records, options, success){
// 可以通过参数sucess判断是否成功加载
},
// 用来指定回调函数执行时的作用域。
scope: store,// 一般不用
//Add为true时,load()得到的数据会添加在原来的store数据的末尾,
//否则会先清除之前的数据,再将得到的数据添加到store中。
add: true // 一般不用
});
3. 后台要返回对应的json格式的数据
{
"root":
[
{
"processVersion":2,
"projectId":84,
"projectName":"a",
"projectVersion":" ",
"type":1
},{
"processVersion":2,
"projectId":85,
"projectName":"b",
"projectVersion":"10.1",
"type":1
},{
"processVersion":2,
"projectId":86,
"projectName":"c",
"projectVersion":"10.2",
"type":1
}
],
"success":true,
"totalProperty":3
}
Store会自动根据传递来的数据进行加载
根据
{name: 'id', type: 'string', mapping:'projectId'},
进行自动匹配,多余的就不匹配.丢弃
2. ext2.2 和 ext3.2 返回值success区别
Ext.data.Store 加载时候
ext2.2 不用管前台放回的是false还是true
ext3.2 如果前台放回success false 无法加载数据 一定要是true
3. stroe加载数据,传递额外信息.并获取
比如:加载数据的同时要向客户端传递查询的sql语句的实现
store.load({
params:{
start:0,
limit:pageSize
},
callback: function(records, options, success){
sql = this.reader.jsonData.sql; // sql 就是附加的json信息
}
});
[3] CCSprite各种动作引见和使用
来源: 互联网 发布时间: 2014-02-18
CCSprite各种动作介绍和使用
// 触摸屏
-(void) ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
for( UITouch *touch in touches ) {
CGPoint location = [touch locationInView: [touch view]];
location = [[CCDirector sharedDirector] convertToGL: location];
// 各种动作
// 瞬时动作
// 设置坐标
id action0 = [CCPlace actionWithPosition:ccp(240,160)];
// 隐藏
id action1 = [CCHide action];
// 显示
id action2 = [CCShow action];
// 隐藏/显示
id action3 = [CCToggleVisibility action];
// 延时动作
// 移动
id action4 = [CCMoveTo actionWithDuration:2 position:ccp(0,0)];
id action5 = [CCMoveBy actionWithDuration:2 position:ccp(100,100)];
// 弹跳
id action6 = [CCJumpTo actionWithDuration:2 position:ccp(0,200) height:30 jumps:5];
id action7 = [CCJumpBy actionWithDuration:2 position:ccp(100, 0) height:30 jumps:5];
// 贝塞尔移动
ccBezierConfig bezier;
bezier.controlPoint_1 = ccp(0, 0);
bezier.controlPoint_2 = ccp(100, 300);
bezier.endPosition = ccp(0,100);
id action8 = [CCBezierTo actionWithDuration:3 bezier:bezier];
id action9 = [CCBezierBy actionWithDuration:3 bezier:bezier];
// 缩放
id action10 = [CCScaleTo actionWithDuration:2 scale:4];
id action11 = [CCScaleBy actionWithDuration:2 scale:0.5];
// 旋转
id action12 = [CCRotateTo actionWithDuration:2 angle:180];
id action13 = [CCRotateBy actionWithDuration:2 angle:-180];
// 闪烁
id action14 = [CCBlink actionWithDuration:3 blinks:5];
// 色调变化
id action15 = [CCTintTo actionWithDuration:2 red:255 green:0 blue:0];
id action16 = [CCTintBy actionWithDuration:0.5 red:0 green:255 blue:255];
// 淡化到/淡入/淡出
id action17 = [CCFadeTo actionWithDuration: 1 opacity:80];
id action18 = [CCFadeIn actionWithDuration:1.0f];
id action19 = [CCFadeOut actionWithDuration:1.0f];
// 动画顺序播放
CCAnimation *animation = [CCAnimation animation];
[animation setDelay:2];
// 这里就添加两帧,需要自己添加
[animation addFrameWithTexture:sprTest.texture rect:CGRectMake(0, 0, 44, 34)];
[animation addFrameWithTexture:sprTest.texture rect:CGRectMake(0, 34, 44, 34)];
id action20 = [CCAnimate actionWithAnimation: animation];
// 组合动作
// 动画序列
id action21 = [CCSequence actions:action19, action18, nil];
// 重复动作
id action22 = [CCRepeat actionWithAction:action21 times:10];
// 延时动作
id action23 = [CCDelayTime actionWithDuration:1];
// 同时动作
id action24 = [CCSpawn actions:action0, action4, action21, nil];
// 无限循环动作
id action25 = [CCRepeatForever actionWithAction:action21];
// 扩展动作
// 回调动作
id acf0 = [CCCallFunc actionWithTarget:self selector:@selector(CallBack1)];
// 回调动作,传递动画自身指针
id acf1 = [CCCallFuncN actionWithTarget:self selector:@selector(CallBack2:)];
// 回调动作,传递动画自身指针已经一个参数
id acf2 = [CCCallFuncND actionWithTarget:self selector:@selector(CallBack3:data:) data:(void*)2];
id action26 = [CCSequence actions:action19, action18, acf0, action23, action0, nil];
// 反转动作,只能用在有方向有顺序的动作上
id action27 = [action9 reverse];
// 速度变化
//id ac = [CCSequence actions:action9,action27,nil];
id actiontest = [CCMoveBy actionWithDuration:0.5 position:ccp(200,0)];
id ac = [CCSequence actions:actiontest,actiontest, nil];
// 渐快
id action28 = [CCEaseIn actionWithAction:ac rate:3];
// 渐慢
id action29 = [CCEaseOut actionWithAction:ac rate:3];
// 先渐快再渐慢
id action30 = [CCEaseInOut actionWithAction:ac rate:3];
// 正弦波移动
id action31 = [CCEaseSineIn actionWithAction:ac];
id action32 = [CCEaseSineOut actionWithAction:ac];
id action33 = [CCEaseSineInOut actionWithAction:ac];
// 由极慢至极快
id action34 = [CCEaseExponentialIn actionWithAction:ac];
// 由极快到极慢
id action35 = [CCEaseExponentialOut actionWithAction:ac];
// 由极慢至极快 再由极快到慢
id action36 = [CCEaseExponentialInOut actionWithAction:ac];
// 手动设定速度,可通过SetSpeed不断调整
id action37 = [CCSpeed actionWithAction:ac speed:(CCRANDOM_0_1() * 5)];
[sprTest runAction:action37];
}
}
// 回调函数1
- (void) CallBack1
{
[sprTest runAction:[CCTintBy actionWithDuration:2 red:255 green:0 blue:255]];
}
// 回调函数2
- (void) CallBack2:(id)sender
{
[sender runAction:[CCTintBy actionWithDuration:1 red:255 green:0 blue:255]];
}
// 回调函数3
-(void) CallBack3:(id)sender data:(void*)data
{
[sender runAction:[CCTintBy actionWithDuration:(NSInteger)data red:255 green:0 blue:255]];
}
最新技术文章: