Postgresql9.2 と SQLAlchemy0.8 を使用しています。多くの out パラメータを持つストアド プロシージャがデータベースにあり、それらをドット表記で使用したいと考えています。しかし、これまで私は惨めに失敗してきました。以下は私のコードがどのように見えるかです。
私がやっていることを示す例は次のとおりです。
CREATE OR REPLACE FUNCTION stored_proc_name(IN in_user_id bigint, IN in_amount bigint,
OUT pout_one bigint, OUT pout_two bigint )
RETURNS record AS
$BODY$
begin
select count(*) as AliasOne into pout_one from tabe_names where conditions;
select user_name as AliasTwo into pout_two from table_name where condition;
end;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION stored_proc_name(bigint, bigint)
OWNER TO postgres;
私のコードスニペットは次のとおりです。
#session object from sessionmaker
result_obj = session.execute(func.stored_proc_name(user_id, amount))
print result_obj.fetechall()
#The above print statement prints following on the console.
>> [('(1,100)',)]
明らかに、上記の結果は文字列をフェッチします。私が欲しいのはresult_obj.pout_one
、私のコードでそれを使用するようなものです。
それを達成する方法はありますか?動作するコード スニペットは高く評価されます。
どうもありがとう!