Re: [SQL] Using Array in Function - Mailing list pgsql-sql

From David G. Johnston
Subject Re: [SQL] Using Array in Function
Date
Msg-id CAKFQuwb8dX8LhzsaTQL0OmYtm+oEz1hBN9QhE4STsHHSKSMT9g@mail.gmail.com
Whole thread Raw
In response to [SQL] Using Array in Function  (Günce Kaya <guncekaya14@gmail.com>)
Responses Re: [SQL] Using Array in Function  (Günce Kaya <guncekaya14@gmail.com>)
List pgsql-sql
On Mon, Oct 9, 2017 at 12:40 PM, Günce Kaya <guncekaya14@gmail.com> wrote:
I came across something strange about function. I have a function that has an input parameter is an array like integer[] and return json value. This input parameter is used in where clause. 

When I call function I'm using input parameter like '{int1,int2,int3}' then return only result for first one int1. If I only execute sql script that is in function with same parameter in where clause, sql script return 3 rows that we need. 

It seems so weird. Both of results should be same for function and sql script of function. 


​A function will only return more than one row if it is defined as either:

RETURNS TABLE
or
RETURNS SETOF <type>

A script will always return all available rows.

David J.

pgsql-sql by date:

Previous
From: Günce Kaya
Date:
Subject: [SQL] Using Array in Function
Next
From: Günce Kaya
Date:
Subject: Re: [SQL] Using Array in Function