create table T1 (
e INTEGER,
F INTEGER
);
Begin
delete from T1;
insert into T1 values (1, 3);
insert into T1 values (2, 4);
end
select * from t1;
/* lo de arriba es SQL; debajo es el programa PL/SQL*/
DECLARE
a number;
b number;
BEGIN
select e,f into a,b /*Cursor implicito, acepta solo un registro*/
from T1
where e > 1; /* Este select asigna el atributo e->a y f ->b, de todos aquellos registros cuyo atributo e->1 */
insert into T1 values (b,a);
END;
/****************************************/
Set serveroutput on; /* habilita salida output */
/* habilitar en Toad, seleccionar pestaña DBMS Output, seleccionar Turn Output On (circulo rojo inferior izquierdo )*/
BEGIN
dbms_output.put_line('Hola mundo');
END;
/****************************************/
DECLARE
Precio integer :=18;
BEGIN
if precio >=15 then
dbms_output.put_line('El precio es : ' || precio);
end if;
END;
/****************************************/
DECLARE
Precio integer :=18;
texto varchar2(5);
BEGIN
if precio >=15 then
texto:='Mayor';
else
texto:='Menor';
end if;
dbms_output.put_line('Es precio es ' || Texto || ' y es' || Precio);
END;
/****************************************/
/* Queda en un ciclo hasta que se cumpla la condicion */
DECLARE
i integer :=0;
BEGIN
LOOP
i:= i + 1;
dbms_output.put_line(i || '- Hola mundo');
exit when i =10;
END LOOP;
END;
No hay comentarios:
Publicar un comentario