|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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/ |
|
#3
|
|||
|
|||
|
Thank you Ivan.
|
![]() |
| Viewing: Dev Shed Forums > Databases > Firebird SQL Development > stored procedure help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|