Professional Documents
Culture Documents
Archivo Practicas Paramañ
Archivo Practicas Paramañ
---- eliminar
create or replace function pa_eliminar_matricula (ma int) returns boolean as
$$
declare
begin --try
if EXISTS(Select matricula_id from matricula where matricula_id=ma)
then
DELETE FROM public.matricula
WHERE matricula_id=ma;
return true ;
else
return false;
end if;
End
$$ language 'plpgsql'
----actualizar
End
$$ language 'plpgsql'
order by 5
------
---insertar
select*from ubigeo
return 0;
else
return 1 ;
end if ;
Exception when others then
return -1 ;
End
$$ language 'plpgsql'
----eliminar
select pa_eliminar_alumno(162)
----actualizar
select*from alumno
order by 7
-- alumno :125 , curso:2
select cu.codigo_curso as Codigo , cu.nombre_curso as
Nombre_Curso ,cu1.nombre_curso ,
dmPre.nota_promedio as Nota_promedio
from detalle_matricula dm inner join matricula ma on ma.matricula_id =
dm.matricula_id
inner join alumno al on ma.alumno_id = al.alumno_id
inner join grupo gr on dm.grupo_id=gr.grupo_id
inner join curso cu on gr.curso_id = cu.curso_id
inner join curso_curso cuCu on cuCu.curso_id=cu.curso_id
inner join curso cu1 on cuCu.curso_id_pre = cu1.curso_id
LEFT JOIN detalle_matricula dmPre ON dmPre.matricula_id = ma.matricula_id AND
dmPre.curso_id = cuCu.curso_id_pre
where al.numero_documento = '73720161' and Cu.curso_id=2
GROUP by
cu.codigo_curso,cu.nombre_curso,cu1.nombre_curso,dmPre.nota_promedio,cuCu.curso_id_
pre
select*from detalle_matricula
select*from ambiente
IF contH = 0 THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
END;
$$ LANGUAGE plpgsql;
IF contH = 0 THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
END;
$$ LANGUAGE plpgsql;
select *
from
create or replace function pa_matricula (mat int, grup int, est character(1), nota
numeric) returns int as
$$
DECLARE
promedio int; creditos int; totalcred int;
BEGIN
select sum(cu.creditosdm.nota_promedio) /sum(cu.creditos) into promedio
from alumno al inner join matricula ma on ma.alumno_id= al.alumno_id
inner join detalle_matricula dm on dm.matricula_id = ma.matricula_id
inner join grupo gr on dm.grupo_id = gr.grupo_id
inner join curso cu on gr.grupo_id = cu.curso_id
where gr.semestre_id = '2022-2' and al.alumno_id = 153;
case promedio
when promedio > 0 and promedio <= 10 then creditos = 16;
when promedio > 10 and promedio <= 15 then creditos = 22;
when promedio > 15 and promedio <=20 then creditos = 27;
hor_id int;
begin