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 March 29th, 2005, 08:10 AM
voidberg voidberg is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 3 voidberg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 46 sec
Reputation Power: 0
stored procedure help

Hello everyone,
I'm trying to create a row-level stored procedure that takes an integer as an argument and based on that int it returns a certain string.
I want to be able to use something like this:
Code:
select my_proc(field1), field2, field3 from database.

After reading some documentation about the subject I created a procedure that looks like this:
Code:
CREATE PROCEDURE T_IMOBIL (TOF INTEGER)
RETURNS (STR VARCHAR(30))
AS
begin
  /* Procedure Text */
  STR = 'Tip necunoscut';

  if (TOF = 0) then
  begin
    STR = 'Tip 1';
    suspend;
    exit;
  end
  if (TOF = 1) then
  begin
    STR = 'Tip 2';
    suspend;
    exit;
  end
  suspend;
end

Trying to do a select the way I wanted didn't work. Also,
Code:
select "TIMOBIL", "STR" from "OFERTE", T_IMOBIL("TIMOBIL")

doesn't work either because of a cursor problem.
So I'm stuck now.
Any ideas about how I can do this or a link to some tutorial / documentation that explains it would be really helpful.

Reply With Quote
  #2  
Old March 29th, 2005, 09:31 AM
IvanP IvanP is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 12 IvanP User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 7 m 37 sec
Reputation Power: 0
Either use outer join to force evaluation of table before evaluation of stored procedure, i.e.

select "TIMOBIL", "STR" from "OFERTE" LEFT JOIN T_IMOBIL("TIMOBIL") ON 1=1;

or use subselect to convert selecting from stored procedure to single-value expression, i.e.

select "TIMOBIL", "STR", (SELECT X FROM T_IMOBIL("TIMOBIL")) from "OFERTE";

Ivan
http://www.volny.cz/iprenosil/interbase/

Reply With Quote
  #3  
Old March 29th, 2005, 01:40 PM
voidberg voidberg is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 3 voidberg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 46 sec
Reputation Power: 0
Thank you Ivan.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > stored procedure help


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 5 hosted by Hostway
Stay green...Green IT