Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 invalid object name

Author  Topic 

kun
Starting Member

1 Post

Posted - 2009-11-10 : 05:03:55
i have store procedure :

_____________________________________________________________

CREATE PROCEDURE S_BROWSE_KEUANGAN_MAHASISWA

(
@IdProgdi Int,
@TahunAjaran Varchar(10),
@Semester int,
@StatusX Int,
@Angkatan Int,
@OP Int
)

AS

set nocount on

declare
@Mhs_nim Varchar(10),
@Mhs_nm Varchar(50),
@mhs_ank Int,
@Status Varchar(5),
@SKS Int,
@JumlahBiaya float,
@JumlahUang Float,
@Sisa Float,
@Keterangan Varchar(50),
@Beasiswa Varchar(100),
@NamaProgdi Varchar(50),
@NamaFakultas Varchar(50),
@Ujian tinyint,
@Approval tinyint,
@Idmahasiswa Varchar(8) ,
@KET_GM Varchar(50),
@KET_APPRV varchar(255)

create Table #Semu
(
Mhs_nim Varchar(10),
Mhs_nm Varchar(50),
mhs_ank Int,
Status Varchar(5),
SKS Int,
JumlahBiaya float,
JumlahUang Float,
Sisa Float,
Keterangan Varchar(50),
Beasiswa Varchar(100),
NamaProgdi Varchar(50),
NamaFakultas Varchar(50),
Ujian tinyint,
Approval tinyint,
Idmahasiswa Varchar(8),
KET_GM Varchar(50),
KET_APPRV varchar(255)
)


If @Angkatan <> ''
Begin
If @StatusX = 6
begin
declare ANANG cursor for Select Mhs_nim, Dbo.F_NAMA_MHS_SKRIPSI (IdMahasiswa,@TahunAjaran,@Semester),mhs_ank, Dbo.F_NAMA_STATUS_AKD(Stat_akd), Dbo.F_TOTAL_SKS_AMBIL_SEMESTER (IdMahasiswa,@TahunAjaran,@Semester,1), Dbo.F_NAMA_BEASISWA (IdMahasiswa,@TahunAjaran,@Semester), Dbo.F_NMPROGDI(idprogdi), Dbo.F_NMFAKULTAS(IdProgdi),Dbo.F_HISTORI_STATUS_KEUANGAN (IdMahasiswa,@TahunAjaran,@Semester) ,Dbo.F_HISTORI_STATUS_APPROVAL (IdMahasiswa,@TahunAjaran,@Semester) , Idmahasiswa, Dbo.F_KETERANGAN_GM(IdMahasiswa,@TahunAjaran,@Semester),Dbo.F_KETERANGAN_APPROVAL(IdMahasiswa,@TahunAjaran,@Semester) From T_MAHASISWA where Idprogdi=@IdProgdi and mhs_ank=@Angkatan Order by mhs_nim
end
Else
Begin
declare ANANG cursor for Select Mhs_nim, Dbo.F_NAMA_MHS_SKRIPSI (IdMahasiswa,@TahunAjaran,@Semester),mhs_ank, Dbo.F_NAMA_STATUS_AKD(Stat_akd), Dbo.F_TOTAL_SKS_AMBIL_SEMESTER (IdMahasiswa,@TahunAjaran,@Semester,1), Dbo.F_NAMA_BEASISWA (IdMahasiswa,@TahunAjaran,@Semester), Dbo.F_NMPROGDI(idprogdi), Dbo.F_NMFAKULTAS(IdProgdi),Dbo.F_HISTORI_STATUS_KEUANGAN (IdMahasiswa,@TahunAjaran,@Semester) ,Dbo.F_HISTORI_STATUS_APPROVAL (IdMahasiswa,@TahunAjaran,@Semester), Idmahasiswa, Dbo.F_KETERANGAN_GM(IdMahasiswa,@TahunAjaran,@Semester),Dbo.F_KETERANGAN_APPROVAL(IdMahasiswa,@TahunAjaran,@Semester) From T_MAHASISWA where Idprogdi=@IdProgdi and stat_akd=@statusx and mhs_ank=@Angkatan Order by mhs_nim
End
End

If @Angkatan = ''
Begin
If @StatusX = 6
begin
declare ANANG cursor for Select Mhs_nim, Dbo.F_NAMA_MHS_SKRIPSI (IdMahasiswa,@TahunAjaran,@Semester),mhs_ank, Dbo.F_NAMA_STATUS_AKD(Stat_akd), Dbo.F_TOTAL_SKS_AMBIL_SEMESTER (IdMahasiswa,@TahunAjaran,@Semester,1), Dbo.F_NAMA_BEASISWA (IdMahasiswa,@TahunAjaran,@Semester), Dbo.F_NMPROGDI(idprogdi), Dbo.F_NMFAKULTAS(IdProgdi),Dbo.F_HISTORI_STATUS_KEUANGAN (IdMahasiswa,@TahunAjaran,@Semester),Dbo.F_HISTORI_STATUS_APPROVAL (IdMahasiswa,@TahunAjaran,@Semester), Idmahasiswa, Dbo.F_KETERANGAN_GM(IdMahasiswa,@TahunAjaran,@Semester),Dbo.F_KETERANGAN_APPROVAL(IdMahasiswa,@TahunAjaran,@Semester) From T_MAHASISWA where Idprogdi=@IdProgdi Order by mhs_nim
end
Else
Begin
declare ANANG cursor for Select Mhs_nim, Dbo.F_NAMA_MHS_SKRIPSI (IdMahasiswa,@TahunAjaran,@Semester),mhs_ank, Dbo.F_NAMA_STATUS_AKD(Stat_akd), Dbo.F_TOTAL_SKS_AMBIL_SEMESTER (IdMahasiswa,@TahunAjaran,@Semester,1), Dbo.F_NAMA_BEASISWA (IdMahasiswa,@TahunAjaran,@Semester), Dbo.F_NMPROGDI(idprogdi), Dbo.F_NMFAKULTAS(IdProgdi),Dbo.F_HISTORI_STATUS_KEUANGAN (IdMahasiswa,@TahunAjaran,@Semester),Dbo.F_HISTORI_STATUS_APPROVAL (IdMahasiswa,@TahunAjaran,@Semester), Idmahasiswa, Dbo.F_KETERANGAN_GM(IdMahasiswa,@TahunAjaran,@Semester),Dbo.F_KETERANGAN_APPROVAL(IdMahasiswa,@TahunAjaran,@Semester) From T_MAHASISWA where Idprogdi=@IdProgdi and stat_akd=@statusx Order by mhs_nim
End
End

open ANANG
FETCH NEXT FROM ANANG into @Mhs_nim, @Mhs_nm, @mhs_ank, @Status,@SKS, @Beasiswa, @NamaProgdi, @NamaFakultas, @ujian, @approval, @Idmahasiswa, @KET_GM, @KET_APPRV
WHILE @@FETCH_STATUS = 0
BEGIN

Select @JumlahBiaya = sum(JumlahBayar) from T_KEUANGAN_MAHASISWA where IdMahasiswa=@IDMahasiswa And TahunAJaran=@TahunAjaran and Semester=@Semester
Select @JumlahUang = sum(JumlahUang) from T_KEUANGAN_MAHASISWA where IdMahasiswa=@IDMahasiswa And TahunAJaran=@TahunAjaran and Semester=@Semester
Select @Sisa = @JumlahUang - @JumlahBiaya

if @Sisa = 0 and @JumlahUang <> 0 set @keterangan = 'Lunas'
if @Sisa = 0 and @JumlahUang = 0 set @keterangan = 'Belum Bayar'
if @Sisa > 0 set @keterangan = 'Lebih Bayar'
If @Sisa < 0 set @keterangan = 'Belum Lunas'


insert into #Semu Select
@Mhs_nim,
@Mhs_nm,
@mhs_ank,
@Status,
@SKS,
@JumlahBiaya,
@JumlahUang,
@Sisa,
@Keterangan,
@Beasiswa,
@NamaProgdi, @NamaFakultas, @ujian, @Approval,
@Idmahasiswa, @KET_GM, @KET_APPRV

FETCH NEXT FROM ANANG into @Mhs_nim, @Mhs_nm, @mhs_ank, @Status,@SKS, @Beasiswa, @NamaProgdi, @NamaFakultas, @ujian, @Approval, @Idmahasiswa, @KET_GM, @KET_APPRV
End

close ANANG
deallocate ANANG

If @OP=1
Begin
select * from #Semu
End

If @OP=2
Begin
select * from #Semu where Sisa < 0
End

If @OP=3
Begin
select * from #Semu where Sisa >= 0 and JumlahUang <> 0
End
GO

__________________________________________________________

when i run those store procedure in visual basic 6, i have error message -> "<Invalid object name '#Semu'.>"

can master tell me what's wrong in my store procedure ? and what should i do

i'm sorry if my english so bad

thank's

X002548
Not Just a Number

15586 Posts

Posted - 2009-11-10 : 10:41:46
Break up the sproc and run it in pieces in SQL Server client tool

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -