LABO_SELECTIVAS

download LABO_SELECTIVAS

of 13

Transcript of LABO_SELECTIVAS

  • 7/24/2019 LABO_SELECTIVAS

    1/13

    /*INTEGRANTES:

    BELITO HILARIO ROSMEL CODIGO: 12200145

    KAROL JUAREZ MAGALLANES CODIGO: 12200014*/

    --PROBLEMA1--Construir un programa que permita cargar 3 sueldos de 3 empleados diferentes,--determine cual de ellos es el mayor, cual es el menor y cual es el nmero medio--(Debe indicar el nombre y apellido tambin).

    set serveroutput ondeclarev_id1 number:=&identidad1;v_id2 number:=&identidad;v_id3 number:=&identidad3;

    v_salario1 number;v_salario2 number;v_salario3 number;mayor number;medio number;

    menor number;empleado1 employees%rowtype;empleado2 employees%rowtype;empleado3 employees%rowtype;

    beginselect salary into v_salario1from employeeswhere employee_id=v_id1;

    select salary into v_salario2from employeeswhere employee_id=v_id2;

    select salary into v_salario3from employeeswhere employee_id=v_id3;

    if v_salario1 >= v_salario2 and v_salario1 >= v_salario3 then if v_salario2 >= v_salario3 then mayor:=v_id1; medio:=v_id2; menor:=v_id3; else mayor:=v_id1; medio:=v_id3;

    menor:=v_id2; end if;elsif v_salario2 >= v_salario1 and v_salario2 >= v_salario3 then if v_salario1 >= v_salario3 then mayor:=v_id2; medio:=v_id1; menor:=v_id3; else mayor:=v_id2; medio:=v_id3;

  • 7/24/2019 LABO_SELECTIVAS

    2/13

    menor:=v_id1; end if;elsif v_salario3 >= v_salario1 and v_salario3 >= v_salario2 then if v_salario1 >= v_salario2 then mayor:=v_id3; medio:=v_id1; menor:=v_id2; else mayor:=v_id3; medio:=v_id2; menor:=v_id1; end if;end if;

    select * into empleado1from employeeswhere employee_id=mayor;

    select * into empleado2from employeeswhere employee_id=medio;

    select * into empleado3from employees

    where employee_id=menor;dbms_output.put_line('*************EMPLEADO CON SUELDO MAYOR*************');dbms_output.put_line('ID:' || empleado1.employee_id);dbms_output.put_line('NOMBRE:' || empleado1.first_name);dbms_output.put_line('APELLIDO:' || empleado1.last_name);dbms_output.put_line('SALARIO:' || TO_CHAR(empleado1.salary, 'L999,999.99'));dbms_output.put_line('*************EMPLEADO CON SUELDO MEDIO*************');dbms_output.put_line('ID:' || empleado2.employee_id);dbms_output.put_line('NOMBRE:' || empleado2.first_name);dbms_output.put_line('APELLIDO:' || empleado2.last_name);dbms_output.put_line('SALARIO:' || TO_CHAR(empleado2.salary, 'L999,999.99'));dbms_output.put_line('*************EMPLEADO CON SUELDO MENOR*************');

    dbms_output.put_line('ID:' || empleado3.employee_id);dbms_output.put_line('NOMBRE:' || empleado3.first_name);dbms_output.put_line('APELLIDO:' || empleado3.last_name);dbms_output.put_line('SALARIO:' || TO_CHAR(empleado3.salary, 'L999,999.99'));dbms_output.put_line('***************************************************');end;

    --PROBLEMA2--Calcular el costo del servicio de mudanza, de acuerdo a la distancia entre elpunto--de partida y de llegada para dos empleados diferentes (Estos datos se deben obtener de la ciudad--a la cual pertenece cada empleado). Para calcular el costo se debe tener en cu

    enta: Si los dos--empelados pertenecen a la misma ciudad se cobrar S/. 700 por concepto de mudanza, si son de--diferente ciudad y diferente Pas se cobrar S/. 30000, si son de diferentes regiones S/. 25000.

    set serveroutput ondeclarev_id1 number:=&identidad1;v_id2 number:=&identidad2;

  • 7/24/2019 LABO_SELECTIVAS

    3/13

    v_depa1 number;v_depa2 number;

    v_ciudad1 number;v_ciudad2 number;

    v_pais1 countries.country_id%TYPE;v_pais2 countries.country_id%TYPE;

    v_region1 number;v_region2 number;

    v_costoMudanza number;beginselect d.department_id,l.location_id,co.country_id,r.region_id into v_depa1,v_ciudad1,v_pais1,v_region1from employees e,departments d,locations l,countries co,regions rwhere e.employee_id=v_id1 AND e.DEPARTMENT_ID=d.DEPARTMENT_ID AND d.LOCATION_ID=l.LOCATION_ID AND l.COUNTRY_ID=co.COUNTRY_ID AND co.REGION_ID=r.REGION_ID;

    select d.department_id,l.location_id,co.country_id,r.region_id into v_depa2,v_ciudad2,v_pais2,v_region2from employees e,departments d,locations l,countries co,regions rwhere e.employee_id=v_id2 AND e.DEPARTMENT_ID=d.DEPARTMENT_ID AND d.LOCATION_ID=l.LOCATION_ID AND l.COUNTRY_ID=co.COUNTRY_ID AND co.REGION_ID=r.REGION_ID;

    if v_ciudad1 = v_ciudad2 then v_costoMudanza:=700; end if;

    if v_ciudad1 != v_ciudad2 AND v_pais1 != v_pais2 then

    v_costoMudanza:=3000; end if; if v_region1 != v_region2 then v_costoMudanza:=25000; end if;

    dbms_output.put_line('************LUGAR INICIO***********');dbms_output.put_line('PERSONA:'||v_id1);dbms_output.put_line('DEPARTAMENTO:'||v_depa1);dbms_output.put_line('CIUDAD:'||v_ciudad1);dbms_output.put_line('PAIS:'||v_pais1);dbms_output.put_line('REGION:'||v_region1);dbms_output.put_line('************LUGAR DESTINO***********');

    dbms_output.put_line('PERSONA:'||v_id2);dbms_output.put_line('DEPARTAMENTO:'||v_depa2);dbms_output.put_line('CIUDAD:'||v_ciudad2);dbms_output.put_line('PAIS:'||v_pais2);dbms_output.put_line('REGION:'||v_region2);dbms_output.put_line('************COSTO MUDANZA***********');dbms_output.put_line('COSTO MUDANZA: '||TO_CHAR(v_costoMudanza, 'L999,999.99'));dbms_output.put_line('************************************');

    end;

  • 7/24/2019 LABO_SELECTIVAS

    4/13

    --PROBLEMA3--Disee un programa que determine el sueldo total de un empleadocualquiera. El jefe--del departamento donde labora el empleado ha prometido incrementar en 20 % elsueldo de dicho--empleado si la cantidad de aos que labora en la empresa es mayor a 10, si es mayor a 5 aos el--15 % de lo contrario el 10%. En su respuesta debe considerar el nombre completo del jefe del departamento.

    set serveroutput ondeclarev_idEmp number:=&identidad;v_fecha date;v_tiempo number;v_salario number;v_idmanager number;v_aumentoSueldo number;empleado employees%rowtype;empleadoManager employees%rowtype;beginselect e.hire_date,e.salary,m.employee_id into v_fecha,v_salario,v_idmanagerfrom employees e,employees m

    where e.employee_id=v_idEmp AND e.manager_id=m.employee_id;v_tiempo:=round(months_between(sysdate,v_fecha)/12);

    if v_tiempo>10 then

    v_aumentoSueldo:=v_salario*0.2; end if; if v_tiempo>5 AND v_tiempo

  • 7/24/2019 LABO_SELECTIVAS

    5/13

    DBMS_OUTPUT.PUT_LINE('AUMENTO: '||TO_CHAR(v_aumentoSueldo, 'L999,999.99'));DBMS_OUTPUT.PUT_LINE('MONTO TOTAL: '|| TO_CHAR(empleado.salary*(1+nvl(empleado.commission_pct,0))+v_aumentoSueldo, 'L999,999.99'));end;

    --PROBLEMA4--Disee un programa que determine la categora de un empleado en base a sus aos de servicio,--de acuerdo a la siguiente tabla:--Aos Categora--20 15 A--14 10 B--9 6 C--5 0 D--El programa debe mostrar informacin detallada del empleado, su categora y el nombre del jefe.--Debe incluir el sueldo total a recibiren el mes, nombre del departamento dondelabora, la direccin,--la ciudad y el nombre de la regin a donde pertenece.

    set serveroutput ondeclarev_idEmp number:=&identidad;v_fecha date;

    v_tiempo number;v_categoria char(1);v_nombreJefe varchar2(50);v_nombreDepa varchar2(50);v_dirCiudad varchar2(50);v_region varchar2(50);empleado employees%rowtype;beginselect e.hire_date,m.first_name||' '||m.last_name,d.department_name,l.STREET_ADDRESS,r.region_nameinto v_fecha,v_nombreJefe,v_nombreDepa,v_dirCiudad,v_regionfrom employees e,employees m,departments d,locations l,countries co,regions rwhere e.employee_id=v_idEmp AND

    e.manager_id=m.employee_id AND e.DEPARTMENT_ID=d.DEPARTMENT_ID AND d.LOCATION_ID=l.LOCATION_ID AND l.COUNTRY_ID=co.COUNTRY_ID AND co.REGION_ID=r.REGION_ID;

    v_tiempo:=round(months_between(sysdate,v_fecha)/12);

    if v_tiempo >= 0 and v_tiempo = 6 and v_tiempo = 10 and v_tiempo =15 and v_tiempo 20 then v_categoria:='No Categorizado'; end if;

    select * into empleadofrom employeeswhere employee_id=v_idEmp;

  • 7/24/2019 LABO_SELECTIVAS

    6/13

    DBMS_OUTPUT.PUT_LINE('****************CATEGORIZACION DE EMPLEADOS*********************');DBMS_OUTPUT.PUT_LINE('*******************JEFE**********************');DBMS_OUTPUT.PUT_LINE('NOMBRE:'||v_nombreJefe);DBMS_OUTPUT.PUT_LINE('*******************EMPLEADO**********************');DBMS_OUTPUT.PUT_LINE('ID: '||empleado.employee_id);DBMS_OUTPUT.PUT_LINE('NOMBRE Y APELLIDO: '||empleado.first_name||' '||empleado.last_name);DBMS_OUTPUT.PUT_LINE('CATEGORIA: '||v_categoria);DBMS_OUTPUT.PUT_LINE('AOS TRABAJO: '||v_tiempo||'aos');DBMS_OUTPUT.PUT_LINE('SALARIO: '||TO_CHAR(empleado.salary*(1+nvl(empleado.commission_pct,0)), 'L999,999.99'));DBMS_OUTPUT.PUT_LINE('DEPARTAMENTO: '||v_nombreDepa);DBMS_OUTPUT.PUT_LINE('CIUDAD: '||v_dirCiudad);DBMS_OUTPUT.PUT_LINE('REGION: '||v_region);end;

    --PROBLEMA5--Una empresa de bienes races ofrece casas de inters social, bajo las siguientes condiciones: Si los ingresos--del comprador son menores de $8000, el enganche ser del 7% del costo de la casay el resto se distribuir en--pagos mensuales, a pagar en diez aos. Si los ingresos del comprador son de $800

    0 o mas, el enganche ser del--10 % del costo de la casa y el resto se distribuir en pagos mensuales a pagar en 7 aos.--Cada empleado puede comprar una casa para lo cual en el primer mes se debe calcular el enganche en funcin a su--sueldo total a percibir. Luego se debe calcular el monto a pagar en cada mes por los siguientes 10 aos.--El reporte debe mostrar el sueldo del empleado, el descuento por enganche y elmonto a pagar el prximo mes--por los siguientes aos que dure la deuda. Debe ingresar el monto total de la casa para lo cual el programa--debe validar si la suma a calcular por el enganche excede al 50 % del sueldo en este caso no se podr realizar

    --la operacin por sueldo insuficiente.

    set serveroutput ondeclare v_id number:=&identidad; v_costoCasa number:=&costo_casa; v_enganche number; v_pagoMensual number; empleado employees%rowtype; v_ingresos number; situacion varchar2(100); aos number;begin

    select * into empleado from employees where employee_id=v_id; v_ingresos:=empleado.salary*(1+nvl(empleado.commission_pct,0));if v_ingresos0.5*v_ingresos then situacion:='NO HABILITADO'; else aos:=10; v_pagoMensual:=((v_costoCasa-v_enganche)/(aos*12));

  • 7/24/2019 LABO_SELECTIVAS

    7/13

    situacion:='HABILITADO'; end if; else v_enganche:=0.1*v_costoCasa; if v_enganche>0.5*v_ingresos then situacion:='NO HABILITADO'; else aos:=10; v_pagoMensual:=((v_costoCasa-v_enganche)/(aos*12)); situacion:='HABILITADO'; end if;end if;

    DBMS_OUTPUT.PUT_LINE('****************COMPRA DE UNA CASA*********************'

    ); DBMS_OUTPUT.PUT_LINE('*********DATOS EMPLEADO*******'); DBMS_OUTPUT.PUT_LINE('NOMBRE Y APELLIDO: '||empleado.first_name||' '||empleado.last_name); DBMS_OUTPUT.PUT_LINE('SALARIO TOTAL: '||TO_CHAR(v_ingresos,'L999,999.99')); DBMS_OUTPUT.PUT_LINE('*********DATOS CASA*******'); DBMS_OUTPUT.PUT_LINE('COSTO CASA:'||TO_CHAR(v_costoCasa,'L999,999.99')); DBMS_OUTPUT.PUT_LINE('ENGANCHE:'||TO_CHAR(v_enganche,'L999,999.99')); DBMS_OUTPUT.PUT_LINE('PAGO MENSUAL:'||TO_CHAR(v_pagoMensual, 'L999,999.99')); DBMS_OUTPUT.PUT_LINE('AOS A PAGAR:'||aos);

    DBMS_OUTPUT.PUT_LINE('SITUACION:'||situacion);end;

    --PROBLEMA 6--El gobierno del estado Peruano desea reforestar un bosque. Si la superficie del terreno excede a--1 milln de metros cuadrados, entonces decidir sembrar de la siguiente manera:-- Superficie del bosque (%) Tipo de rbol-- 70% pino-- 20% oyamel-- 10% cedro--Si la superficie del terreno es menor o igual a un milln de metros cuadrados, entonces decidir

    --sembrar de la siguiente manera:-- Superficie del bosque (%) Tipo de rbol-- 50% pino-- 30% oyamel-- 20% cedro--El gobierno desea saber el numero de pinos, oyameles y cedros que tendr que sembrar en el bosque,--si se sabe que en 10 metros cuadrados caben 8 pinos, en 15 metros cuadrados caben 15 oyameles--y en 18 metros cuadrados caben 10 cedros.

    set serveroutput ondeclare

    superficieBosque number:=&cantidad_metros_cubicos; superficiePino number; superficieOyamel number; superficieCedro number; numeroDePino number; numeroDeOyamel number; numeroDeCedro number;begin if superficieBosque > 1000000 then superficiePino:=0.7*superficieBosque;

  • 7/24/2019 LABO_SELECTIVAS

    8/13

    superficieOyamel:=0.2*superficieBosque; superficieCedro:=0.1*superficieBosque; else superficiePino:=0.5*superficieBosque; superficieOyamel:=0.3*superficieBosque; superficieCedro:=0.2*superficieBosque; end if;

    numeroDePino:=round((superficiePino/10)*8); numeroDeOyamel:=round((superficiePino/15)*15); numeroDeCedro:=round((superficiePino/18)*10);

    DBMS_OUTPUT.PUT_LINE('************************REFORESTACION DE BOSQUE***********************'); DBMS_OUTPUT.PUT_LINE('**********DIVISION DEL TERRENO*********'); DBMS_OUTPUT.PUT_LINE('SUPERFICIE DEL BOSQUE:'||superficieBosque||' metro Cubicos'); DBMS_OUTPUT.PUT_LINE('SUPERFICIE DE PINO:'||superficiePino||' metro Cubicos'); DBMS_OUTPUT.PUT_LINE('SUPERFICIE DE OYAMEL:'||superficieOyamel||' metro Cubicos'); DBMS_OUTPUT.PUT_LINE('SUPERFICIE DE CEDRO:'||superficieCedro||' metro Cubicos'); DBMS_OUTPUT.PUT_LINE('**********CANTIDAD A SEMBRAR***********');

    DBMS_OUTPUT.PUT_LINE('CANTIDAD DE PINO:'||numeroDePino||' unidades'); DBMS_OUTPUT.PUT_LINE('CANTIDAD DE OYAMEL:'||numeroDeOyamel||' unidades'); DBMS_OUTPUT.PUT_LINE('CANTIDAD DE CEDRO:'||numeroDeCedro||' unidades');end;

    --PROBLEMA 7--La empresa paga a sus empleados un mes de gratificacin en los meses de Julio yDiciembre.--Dicha gratificacin vara de acuerdo a los aos de servicios que tiene el empleado,como--se muestra en el siguiente cuadro:-- Aos de Servicios % de Gratificacin-- 0 a 5 60

    -- 6 a 8 80-- 9 a ms 60 100--Adems todos los empleados reciben un descuento por AFP del 9%. Calcular el total a recibir--de un empleado por ao. En el reporte debe indicar los datos personales, la cantidad de aos--de servicio y el porcentaje de gratificacin percibida.

    set serveroutput ondeclare identidad number:=&id_empleado; aosTrabajo number; salarioTotal number;

    empleado employees%rowtype; gratificacion number; montoGratificacion number; descuentoAFP number; gratificacionFinal number;begin select * into empleado from employees where employee_id=identidad; aosTrabajo:=round(months_between(sysdate,empleado.hire_date)/12);salarioTotal:=empleado.salary*(1+nvl(empleado.commission_pct,0));

  • 7/24/2019 LABO_SELECTIVAS

    9/13

    if aosTrabajo>0 AND aosTrabajo=6 AND aosTrabajo=9 then gratificacion:=1; end if; montoGratificacion:=salarioTotal*(1+gratificacion); descuentoAFP:=montoGratificacion*0.09; gratificacionFinal:=(montoGratificacion-descuentoAFP);DBMS_OUTPUT.PUT_LINE('****************SALARIO DEL EMPLEADO********************

    *'); DBMS_OUTPUT.PUT_LINE('*********DATOS EMPLEADO*******'); DBMS_OUTPUT.PUT_LINE('NOMBRE Y APELLIDO: '||empleado.first_name||' '||empleado.last_name); DBMS_OUTPUT.PUT_LINE('*********DESCUENTOS Y GRATIFICACION*******'); DBMS_OUTPUT.PUT_LINE('AOS DE SERVICIO:'||aosTrabajo); DBMS_OUTPUT.PUT_LINE('SALARIO MENSUAL: '||TO_CHAR(salarioTotal, 'L999,999.99')); DBMS_OUTPUT.PUT_LINE('PORCENTAJE GRATIFICACION:'||gratificacion*100||'%'); DBMS_OUTPUT.PUT_LINE('SALARIO MAS GRATIFICACION:'||TO_CHAR(montoGratificacion,'L999,999.99'));

    DBMS_OUTPUT.PUT_LINE('DESCUENTO POR AFP:'||TO_CHAR(descuentoAFP, 'L999,999.99')); DBMS_OUTPUT.PUT_LINE('GRATIFICACION JULIO Y DICIEMBRE:'||TO_CHAR(gratificacionFinal, 'L999,999.99')); DBMS_OUTPUT.PUT_LINE('GRATIFICACION TOTAL AL AO:'||TO_CHAR(2*gratificacionFinal, 'L999,999.99'));

    end;

    --PROBLEMA 8--Una empresa se encarga de la venta y distribucin de CD. Los clientes pueden adquirir--los artculos por cantidad. Los precios son:

    -- S/. 3.50 si se compra hasta 9 unidades.-- S/. 3.30 si se compra entre 10 unidades y hasta 99.-- S/. 3.10 si se compra entre 100 y 499 unidades.-- S/. 2.80 para ms de 500.--Realizar un programa que calcule el sueldo neto a recibir por un empleado quecompra n CD,--los mismos que le son descontados de forma automtica de su salario.

    set serveroutput ondeclare identidad number:=&id_empleado; cantDiscos number:=&numero_discos; salarioTotal number;

    empleado employees%rowtype; precioDisco number; descuento number; SalarioFinal number;begin select * into empleado from employees where employee_id=identidad;salarioTotal:=empleado.salary*(1+nvl(empleado.commission_pct,0));

    if cantDiscos

  • 7/24/2019 LABO_SELECTIVAS

    10/13

    precioDisco:=3.50; elsif cantDiscos>=10 AND cantDiscos=100 AND cantDiscos=500 then precioDisco:=2.80; end if; descuento:= precioDisco*cantDiscos; salarioFinal:=salarioTotal-descuento;DBMS_OUTPUT.PUT_LINE('****************COMPRA DISCOS*********************');

    DBMS_OUTPUT.PUT_LINE('*************DATOS EMPLEADO**********'); DBMS_OUTPUT.PUT_LINE('NOMBRE Y APELLIDO: '||empleado.first_name||' '||empleado.last_name); DBMS_OUTPUT.PUT_LINE('SALARIO MENSUAL: '||TO_CHAR(salarioTotal,'L999,999.99')); DBMS_OUTPUT.PUT_LINE('*************COMPRAS *************'); DBMS_OUTPUT.PUT_LINE('DISCOS COMPRADOS:'||cantDiscos||'discos'); DBMS_OUTPUT.PUT_LINE('PRECIO DISCO:'||TO_CHAR(precioDisco,'L999,999.99')); DBMS_OUTPUT.PUT_LINE('DESCUENTO TOTAL COMPRA:'||TO_CHAR(descuento,'L999,999.99')); DBMS_OUTPUT.PUT_LINE('SALARIO FINAL DEL EMPLEADO:'||TO_CHAR(salarioFinal,'L999,999.99'));

    end;

    --PROBLEMA 9--El dueo de una empresa desea planificar las decisiones financieras que tomara en el siguiente ao.--La manera de planificarlas depende de lo siguiente:--Si actualmente su capital se encuentra con saldo negativo, pedir un prstamo bancario para que su--nuevo saldo sea de 100 000. Si su capital tiene actualmente un saldo positivopedir un prstamo bancario--para tener un nuevo saldo de 200 000, pero si su capital tiene actualmente unsaldo superior a los 200 000

    --no pedir ningn prstamo. Posteriormente repartir su presupuesto de la siguiente maera.-- 50 000 para equipo de computo-- 20 000 para mobiliario--y del resto la mitad ser para la compra de insumos y la otra para otorgar incentivos al personal.--Mostrar que cantidades se destinaran para la compra de insumos e incentivos alpersonal, se sabe--que los incentivos de personal se repartirn equitativamente entre todos. Muestre tambin en el reporte--el monto total a cobrar por un empleado incluido el incentivo que recibir, en caso de que fuera necesario,--a cuanto ascendera la cantidad que se pedira al banco.

    set serveroutput ondeclare capital number:=&capital; v_id number:=&Identidad; empleado employees%rowtype; cantidadEmpleados number; prestamo number; resto number; insumos number;

  • 7/24/2019 LABO_SELECTIVAS

    11/13

    incentivos number; incentivoPorEmpleado number; sueldoTotal number; montoTotal number;

    begin select * into empleado from employees where employee_id=v_id;select count(employee_id)

    into cantidadEmpleados from employees;sueldoTotal:=empleado.salary*(1+nvl(empleado.commission_pct,0));

    if capital=0 AND capital200000 then prestamo:=0; end if;

    resto:=capital-50000-20000; insumos:=resto/2; incentivos:=resto/2; incentivoPorEmpleado:=incentivos/cantidadEmpleados; montoTotal:=sueldoTotal+incentivoPorEmpleado;DBMS_OUTPUT.PUT_LINE('************* EMPRESA**************');

    DBMS_OUTPUT.PUT_LINE('************DESTINO DEL PRESUPUESTO*************'); DBMS_OUTPUT.PUT_LINE('GASTO EN INSUMOS:'||TO_CHAR(insumos, 'L999,999.99')); DBMS_OUTPUT.PUT_LINE('INCENTIVO TOTAL A LOS EMPLEADO:'||TO_CHAR(incentivos, 'L999,999.99')); DBMS_OUTPUT.PUT_LINE('CANTIDAD DE EMPLEADOS:'||cantidadEmpleados); DBMS_OUTPUT.PUT_LINE('INCENTIVO POR EMPLEADO:'||TO_CHAR(incentivoPorEmpleado,

    'L999,999.99')); dbms_output.put_line('**************PRESTAMO BANCARIO******************'); if prestamo>200000 then DBMS_OUTPUT.PUT_LINE('PRESTAMO:' || 'No Necesita'); else DBMS_OUTPUT.PUT_LINE('PRESTAMO:'||TO_CHAR(prestamo, 'L999,999.99')); end if; dbms_output.put_line('*********************EMPLEADO**********************'); DBMS_OUTPUT.PUT_LINE('CODIGO:'||empleado.employee_id); DBMS_OUTPUT.PUT_LINE('NOMBRE COMPLETO:'|| empleado.first_name || ' ' || empleado.last_name); DBMS_OUTPUT.PUT_LINE('SUELDO TOTAL:'|| TO_CHAR(sueldoTotal, 'L999,999.99')); DBMS_OUTPUT.PUT_LINE('MONTO TOTAL:'||TO_CHAR(montoTotal, 'L999,999.99'));

    end;

    --PROBLEMA 10--Una compaa de seguros ofrece a sus clientes seguros de sepelio:-- Categora Pago mensual (S/.)-- A 40-- B 30-- C 20-- D 10

  • 7/24/2019 LABO_SELECTIVAS

    12/13

    --Segn el cuadro de categoras del ejercicio 4 determine el monto total a percibir--por un empleado, recuerde que estos pagos por seguro solo son para los empleados que no son jefes.

    set serveroutput ondeclarev_idEmp number:=&identidad;v_fecha date;v_tiempo number;v_categoria char(1);v_nombreJefe varchar2(50);v_nombreDepa varchar2(50);v_dirCiudad varchar2(50);v_region varchar2(50);montoTotalSeguro number;empleado employees%rowtype;beginselect e.hire_date,m.first_name||' '||m.last_name,d.department_name,l.STREET_ADDRESS,r.region_nameinto v_fecha,v_nombreJefe,v_nombreDepa,v_dirCiudad,v_regionfrom employees e,employees m,departments d,locations l,countries co,regions rwhere e.employee_id=v_idEmp AND e.manager_id=m.employee_id AND

    e.DEPARTMENT_ID=d.DEPARTMENT_ID AND d.LOCATION_ID=l.LOCATION_ID AND l.COUNTRY_ID=co.COUNTRY_ID AND co.REGION_ID=r.REGION_ID;

    v_tiempo:=round(months_between(sysdate,v_fecha)/12);

    if v_tiempo >= 0 and v_tiempo = 6 and v_tiempo = 10 and v_tiempo =15 and v_tiempo 20 then v_categoria:='No tiene categoria'; end if;

    select * into empleadofrom employeeswhere employee_id=v_idEmp;

    DBMS_OUTPUT.PUT_LINE('****************CATEGORIZACION DE EMPLEADOS*********************');DBMS_OUTPUT.PUT_LINE('*******************JEFE**********************');DBMS_OUTPUT.PUT_LINE('NOMBRE:'||v_nombreJefe);DBMS_OUTPUT.PUT_LINE('*******************EMPLEADO**********************');DBMS_OUTPUT.PUT_LINE('ID: '||empleado.employee_id);DBMS_OUTPUT.PUT_LINE('NOMBRE Y APELLIDO: '||empleado.first_name||' '||empleado.last_name);DBMS_OUTPUT.PUT_LINE('CATEGORIA: '||v_categoria);

  • 7/24/2019 LABO_SELECTIVAS

    13/13

    DBMS_OUTPUT.PUT_LINE('AOS TRABAJO: '||v_tiempo||'aos');DBMS_OUTPUT.PUT_LINE('MONTO TOTAL SEGURO: '||TO_CHAR(montoTotalSeguro, 'L999,999.99'));DBMS_OUTPUT.PUT_LINE('DEPARTAMENTO: '||v_nombreDepa);DBMS_OUTPUT.PUT_LINE('CIUDAD: '||v_dirCiudad);DBMS_OUTPUT.PUT_LINE('REGION: '||v_region);end;