I have three simple stored procedures 

create or alter procedure p_one (IDparent integer)
returns (RESULT numeric(15,2))
as
begin
  select coalesce(sum(baseOne),0)
  from detail
  where parent = :IDparent
  into result;
  suspend;
end

create or alter procedure p_two (IDparent integer)
returns (RESULT numeric(15,2))
as
begin
  select coalesce(sum(baseTwo),0)
  from detail
  where parent = :IDparent
  into result;
  suspend;
end

create or alter procedure p_calc (ID integer)
returns (RESULT numeric(15,2))
as
begin
  select coalesce((c_One - c_Two),0)
  from master
  where id = :ID
  into result;
  suspend;
end


                     I have the next tables


Table: master
Columns: 
  Id (integer)
  c_One (computed by ((select result from p_one (Id) ))  )
  c_Two (computed by ((select result from p_two (Id) ))  )
  c_Calc (computed by ((select result from p_calc (Id) ))  )

Table: detail
Columns: 
  Id (integer)
  Parent (integer)
  baseOne (numeric)
  baseTwo (numeric)



When I do a query of the third field, the first time it returns me null. 
After recompile (IBExpert) the stored procedure, and consult again the third
field and then I return the correct value.


select c_Calc from DataTable where....;
returned value : NULL

recompile p_calc

select c_Calc from DataTable where....;
returned value : $435

Thanks in advance.





--
View this message in context: 
http://firebird.1100200.n4.nabble.com/Computed-fields-and-Stored-procedures-tp4637805.html
Sent from the firebird-devel mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to