Subject insert into .. select from table, procedure
Author Robert Zimmermann
Hey mates,

I'm calculating some statistics stuff using a procedure. That procedure ("gen_stats") is being called by passing the record ID in my "raw data" table. It then returns a single record containing the magic top secret statistic data, calculated from the rawdata ^^ My goal was to transfer all the generated stats data to another table using the following insert statement:

insert into results (id, statsvalue1, statsvalue2, statsvalue3)
select s.id, s.statsvalue1, s.statsvalue2, s.statsvalue3 from sourcetable t, gen_stats(t.id) s

Although, gen_stats alway returns a single record (even if theres no stats data, it returns the passed id) the statement returns nothing. I played a bit around and got it running by using a view instead of the sourcedata table (simply: create view v_sourcetable as select * from sourcetable)
Whats the reason I can link my proc using a view while selecting a table returns nothing?

Greetingz,

Robert
--
Psssst! Schon das coole Video vom GMX MultiMessenger gesehen?
Der Eine für Alle: http://www.gmx.net/de/go/messenger03