Re: [GENERAL] Plpgsql - Custom fields Postgres 9.5

2016-12-15 Thread Jeff Janes
On Wed, Dec 14, 2016 at 1:17 PM, Patrick B wrote: > > > 2. To call the function, I have to login to postgres and then run: select > logextract(201612015, 201612015); > How can I do it on cron? because the dates will be different every time. > PostgreSQL already knows what date today is. Why doe

Re: [GENERAL] Plpgsql - Custom fields Postgres 9.5

2016-12-14 Thread Adrian Klaver
On 12/14/2016 05:56 PM, Lucas Possamai wrote: ERROR: column "date_start" does not exist Patrick Patrick*** - trying on SQL fiddle i got that error when executing what Adrian suggested. Yeah, it was my turn not to be paying attention. It has been that sort of day and I guess I co

Re: [GENERAL] Plpgsql - Custom fields Postgres 9.5

2016-12-14 Thread Patrick B
2016-12-15 14:54 GMT+13:00 Lucas Possamai : > > > 2016-12-15 14:34 GMT+13:00 Adrian Klaver : > >> On 12/14/2016 05:19 PM, Patrick B wrote: >> >> Reading the suggestions might help:) >> >> Another try: >> >> CREATE or REPLACE FUNCTION l_extract(date_start text, date_end text)) >> >> RETURNS

Re: [GENERAL] Plpgsql - Custom fields Postgres 9.5

2016-12-14 Thread Lucas Possamai
> > ERROR: column "date_start" does not exist > > > Patrick > Patrick*** - trying on SQL fiddle i got that error when executing what Adrian suggested.

Re: [GENERAL] Plpgsql - Custom fields Postgres 9.5

2016-12-14 Thread Lucas Possamai
2016-12-15 14:34 GMT+13:00 Adrian Klaver : > On 12/14/2016 05:19 PM, Patrick B wrote: > > Reading the suggestions might help:) > > Another try: > > CREATE or REPLACE FUNCTION l_extract(date_start text, date_end text)) > > RETURNS void AS $$ > > > begin > > execute ' > >

Re: [GENERAL] Plpgsql - Custom fields Postgres 9.5

2016-12-14 Thread David G. Johnston
On Wednesday, December 14, 2016, Patrick B wrote: > > ' || date_start || ' > > AND > > ' || date_end || ' > > Results in this > BETWEEN > > 2016-12-15 > > AND > > 20160901 > > Compared to this > '2016-12-15' > > AND > >

Re: [GENERAL] Plpgsql - Custom fields Postgres 9.5

2016-12-14 Thread Adrian Klaver
On 12/14/2016 05:19 PM, Patrick B wrote: 2016-12-15 14:00 GMT+13:00 David G. Johnston mailto:david.g.johns...@gmail.com>>: On Wed, Dec 14, 2016 at 5:12 PM, rob stone mailto:floripa...@gmail.com>>wrote: On Wed, 2016-12-14 at 17:00 -0700, David G. Johnston wrote: > On Wed,

Re: [GENERAL] Plpgsql - Custom fields Postgres 9.5

2016-12-14 Thread armand pirvu
I presume you point at me. Keep the record straight. I got mad not for the help but for the high horse attitude. We all have good and bad. No one is perfect and no one deserves this crap Sent from my iPhone > On Dec 14, 2016, at 7:19 PM, Patrick B wrote: > > > > 2016-12-15 14:00 GMT+13:00 D

Re: [GENERAL] Plpgsql - Custom fields Postgres 9.5

2016-12-14 Thread Patrick B
2016-12-15 14:00 GMT+13:00 David G. Johnston : > On Wed, Dec 14, 2016 at 5:12 PM, rob stone wrote: > >> >> On Wed, 2016-12-14 at 17:00 -0700, David G. Johnston wrote: >> > On Wed, Dec 14, 2016 at 4:49 PM, Patrick B >> > wrote: >> > > ERROR: function logextract(integer, integer) does not exist >

Re: [GENERAL] Plpgsql - Custom fields Postgres 9.5

2016-12-14 Thread David G. Johnston
On Wed, Dec 14, 2016 at 5:12 PM, rob stone wrote: > > On Wed, 2016-12-14 at 17:00 -0700, David G. Johnston wrote: > > On Wed, Dec 14, 2016 at 4:49 PM, Patrick B > > wrote: > > > ERROR: function logextract(integer, integer) does not exist > > > LINE 1: select logextract(20160901,20161001); > > >

Re: [GENERAL] Plpgsql - Custom fields Postgres 9.5

2016-12-14 Thread rob stone
On Wed, 2016-12-14 at 17:00 -0700, David G. Johnston wrote: > On Wed, Dec 14, 2016 at 4:49 PM, Patrick B > wrote: > > ERROR:  function logextract(integer, integer) does not exist > > LINE 1: select logextract(20160901,20161001); > > > > So change the constants you are passing into your function

Re: [GENERAL] Plpgsql - Custom fields Postgres 9.5

2016-12-14 Thread David G. Johnston
On Wed, Dec 14, 2016 at 4:49 PM, Patrick B wrote: > ERROR: function logextract(integer, integer) does not exist > > LINE 1: select logextract(20160901,20161001); > So change the constants you are passing into your function to text (i.e., surrounding them with single quotes) so it matches the new

Re: [GENERAL] Plpgsql - Custom fields Postgres 9.5

2016-12-14 Thread Patrick B
2016-12-15 10:40 GMT+13:00 Adrian Klaver : > On 12/14/2016 01:30 PM, Patrick B wrote: > >> 1. Why when I run the function manually I get this error? >> >> select logextract(201612015, 201612015); >> >> ERROR: operator does not exist: timestamp without time

Re: [GENERAL] Plpgsql - Custom fields Postgres 9.5

2016-12-14 Thread Adrian Klaver
On 12/14/2016 01:30 PM, Patrick B wrote: 1. Why when I run the function manually I get this error? select logextract(201612015, 201612015); ERROR: operator does not exist: timestamp without time zone >= integer LI

Re: [GENERAL] Plpgsql - Custom fields Postgres 9.5

2016-12-14 Thread David G. Johnston
On Wed, Dec 14, 2016 at 2:17 PM, Patrick B wrote: > > As you can see, I select a date. So in December, the date will be: *BETWEEN > '201612015' AND '201601015'*, for example. > > ​That is an unusual timestamp value...what's the 5 for?​ (I've figured this out...but its still unusual) > > > 1. Why

Re: [GENERAL] Plpgsql - Custom fields Postgres 9.5

2016-12-14 Thread Patrick B
> > 1. Why when I run the function manually I get this error? >> >> select logextract(201612015, 201612015); >> >> ERROR: operator does not exist: timestamp without time zone >= >> integer >> >> LINE 13: BETWEEN >> > > The answer is above. Look at yo

Re: [GENERAL] Plpgsql - Custom fields Postgres 9.5

2016-12-14 Thread Adrian Klaver
On 12/14/2016 01:17 PM, Patrick B wrote: Hi, I've got this query, that I manually run it once a month: SELECT uuid, clientid), * FROM logging WHERE logtime BETWEEN '201611015' AND '201612015' As you can see, I select

[GENERAL] Plpgsql - Custom fields Postgres 9.5

2016-12-14 Thread Patrick B
Hi, I've got this query, that I manually run it once a month: SELECT uuid, clientid), * FROM logging WHERE logtime BETWEEN '201611015' AND '201612015' As you can see, I select a date. So in December, the date will be: *BETWEEN '201612015' AND '201601015'*, for examp