create function
"DBO".sf_GetStateID( @.Abbr char(2))
returns integer
begin
declare @.StateID integer;
set @.Abbr=UPPER(@.Abbr);
if @.Abbr is null
set @.Abbr=''
set @.StateID=53;
select MIN(lngStateID) into StateID from "DBA".States where strAbbr=@.Abbr;
if @.StateID is null
insert into States(strAbbr,strName) values(@.Abbr,@.Abbr)
if SQLSTATE = '00000'
set @.StateID=@.@.IDENTITY
return(@.StateID)
end
In this function, I am getting error at SQLSTATE = '00000'. I saw in books online and it says that SQLSTATE is a keyword. It is not recognizing SQLSTATE as a keyword in the function.
Can you help in that?
2nd Error: It is not accepting the statement
select MIN(lngStateID) into StateID from "DBO".States where strAbbr=@.Abbr;
I don't see any problem in the above statement. Do help in solving these two problems.
Tks
K.The 2 problems is that sqlstate is used for odbc/embedded sql - not for udfs. Also, you are returning a scalar in the udf and not a table (for the 2nd error).sql
Showing posts with label sqlstate. Show all posts
Showing posts with label sqlstate. Show all posts
Friday, March 30, 2012
problem with SQLSTATE
Monday, March 12, 2012
Problem with resto odbc sqlstate: 42000
I got this error when I do a manual restore:
"odbc sqlstate: 42000"
Please help,
CulamYour database is running a shadow copy.
Delete the database, and the real copy will then show back up in the list.
"culam" <culam@.discussions.microsoft.com> wrote in message
news:442BB61D-C504-4FA2-B097-1AF2A34403B4@.microsoft.com...
> I got this error when I do a manual restore:
> "odbc sqlstate: 42000"
> Please help,
> Culam
"odbc sqlstate: 42000"
Please help,
CulamYour database is running a shadow copy.
Delete the database, and the real copy will then show back up in the list.
"culam" <culam@.discussions.microsoft.com> wrote in message
news:442BB61D-C504-4FA2-B097-1AF2A34403B4@.microsoft.com...
> I got this error when I do a manual restore:
> "odbc sqlstate: 42000"
> Please help,
> Culam
Subscribe to:
Posts (Atom)