Re: YNT: Re: Using bind variable within BEGIN END

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: gulsumramazanoglu <gulsumramazanoglu(at)gmail(dot)com>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, anand086 <anand086(at)gmail(dot)com>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: YNT: Re: Using bind variable within BEGIN END
Date: 2017-06-02 20:00:24
Message-ID: c5ee822d-d3f1-0960-5392-80b00ff77a5b@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 06/02/2017 11:38 AM, gulsumramazanoglu wrote:
> ... which will pass arguments and get back a result set, i mean..

Using Python and psycopg2:

\df billing_days
List of functions
Schema | Name | Result data type | Argument data
types | Type
--------+--------------+--------------------------+--------------------------------+--------
public | billing_days | TABLE(billing_date date) | start_date date,
end_date date | normal

select * from billing_days('05/01/2017', '05/30/2017');
billing_date
--------------
2017-05-01
2017-05-02
2017-05-03
2017-05-04
2017-05-05
2017-05-08
2017-05-09
2017-05-10
2017-05-11
2017-05-12
2017-05-15
2017-05-16
2017-05-17
2017-05-18
2017-05-19
2017-05-22
2017-05-23
2017-05-24
2017-05-25
2017-05-26
2017-05-29
2017-05-30

import psycopg2
con = psycopg2.connect('dbname=**** user=***_admin host=localhost')
bill_cur = con.cursor()
bill_cur.execute("SELECT * FROM billing_days(%s, %s)" , ('05/01/2017',
'05/31/2017'))
bill_rs = bill_cur.fetchall()
for row in bill_rs:
print(row[0])

2017-05-01
2017-05-02
2017-05-03
2017-05-04
2017-05-05
2017-05-08
2017-05-09
2017-05-10
2017-05-11
2017-05-12
2017-05-15
2017-05-16
2017-05-17
2017-05-18
2017-05-19
2017-05-22
2017-05-23
2017-05-24
2017-05-25
2017-05-26
2017-05-29
2017-05-30
2017-05-31

>
>
>
> Samsung cihazımdan gönderildi

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message gulsumramazanoglu 2017-06-02 20:19:17 YNT: Re: YNT: Re: Using bind variable within BEGIN END
Previous Message basuraspam - 2017-06-02 19:30:34 Re: Database views metadata always nullable columns