all groups > sql server programming > february 2005 >
You're in the

sql server programming

group:

Problems with Stored procedures


Problems with Stored procedures tshad
2/24/2005 8:07:29 PM
sql server programming:
I am trying to recreate my database from work to my home machines. But use
Sql 2000.

One error I get is that bigint is invalid type - but my tables have bigints
in then

Another is that Scope_Identity is not valid - but it works fine at work.

Here is one Stored procedure (with errors at end).
******************************************************
CREATE PROCEDURE AddNewApplicantScreen
(
@ClientID varChar(20),@JobID bigInt,@ApplicantID bigInt,@PositionID
Int,@Version Int, @QuestionUnique Int, @Answer Int,@AnswerTime Int
)
AS

if not exists (Select ApplicantID from ftsolutions.dbo.ApplicantScreen
where ClientID = @ClientID and JobID = @JobID and ApplicantID =
@ApplicantID and PositionID = @PositionID and Version = @Version
and QuestionUnique = @QuestionUnique)
insert into
ApplicantScreen(ClientID,JobID,ApplicantID,PositionID,Version,QuestionUnique
,Answer,AnswerTime)

values(@ClientID,@JobID,@ApplicantID,@PositionID,@Version,@QuestionUnique,@A
nswer,@AnswerTime)
else
Update ftsolutions.dbo.ApplicantScreen set Answer=@Answer,
AnswerTime=@AnswerTime
where ClientID = @ClientID and JobID = @JobID and ApplicantID =
@ApplicantID and PositionID = @PositionID and Version = @Version
and QuestionUnique = @QuestionUnique
GO


Server: Msg 2715, Level 16, State 3, Procedure AddNewApplicantScreen, Line 0
Column or parameter #2: Cannot find data type bigint.
Server: Msg 2715, Level 16, State 1, Procedure AddNewApplicantScreen, Line 0
Column or parameter #3: Cannot find data type bigint.
Parameter '@JobID' has an invalid data type.
Parameter '@ApplicantID' has an invalid data type.
****************************************************************************
***

Here is another:
****************************************************************************
***
CREATE PROCEDURE spAddNewResume
(
@ClientID varChar(20),@PositionID Int,@FirstName varChar(30),@LastName
varChar(30),@Email varChar(45),@TicklerPhrase varChar(45),@ResumeText
text,@CoverSheet text
)
AS
declare @ApplicantID int, @JobID bigInt

if not exists (Select ApplicantID from ftsolutions.dbo.Applicant where
ClientID = @ClientID and
LastName = @LastName and FirstName = @FirstName and Email = @Email)
begin
begin tran
INSERT INTO Applicant
(ClientID,ApplicantID,PositionID,FirstName,LastName,Email,DatePosted)
Select @ClientID,COALESCE(max(ApplicantID),1000)+1,@PositionID,@FirstName,
@LastName,@Email,getdate()
from ftsolutions.dbo.Applicant
where ClientID = @ClientID

Select @JobID = Scope_Identity()
Select @ApplicantID=ApplicantID from ftsolutions.dbo.Applicant where JobID
= @JobID
commit tran
end
else
begin
Select @ApplicantID = ApplicantID from Applicant where ClientID = @ClientID
and
LastName = @LastName and FirstName = @FirstName and Email = @Email

INSERT INTO Applicant
(ClientID,ApplicantID,PositionID,FirstName,LastName,Email,DatePosted) values
(@ClientID,@ApplicantID,@PositionID,@FirstName,
@LastName,@Email,getdate() )

Select @JobID = Scope_Identity()
end

INSERT INTO ApplicantResume
(ClientID,ApplicantID,PositionID,FirstName,LastName,Email,TicklerPhrase,Resu
meText,CoverSheet,JobID) values
(
@ClientID,@ApplicantID,@PositionID,@FirstName,@LastName,@Email,@TicklerPhras
e,@ResumeText,@CoverSheet,@JobID)

INSERT INTO JobApplicant (ClientID,ApplicantID,PositionID,JobID,Resume)
Values(@ClientID,@ApplicantID,@PositionID,@JobID,getdate() )

select @ApplicantID as ApplicantID,@JobID as JobID
GO


Server: Msg 195, Level 15, State 10, Procedure spAddNewResume, Line 17
'Scope_Identity' is not a recognized function name.
Server: Msg 195, Level 15, State 1, Procedure spAddNewResume, Line 29
'Scope_Identity' is not a recognized function name.
****************************************************************************
**

Why would that happen?

Thanks,

Tom

Re: Problems with Stored procedures Dan Guzman
2/24/2005 10:11:15 PM
What does the following return on your home machine?

SELECT @@VERSION

--
Hope this helps.

Dan Guzman
SQL Server MVP

[quoted text, click to view]

Re: Problems with Stored procedures tshad
2/24/2005 10:20:26 PM
[quoted text, click to view]

I couldn't remember how to get the version.

I did have both Sql Server 7 and 2k on my machine, but I now remember I took
the 2k off when testing the trial version and converting to the real version
before I did it at work.

I just reinstalled 2k and it works fine now.

How stupid.

Thanks,

Tom
[quoted text, click to view]

AddThis Social Bookmark Button