--ORACLE try int v_id; select 1 into v_id from t_gpslatest where f_code='12'; if v_d=1 then update t_gpslatest set f_style='99',f_longtitude='88',f_latitude='77',f_direction='66',f_speed='55',f_time=sysdate where f_code = '11'; else insert into t_gpslatest(f_code,f_style,f_longtitude,f_latitude,f_direction,f_speed,f_time)values('11','22222','333333','44444','55555','66666',sysdate); end if
--你的值都写错了,不是12吗,怎么又成了11了 declare rec int := 0; begin select count(1) into rec from t_gpslatest where f_code='12'; if rec>0 then update t_gpslatest set f_style='99',f_longtitude='88',f_latitude='77' ,f_direction='66',f_speed='55',f_time=sysdate where f_code = '12'; else insert into t_gpslatest(f_code,f_style,f_longtitude,f_latitude,f_direction,f_speed,f_time) values('12','22222','333333','44444','55555','66666',sysdate); end if; commit; exception when others then rollback; dbms_output.put_line('error'); end; /
declare i number; begin select count(*) into i from t_gpslatest where f_code='12'; if i>0 then update t_gpslatest set f_style='99',f_longtitude='88',f_latitude='77',f_direction='66',f_speed='55',f_time=sysdate where f_code = '12'; else insert into t_gpslatest(f_code,f_style,f_longtitude,f_latitude,f_direction,f_speed,f_time) values('11','22222','333333','44444','55555','66666',sysdate); end if; end;
try
int v_id;
select 1 into v_id from t_gpslatest where f_code='12';
if v_d=1 then
update t_gpslatest set f_style='99',f_longtitude='88',f_latitude='77',f_direction='66',f_speed='55',f_time=sysdate where f_code = '11';
else
insert into t_gpslatest(f_code,f_style,f_longtitude,f_latitude,f_direction,f_speed,f_time)values('11','22222','333333','44444','55555','66666',sysdate);
end if
--你的值都写错了,不是12吗,怎么又成了11了
declare
rec int := 0;
begin
select count(1) into rec from t_gpslatest where f_code='12';
if rec>0 then
update t_gpslatest set f_style='99',f_longtitude='88',f_latitude='77'
,f_direction='66',f_speed='55',f_time=sysdate
where f_code = '12';
else
insert into t_gpslatest(f_code,f_style,f_longtitude,f_latitude,f_direction,f_speed,f_time)
values('12','22222','333333','44444','55555','66666',sysdate);
end if;
commit;
exception
when others then
rollback;
dbms_output.put_line('error');
end;
/
i number;
begin
select count(*) into i from t_gpslatest where f_code='12';
if i>0 then
update t_gpslatest
set f_style='99',f_longtitude='88',f_latitude='77',f_direction='66',f_speed='55',f_time=sysdate
where f_code = '12';
else
insert into t_gpslatest(f_code,f_style,f_longtitude,f_latitude,f_direction,f_speed,f_time)
values('11','22222','333333','44444','55555','66666',sysdate);
end if;
end;
9楼的答案也对
6楼的思想严谨,顶.......楼主可以结贴了.
好使。谢谢兄弟们。凡是参与的都有分。大家有份是我的一贯作风。