2010-08-23 37 views
0

在回答上一個問題(request over several schema)之後,我嘗試編寫一個存儲過程來爲多個模式選擇表(每個用戶都有一個模式)。postgresql在多個模式上查詢的存儲過程

create or replace public.select_simulations() returns setof simulation as $$ 
declare 
    users pg_user%ROWTYPE; 
    simu simulation%ROWTYPE; 
begin 
    for users in select usename from pg_user where usename <> 'postgres' loop 
     for simu in select id, name from (users.usename).simulation loop    
      return next simu; 
     end loop; 
    end loop; 
end; 
$$ 

,但不接受(users.usename).simulation,沒有它產生的錯誤括號(好像搜索子領域,而不是一個模式)...

那麼,什麼是正確的語法告訴users.usename是一個模式名稱?

謝謝你的幫助!

+0

我使用PostgreSQL 8.1,也許它事.. – 2010-08-23 10:03:50

+0

版本8.1將在今年停止服務,您最好升級到更新的版本。自2005年11月以來,PostgreSQL也變得更好了,只是時間不足以爲這個陳舊過時的版本做些什麼。 http://wiki.postgresql.org/wiki/PostgreSQL_Release_Support_Policy – 2010-08-23 10:18:25

+0

謝謝你的建議,我升級到8.4。 – 2010-08-23 13:28:05

回答