sábado, 10 de diciembre de 2011

Clase 10/12/2011

Creación de Tablas


inserción de Datos





en la pagina 7 de la guia entregada el comentario esta erroneo, en SQL el comentarios es:





una linea --


más de una linea /* comentarios */








utilizacion de PL/SQL





create table t1 (e integer, f integer);


insert into t1 values (1,3);


insert into t1 values (2,4);






declare
a t1.e%TYPE;
b t1.f%TYPE;
begin
select e,f into a,b from t1 where e> 1;
insert into t1 values (b,a);
commit;
end;
select * from t1


CONDICIONES

IF

ejemplo

declare
a t1.e%TYPE;
b t1.f%TYPE;
cont number:=0;
begin
select count(*) into cont from t1 where e>1;
if (cont > 1) then
dbms_output.put_line('Existe más de un registro');
elsif cont = 0 then
dbms_output.put_line('No hay Datos');
insert into t1 values (2,4);
commit;
else
select e,f into a,b from t1 where e> 1;
dbms_output.put_line('Inserto');
insert into t1 values (b,a);
commit;
end if;
end;


LOOP


begin
fecha:=trunc(sysdate);
loop
if to_char(fecha,'mm') = '12' then
dbms_output.put_line('Año ' fecha);
end if;
fecha:=add_months(fecha, 1);
exit when fecha > to_date('31/12/2020','dd/mm/yyyy');
end loop;
end;

No hay comentarios:

Publicar un comentario