You are on page 1of 11

LAPORAN UTS

PEMOGRAMAN SQL LANJUT

“MEMBUAT VIEW DAN STORE PROCEDURE”

Disusun Oleh :

Nama : Erwan Saputra
NPM : 16753019
Program Studi : Manajemen Informatika 4 A

JURUSAN EKONOMI DAN BISNIS
POLITEKNIK NEGERI LAMPUNG
BANDAR LAMPUNG
2018
VIEW DAN STORE PROCEDURE

Dalam Pembuatan View dan Store Procedure ini memiliki 5 tabel yaitu seperti
berikut.

1. Tabel Mahasiswa

2. Tabel Dosen

3. Tabel Pendidikan

4. Tabel Prodi
5. Tabel Status Akademik

MASTER QUERY DATA
Select * from MAHASISWA
Select * from DOSEN
Select * from PENDIDIKAN
Select * from PRODI
Select * from STATUS_AKADEMIK

VIEW
Nama View Query Eksekusi
mhs_MI Create view mhs_MI as select * from mhs_MI
select
a.nama,a.npm,a.sex,b.nmpr
odi,a.thn_masuk from
MAHASISWA as a, PRODI as
b
where a.idprodi=b.idprodi
and b.nmprodi='Manajemen
Informatika'
mhs_AgribisnisPan Create view select * from
gan mhs_AgribisnisPangan as mhs_AgribisnisPangan
select
a.nama,a.npm,a.sex,b.nmpr
odi,a.thn_masuk from
MAHASISWA as a, PRODI as
b
where a.idprodi=b.idprodi
and b.nmprodi='Agribisnis
Pangan'
mhs_Agribisnis Create view select * from
mhs_Agribisnis as mhs_Agribisnis
select
a.nama,a.npm,a.sex,b.nmpr
odi,a.thn_masuk from
MAHASISWA as a, PRODI as
b
where a.idprodi=b.idprodi
and
b.nmprodi='Agribisnis'
mhs_Akuntansi Create view mhs_Akuntansi select * from
as mhs_Akuntansi
select
a.nama,a.npm,a.sex,b.nmpr
odi,a.thn_masuk from
MAHASISWA as a, PRODI as
b
where a.idprodi=b.idprodi
and b.nmprodi='Akuntansi'
dosen_MI Create view dosen_MI as select * from
select a.nmdosen,a.gelar, dosen_MI
b.nmprodi,c.nmpendidikan
from DOSEN as a,PRODI as
b , PENDIDIKAN as c where
a.idprodi=b.idprodi
and
a.idpendidikan=c.idpendid
ikan and
b.nmprodi='Manajemen
Informatika'
dosen_Agribisnis Create view select * from
dosen_Agribisnis as dosen_Agribisnis
select a.nmdosen,a.gelar,
b.nmprodi,c.nmpendidikan
from DOSEN as a,PRODI as
b , PENDIDIKAN as c where
a.idprodi=b.idprodi
and
a.idpendidikan=c.idpendid
ikan
and
b.nmprodi='Agribisnis'
dosen_AGBPangan Create view select * from
dosen_AGBPangan as dosen_AGBPangan
select a.nmdosen,a.gelar,
b.nmprodi,c.nmpendidikan
from DOSEN as a,PRODI as
b , PENDIDIKAN as c where
a.idprodi=b.idprodi
and
a.idpendidikan=c.idpendid
ikan
and b.nmprodi='Agribisnis
Pangan'
dosen_Akuntansi Create view select * from
dosen_Akuntansi as dosen_Akuntansi
select a.nmdosen,a.gelar,
b.nmprodi,c.nmpendidikan
from DOSEN as a,PRODI as
b , PENDIDIKAN as c where
a.idprodi=b.idprodi
and
a.idpendidikan=c.idpendid
ikan
and b.nmprodi='Akuntansi'
mhs_Aktif Create view mhs_Aktif as select * from
Select a.nama,a.npm, mhs_Aktif
b.nmstatusaka ,c.nmprodi
from MAHASISWA as a,
STATUS_AKADEMIK as
b,PRODI as c where
a.idstatusaka=b.idstatusa
ka and
a.idprodi=c.idprodi
and
b.nmstatusaka='aktif'
status_MHS Create view status_MHS as select * from
select Count(a.nama) as status_MHS
JumlahMahasiswa,
b.nmstatusaka
from MAHASISWA as a,
STATUS_AKADEMIK as b
where
a.idstatusaka=b.idstatusa
ka
group by b.nmstatusaka
Jumlah_Mhs Create view Jumlah_Mhs as select * from
select COUNT(*)as Jumlah_Mhs
JumlahMhs from MAHASISWA
Jumlah_Dosen Create view Jumlah_Dosen select * from
as Jumlah_Dosen
select COUNT(*)as
JumlaDosen from DOSEN
JumlahMHS_Perempu Create view select * from
an JumlahMHS_Perempuan as JumlahMHS_Perempuan
select Count(a.nama) as
JumlahMHS_P, b.nmprodi
from MAHASISWA as a,
PRODI as b where
a.idprodi=b.idprodi and
a.sex='P' group by
b.nmprodi
JumlahMHS_Laki Create view select * from
JumlahMHS_Laki as JumlahMHS_Laki
select Count(a.nama) as
JumlahMHS_L, b.nmprodi
from MAHASISWA as a,
PRODI as b where
a.idprodi=b.idprodi and
a.sex='L' group by
b.nmprodi
JumlahDosen_Laki Create view select * from
JumlahDosen_Laki as JumlahDosen_Laki
select Count(a.nmdosen)
as JumlahDosen_L,
b.nmprodi
from DOSEN as a, PRODI as
b
where a.idprodi=b.idprodi
and a.sex='L'
group by b.nmprodi
JumlahDosen_Perem Create view select * from
puan JumlahDosen_Perempuan as JumlahDosen_Perempua
select Count(a.nmdosen) n
as JumlahDosen_P,
b.nmprodi
from DOSEN as a, PRODI as
b
where a.idprodi=b.idprodi
and a.sex='P'
group by b.nmprodi
JmlhDosen_brdasar Create view select * from
kn_PenddknProdi JmlhDosen_brdasarkn_Pendd JmlhDosen_brdasarkn_
knProdi as PenddknProdi
select count(a.nmdosen)
as JumlahDosen,
b.nmpendidikan, c.nmprodi
from DOSEN as a,
PENDIDIKAN as b, PRODI as
c
where
a.idpendidikan=b.idpendid
ikan and
a.idprodi=c.idprodi
group by b.nmpendidikan,
c.nmprodi
JmlhMhs_brdasarkn Create view select * from
_ProdiStatusaka JmlhMhs_brdasarkn_ProdiSt JmlhMhs_brdasarkn_Pr
atusaka as odiStatusaka
select count(a.nama) as
JumlahMhs, b.nmprodi
,c.nmstatusaka
from MAHASISWA as a,
PRODI as b,
STATUS_AKADEMIK as c
where a.idprodi=b.idprodi
and
a.idstatusaka=c.idstatusa
ka
group by b.nmprodi,
c.nmstatusaka
STORE PROCEDURE
Nama Store Query Eksekusi
Procedure
Menampilkan_sex create procedure Menampilkan_sex_mhs exec
_mhs @sex nvarchar as Menampilkan_sex_m
begin hs[l]
select * from MAHASISWA
where sex= @sex
end
go
Menampilkan_tem create procedure exec
patLhr_mhs Menampilkan_tempatLhr_mhs @tempat_lhr Menampilkan_tempa
@tempat_lhr nvarchar(30) as tLhr_mhs[Metro]
begin
select * from MAHASISWA
where tempat_lhr=@tempat_lhr
end
go
Menampilkan_tah create procedure exec
unMasuk_ Menampilkan_tahunMasuk_mhs @thn_masuk Menampilkan_tahun
nvarchar(4) as Masuk_mhs[2015]
begin
select * from MAHASISWA
where thn_masuk=@thn_masuk
end
go
Menampilkan_pro create procedure Menampilkan_prodi_mhs exec
di_mhs @prodi int as Menampilkan_prodi
begin _mhs[2]
select * from MAHASISWA
where idprodi=@prodi
end
go
Menampilkan_npm create procedure Menampilkan_npm_mhs exec
_mhs @npm int as Menampilkan_npm_m
begin hs[16753031]
select * from MAHASISWA
where npm=@npm
end
go
Menampilkan_nam create procedure Menampilkan_nama_mhs exec
a_mhs @nama nvarchar(50) as Menampilkan_nama_
begin mhs[MayaN]
select * from MAHASISWA
where nama=@nama
end
go
Menampilkan_id_ create procedure Menampilkan_id_mhs exec
mhs @ID_Mhs int as Menampilkan_id_mh
begin s[1]
select * from MAHASISWA
where idmhs=@ID_Mhs
end
go
Menampilkan_sta create procedure exec
tusAka_Mhs Menampilkan_statusAka_Mhs @statusaka int Menampilkan_statu
as sAka_Mhs[1]
begin
select * from MAHASISWA
where idstatusaka=@statusaka
end
go
Menampilkan_tem create procedure exec
patLhr_dan_prod Menampilkan_tempatLhr_dan_prodi @tempat Menampilkan_tempa
i nvarchar(30),@prodi int as tLhr_dan_prodi
begin Metro,3
select * from MAHASISWA
where tempat_lhr=@tempat and
idprodi=@prodi
end
go
input_DataMhs create procedure input_DataMhs @npm exec
nvarchar(8), @nama nvarchar(50), input_DataMhs
@tempat nvarchar(30),@tanggal date, @sex '16753034','Andre
nvarchar(1),@thn_masuk ','BLampung','199
nvarchar(4),@idprodi int, @idstatusaka 8-08-
int 08','L','2016','2
as ','1'
begin
insert into MAHASISWA
(npm,nama,tempat_lhr,tanggal_lhr,sex,thn
_masuk,idprodi,idstatusaka)
values
(@npm,@nama,@tempat,@tanggal,@sex,@thn_m
asuk,@idprodi,@idstatusaka)
end
go
input_DataDosen Create procedure input_DataDosen @nama exec
nvarchar(50), @gelar nvarchar(50), input_DataDosen
@tempat_lhr nvarchar(50), @tanggal_lhr 'Zuriati','S.Kom.
date, @sex nvarchar(1), @idprodi int, ,M.Kom','Bandarla
@idpendidikan int mpung','1972/06/0
As 1','P','1','1'
begin
insert into
dosen(nmdosen,gelar,tempat_lhr,tanggal_l
hr,sex,idprodi,idpendidikan)
Values(@nama,@gelar,@tempat_lhr,@tanggal
_lhr,@sex,@idprodi,@idpendidikan)
End
GO
input_DataProdi create procedure input_DataProdi exec
@nmprodi nvarchar(50), @akreditasi input_DataProdi
nvarchar(50), 'Manajemen
@tahun_berdiri int Informatika
as A','A',2006
begin
insert into prodi
(nmprodi,akreditasi,thn_berdiri)
values
(@nmprodi,@akreditasi,@tahun_berdiri)
End
GO
input_DaataPend create procedure input_DaataPendidikan exec
idikan @nmpendidikan nvarchar(50) input_DaataPendid
As ikan 'S2'
begin
insert into pendidikan(nmpendidikan)
values(@nmpendidikan)
end
GO
input_Datastatu create procedure input_DatastatusAka exec
sAka @nmstatusaka nvarchar(50) input_DatastatusA
as ka 'Sakit'
begin
insert into status_akademik(nmstatusaka)
values(@nmstatusaka)
end
GO
update_DataMaha create procedure update_DataMahasiswa exec
siswa @idmhs int,@npm nvarchar(8), @nama update_DataMahasi
nvarchar(50), swa
@tempat_lhr nvarchar(30),@tanggal_lhr '11','16753031','
date, @sex nvarchar(1),@thn_masuk MayaN','LamTeng',
nvarchar(4),@idprodi int, @idstatusaka '1998-05-
int 05','P','2015','2
as ','2'
begin
update MAHASISWA
set
npm = @npm,
nama = @nama,
tempat_lhr = @tempat_lhr,
tanggal_lhr = @tanggal_lhr,
sex = @sex,
thn_masuk = @thn_masuk,
idprodi = @idprodi,
idstatusaka = @idstatusaka
where idmhs = @idmhs
end
go
update_DataDose Create procedure update_DataDosen exec
n @iddosen int, @nmdosen update_DataDosen
nvarchar(50),@gelar nvarchar(30), '10','Bu
@tempat_lhr nvarchar(30), @tanggal_lhr Zur','S.Kom','Jak
date,@sex nvarchar(1),@idprodi int, arta','1975-01-
@idpendidikan int 09','P','2','3'
As
begin
update dosen set
nmdosen=@nmdosen,gelar=@gelar,
tempat_lhr=@tempat_lhr,
tanggal_lhr=@tanggal_lhr,
sex=@sex,idprodi=@idprodi,
idpendidikan=@idpendidikan
where iddosen=@iddosen
end
GO
update_DataPend Create procedure update_DataPendidikan exec
idikan @idpendidikan int, @nmpendidikan update_DataPendid
varchar(50) ikan 2,'Sarjana
As 1'
begin
update pendidikan set
nmpendidikan=@nmpendidikan
where idpendidikan=@idpendidikan
end
GO

update_DataProd create procedure update_DataProdi exec
i @idprodi int, @nmprodi varchar(50), update_DataProdi
@akreditasi varchar(1), @tahun_berdiri 1,'Manajemen
int Informatika
As A','B','2005'
begin
update prodi set nmprodi=@nmprodi,
akreditasi=@akreditasi,
thn_berdiri=@tahun_berdiri
where idprodi=@idprodi
end
Go
update_StatusAk Create procedure update_StatusAkademik exec
ademik @idstatusaka int, @nmstatusaka update_StatusAkad
varchar(50) emik 3,'Wisuda'
As
begin
update status_akademik set
nmstatusaka=@nmstatusaka
where idstatusaka=@idstatusaka
end
GO

deleteDatamhs create procedure deleteDatamhs @idmhs exec
int deletedatamhs 12
as
begin
delete from mahasiswa where idmhs=@idmhs
end
GO
deleteDatadosen create procedure deleteDatadosen exec
@iddosen int deleteDatadosen 1
as
Begin
delete from DOSEN where iddosen=@iddosen
End
Go
deleteDataPendi create procedure deleteDataPendidikan exec
dikan @idpendidikan int deleteDataPendidi
As kan 2
begin
delete from pendidikan where
idpendidikan=@idpendidikan
End
GO
deleteDataProdi Create procedure deleteDataProdi exec
@idprodi int deleteDataProdi 2
As
begin
delete from prodi where idprodi=@idprodi
End
GO
deleteDataStatu create procedure deleteDataStatusaka exec
saka @idstatusaka int deleteDataStatusa
As ka 1
begin
delete from status_akademik where
idstatusaka=@idstatusaka
End
GO