所以我有以下存储过程来创建一个站点。我希望我的ruby代码返回ourput参数。我需要更改什么才能使其正常工作?
-- FUNCTION: public.createsite(text, boolean, bigint, text, integer, text)
-- DROP FUNCTION public.createsite(text, boolean, bigint, text, integer, text);
CREATE OR REPLACE FUNCTION public.createsite(
sitename text,
activeflag boolean,
createdby bigint,
sitedba text DEFAULT NULL::text,
facilityid integer DEFAULT NULL::integer,
siltelogo text DEFAULT NULL::text,
OUT siteid bigint)
RETURNS bigint
LANGUAGE 'plpgsql'
COST 100.0
VOLATILE
AS $function$
BEGIN
INSERT INTO public.SITES(
SITE_NAME, SITE_DBA, ACTIVE_FLAG, FACILITY_ID,
SITE_LOGO, CREATED_BY, MODIFIED_BY,
created_at, updated_at)
VALUES (SiteName, SiteDBA, ActiveFlag, FacilityID, SilteLogo, CreatedBy, CreatedBy, 'now', 'now')
RETURNING SITE_ID
INTO SiteID;
END;
$function$;
ALTER FUNCTION public.createsite(text, boolean, bigint, text, integer, text)
OWNER TO owner_name;
如何在ruby代码中返回输出参数?
post 'new' do
begin
v1 = "site name"
v2 = "flag"
v3 = "1"
v4 = "dba"
v5 = "1"
v6 = "logo
sp_String = "select createsite('#{v1}', '#{v2}', '#{v3}', '#{v4}', '#{v5}','#{v6}')"
#puts s_pString
results = ActiveRecord::Base.connection.execute(s_pString)
return results
end
end