0
bigintからtextに型を変更すると、PLPGSQL関数が機能しなくなりました。これは私が取得していますエラーです:クエリの構造が関数の結果の型と一致しません
dev=> select * from app.get_companies(4,808739954140037) ;
NOTICE: Data rows were NOT found (structure of query does not match function result type)
company_id_str | company_name
----------------+--------------
(0 rows)
dev=>
そして、これは私の関数である:
CREATE OR REPLACE FUNCTION app.get_companies(ident_id bigint,sess bigint)
RETURNS TABLE(company_id_str text,company_name text) as $$
DECLARE
server_session bigint;
BEGIN
select app.session.session from app.session where app.session.identity_id=ident_id and app.session.session=sess into server_session;
IF FOUND
THEN
BEGIN
RETURN QUERY SELECT quote_ident(app.company.company_id::text)::text as company_id_str,app.company.name as company_name FROM app.company,app.identcomp WHERE app.company.company_id=app.identcomp.company_id and app.identcomp.identity_id=ident_id;
EXCEPTION
WHEN OTHERS THEN
RAISE NOTICE 'Data rows were NOT found (%)',SQLERRM;
RETURN;
END;
ELSE
RAISE NOTICE 'Session row was NOT found';
RETURN;
END IF;
END;
$$ LANGUAGE plpgsql;
私はキャストを適用していると私は表として出力を定義していた場合、なぜこのエラーが起こっているのでしょうか?
app.companyテーブルが次のように定義される。返されるテーブルのcompany_name
がtext
いる間
create table app.company (
company_id bigserial,
date_inserted timestamp,
name varchar(64)
);
を私はvarchar型とテキストが互換性だと思っていました。ありがとう! – Nulik