You are on page 1of 2

3-create or replace

TRIGGER REMPLASE
BEFORE INSERT
ON PRODUCT_INFORMATION
for each row
declare
codigo number(6);
nombre varchar2(30);
precio number(6);
begin
codigo:=:new.PRODUCT_ID;
nombre:=:new.PRODUCT_NAME;
precio:=:new.LIST_PRICE ;
dbms_output.put_line(codigo||' ' ||nombre||' '||precio);
end;
================================================================================
==
select EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALA
RY,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID from HR.EMPLOYEES;
select DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID from HR.DEPARTMENTS;
select LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID fro
m HR.LOCATIONS;
select COUNTRY_ID,COUNTRY_NAME,REGION_ID from HR.COUNTRIES;
---11111111111111111111111111111
CREATE OR REPLACE FUNCTION MOSTRAR(COD NUMBER)
RETURN VARCHAR2
IS
PAIS VARCHAR2(50);
BEGIN
SELECT C.COUNTRY_NAME INTO PAIS
FROM EMPLOYEES E INNER JOIN DEPARTMENTS D
ON E.DEPARTMENT_ID=D.DEPARTMENT_ID
INNER JOIN LOCATIONS L
ON D.LOCATION_ID=L.LOCATION_ID
INNER JOIN COUNTRIES C
ON L.COUNTRY_ID=C.COUNTRY_ID
WHERE EMPLOYEE_ID=COD;
RETURN PAIS;
END;
================111
select FIRST_NAME||' '||LAST_NAME AS "NOMBRE APELLIDO",MOSTRAR(198) AS PAIS from
HR.EMPLOYEES;
CREATE OR REPLACE FUNCTION MOSTRAR_V1(COD NUMBER)
RETURN VARCHAR2
IS
PAIS VARCHAR2(50);
BEGIN
SELECT E.FIRST_NAME||' '||E.LAST_NAME||' '||C.COUNTRY_NAME INTO PAIS
FROM EMPLOYEES E INNER JOIN DEPARTMENTS D
ON E.DEPARTMENT_ID=D.DEPARTMENT_ID
INNER JOIN LOCATIONS L
ON D.LOCATION_ID=L.LOCATION_ID
INNER JOIN COUNTRIES C
ON L.COUNTRY_ID=C.COUNTRY_ID
WHERE EMPLOYEE_ID=COD;
RETURN PAIS;
END;

BEGIN
DBMS_OUTPUT.PUT_LINE(MOSTRAR_V1(198));
END;
2----===========================================================================
====================================
================================================================================
====================================
CREATE OR REPLACE PROCEDURE MOSTRAR_V(COD NUMBER)
IS
CURSOR V_EMPLEADO IN SELECT E.FIRST_NAME,E.LAST_NAME,C.COUNTRY_NAME
FROM EMPLOYEES E INNER JOIN DEPARTMENTS D
ON E.DEPARTMENT_ID=D.DEPARTMENT_ID
INNER JOIN LOCATIONS L
ON D.LOCATION_ID=L.LOCATION_ID
INNER JOIN COUNTRIES C
ON L.COUNTRY_ID=C.COUNTRY_ID
WHERE EMPLOYEE_ID=COD;
BETWEEN SALARY SALARIOX AND SALARIOY;
NOMBRE VARCHAR2(20);
APELLIDO VARCHAR2(20);
PAIS VARCHAR2(50);
BEGIN
FOR M_EMPLEADO IN V_EMPLEADO LOOP
NOMBRE:=M_EMPLEADO.FIRST_NAME;
APELLIDO:=M_EMPLEADO.LAST_NAME;
PAIS:=M_EMPLEADO.COUNTRY_NAME;
DBMS_OUTPUT.PUT_LINE('NOMBRE APELLIDO '||NOMBRE||' '||APELLIDO||' PAIS '||PAIS)
;
END LOOP;
END;
EXECUTE MOSTRAR_V(198);