If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Sybase > Custom functions always return null, please help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-10-10, 05:33
SergeMadi SergeMadi is offline
Registered User
 
Join Date: Feb 2010
Posts: 4
Custom functions always return null, please help

Hi guys,
Sinse yesterday we have a problem with server.
Today we found that all custom functions return 'null'.
Please help....
For example func.sql:
if (select proc_name
from sys.sysprocedure
where lower(proc_name)=lower('ExistProc')) is not NULL then
drop function ExistProc;
end if;

create function ExistProc(ProcName varchar(30)) returns integer
begin
declare pname varchar(30);
set pname=(select proc_name
from sys.sysprocedure
where lower(proc_name)=lower(ProcName));
if pname is null then
return 0
else
return 1;
end if;
end;
////////////////////
So, when we try too use ExistProc, we always get null as the return value.
for example:
if ExistProc(anyFunctionName)=1 then
drop function SimpleReverse;
end if;
or: select ExistProc(anyFunctionName) as res
As I said the problem is sinse yesterday, it had been working.
I think server is "Anywhere 8", i'm not sure.
Reply With Quote
  #2 (permalink)  
Old 02-10-10, 05:55
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
I don't know what the answer is but have you tried running the SQL just to see what comes out ?
Code:
select proc_name
from sys.sysprocedure
where lower(proc_name)=lower("NameOfAProc")
Reply With Quote
  #3 (permalink)  
Old 02-10-10, 06:00
SergeMadi SergeMadi is offline
Registered User
 
Join Date: Feb 2010
Posts: 4
Hi Mike. Yes, the code:
select proc_name from sys.sysprocedure where lower(proc_name)=lower("NameOfAProc")
works.
Reply With Quote
  #4 (permalink)  
Old 02-10-10, 06:16
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Still guessing (I'm not a DBA) : I assume it's not a permissions thing and the user that's calling the function has permission to access these tables as does the user who compiled the functions.
Reply With Quote
  #5 (permalink)  
Old 02-10-10, 06:18
SergeMadi SergeMadi is offline
Registered User
 
Join Date: Feb 2010
Posts: 4
it's always the same user.
Reply With Quote
  #6 (permalink)  
Old 02-10-10, 07:41
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Still guessing I'm afraid but at least it shows someone cares
  • Has the database been restored recently?
  • Have you tried just recompiling the function?
  • Could there be two procs in the database with slightly different names ie MyProc and myproc - then your function will try and assign two values to a variable and go wrong?
Reply With Quote
  #7 (permalink)  
Old 02-10-10, 07:47
SergeMadi SergeMadi is offline
Registered User
 
Join Date: Feb 2010
Posts: 4
Thanks Mike.
Answers are no,no and no... There are no changes we made. It have worked for years.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On