Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 31st, 2006, 08:17 AM
shennig shennig is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 18 shennig User rank is Lance Corporal (50 - 100 Reputation Level)shennig User rank is Lance Corporal (50 - 100 Reputation Level)shennig User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 7 h 33 m 54 sec
Reputation Power: 0
Function unknown.SQL error code = -804.

Hi,

i've created a procedure that should give me the position of a substring in a string:

--------------------------------------------------------
CREATE PROCEDURE Pos (SubStr VARCHAR(100), Str VARCHAR(100))
RETURNS (Pos INTEGER) AS
DECLARE VARIABLE SubStr2 VARCHAR(201); /* 1 + SubStr-lenght + Str-length */
DECLARE VARIABLE Tmp VARCHAR(100);
BEGIN
IF (SubStr IS NULL OR Str IS NULL)
THEN BEGIN Pos = NULL; EXIT; END

SubStr2 = SubStr || '%';
Tmp = '';
Pos = 1;
WHILE (Str NOT LIKE SubStr2 AND Str NOT LIKE Tmp) DO BEGIN
SubStr2 = '_' || SubStr2;
Tmp = Tmp || '_';
Pos = Pos + 1;
END

IF (Str LIKE Tmp) THEN Pos = 0;
END
-------------------------------------------------------

There are no compilation errors. but when i try to use this procedure in another procedure or in a select statement, it occurs:
Function unknown.SQL error code = -804.

i've given grants and it seems, that the procedure is visible. In IBExpert it auto-identifies the procedure Pos, also shows it in the explorer and when i'm debuging the Pos it works right.

i've tried to declare the function. executing this sql

Code (found in this forum):

DECLARE EXTERNAL FUNCTION Pos
varchar(100),varchar(100)
RETURNS integer FREE_IT
ENTRY_POINT 'IB_UDF_pos' MODULE_NAME 'ib_udf';

after this, i can use the procedure, but the results are totally wrong! values over 39.000 an such things.

does anyone knows a solution?

i'm using firebird 1.5.3 and IBExpert 2006.08.16

thanks a lot!

Reply With Quote
  #2  
Old October 31st, 2006, 09:10 AM
shennig shennig is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 18 shennig User rank is Lance Corporal (50 - 100 Reputation Level)shennig User rank is Lance Corporal (50 - 100 Reputation Level)shennig User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 7 h 33 m 54 sec
Reputation Power: 0
Ok, i've found that i have to use the procedure like a table with the select statement.

select pos from pos('e','rrerr');

but in the select statement the result must be 3, but it is null!!!!

why?!? when i create a simple procedure with one fix outup parameter it is also null.

Solutions?????

Reply With Quote
  #3  
Old October 31st, 2006, 12:05 PM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,905 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 4 h 58 m 14 sec
Reputation Power: 279
I'd rather declare it as per Ivan Prenosil's site

Reply With Quote
  #4  
Old November 1st, 2006, 08:23 AM
shennig shennig is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 18 shennig User rank is Lance Corporal (50 - 100 Reputation Level)shennig User rank is Lance Corporal (50 - 100 Reputation Level)shennig User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 7 h 33 m 54 sec
Reputation Power: 0
Quote:
Originally Posted by pabloj
I'd rather declare it as per Ivan Prenosil's site


Sorry,i don't want to say that i,ve created the procedure shown above in the sense of making it new. but its the first procedure that i've put in the firebird database. but the results i get, are all wrong and i don't know why and the documentation is poor.

do know anybody a possible solution?

Reply With Quote
  #5  
Old November 1st, 2006, 11:42 AM
clivew clivew is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2006
Location: Carlsbad, CA
Posts: 807 clivew User rank is Sergeant (500 - 2000 Reputation Level)clivew User rank is Sergeant (500 - 2000 Reputation Level)clivew User rank is Sergeant (500 - 2000 Reputation Level)clivew User rank is Sergeant (500 - 2000 Reputation Level)clivew User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 5 h 10 m
Reputation Power: 19
Quote:
Originally Posted by shennig
Sorry,i don't want to say that i,ve created the procedure shown above in the sense of making it new. but its the first procedure that i've put in the firebird database. but the results i get, are all wrong and i don't know why and the documentation is poor.

do know anybody a possible solution?


Well, I have not analyzed your procedure itself; BUT as it is written in Firebird it does not/ should not be declared EXTERNAL.

EXTERNAL is for importing routines created in another language and compiled to a DLL (in Windows).

Reply With Quote
  #6  
Old November 7th, 2006, 01:05 AM
shennig shennig is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 18 shennig User rank is Lance Corporal (50 - 100 Reputation Level)shennig User rank is Lance Corporal (50 - 100 Reputation Level)shennig User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 7 h 33 m 54 sec
Reputation Power: 0
The Problem is still there!

I've tried an easier procedure:
-----------------------------------------------
CREATE PROCEDURE TEST
returns
(
result integer
)
as
BEGIN
Result = 1;
END;
-----------------------------------------------

When i use a select like this

select * from TEST;

the result is null!!!


What is going wrong?Do i forget something?

Reply With Quote
  #7  
Old November 7th, 2006, 10:34 AM
clivew clivew is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2006
Location: Carlsbad, CA
Posts: 807 clivew User rank is Sergeant (500 - 2000 Reputation Level)clivew User rank is Sergeant (500 - 2000 Reputation Level)clivew User rank is Sergeant (500 - 2000 Reputation Level)clivew User rank is Sergeant (500 - 2000 Reputation Level)clivew User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 5 h 10 m
Reputation Power: 19
Quote:
Originally Posted by shennig
The Problem is still there!

I've tried an easier procedure:
-----------------------------------------------
CREATE PROCEDURE TEST
returns
(
result integer
)
as
BEGIN
Result = 1;
END;
-----------------------------------------------

When i use a select like this

select * from TEST;

the result is null!!!


What is going wrong?Do i forget something?


Try

select Result from TEST;

ALSO.

I just noticed that the name of your function and the name of your return parameter are the same. A prime candidate for confusion. Change one or the other.

Clive.

Last edited by clivew : November 7th, 2006 at 10:36 AM.

Reply With Quote
  #8  
Old November 8th, 2006, 01:35 AM
shennig shennig is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 18 shennig User rank is Lance Corporal (50 - 100 Reputation Level)shennig User rank is Lance Corporal (50 - 100 Reputation Level)shennig User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 7 h 33 m 54 sec
Reputation Power: 0
Quote:
Originally Posted by clivew
Try

select Result from TEST;

ALSO.

I just noticed that the name of your function and the name of your return parameter are the same. A prime candidate for confusion. Change one or the other.

Clive.


Thank you for reply. I've found my mistake. I've forgotten the suspend!

-----------------------------------------------
CREATE PROCEDURE TEST
returns
(
result integer
)
as
BEGIN
Result = 1;
suspend;
END;
-----------------------------------------------

After this the result is given back and it can be selected.

I think i have to learn a lot for firebird

Reply With Quote
  #9  
Old November 8th, 2006, 03:53 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,905 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 4 h 58 m 14 sec
Reputation Power: 279
Anyway I'd not mix case.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > Function unknown.SQL error code = -804.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway