Fix the no multi_row, no multi_field case #314

Fix for the `ERROR:  control reached end of function without RETURN` but
now need to implement for the two other cases.
This commit is contained in:
Rafa de la Torre 2016-12-13 16:38:30 +01:00
parent fae7889fe3
commit 4cd72616ca

View File

@ -17,7 +17,7 @@ BEGIN
IF username IS NULL OR username = '' OR username = '""' THEN
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
END IF;
BEGIN
<% if multi_row %>
RETURN QUERY
SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(<%= ['username', 'orgname'].concat(params).join(', ') %>);
@ -25,12 +25,14 @@ BEGIN
SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(<%= ['username', 'orgname'].concat(params).join(', ') %>) INTO ret;
RETURN ret;
<% else %>
BEGIN
SELECT <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(<%= ['username', 'orgname'].concat(params).join(', ') %>) INTO ret;
RETURN ret;
<% end %>
EXCEPTION
WHEN OTHERS THEN
RAISE WARNING 'whatever';
RETURN ret;
END;
<% end %>
END;
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;