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

From Günce Kaya
Subject Re: [SQL] Using Array in Function
Date
Msg-id CAAV2-mVywoogJLb9yzZzedL0LFv1Wp7d-gq18me0TnJcvBJktw@mail.gmail.com
Whole thread Raw
In response to Re: [SQL] Using Array in Function  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-sql
Hi David,

Thank you for quick response. Your advice solved my problem :)

Regards,
Gunce

On Mon, Oct 9, 2017 at 11:12 PM, David G. Johnston <david.g.johnston@gmail.com> wrote:
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.




--
Gunce Kaya

pgsql-sql by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: [SQL] Using Array in Function
Next
From: ROS Didier
Date:
Subject: [SQL] Need Help on SQL Query