Re: Plpgsql - Custom fields Postgres 9.5

From: Patrick B <patrickbakerbr(at)gmail(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Plpgsql - Custom fields Postgres 9.5
Date: 2016-12-14 23:49:52
Message-ID: CAJNY3itduFt2qt2AGmpSoGjxwLR8u9-aPaffG5r2_H+v3KuZ=Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2016-12-15 10:40 GMT+13:00 Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>:

> 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
>>
>> LINE 13: BETWEEN
>>
>>
>> The answer is above. Look at your original query at the top of the
>> post.
>>
>>
>>
>> I presume this is wrong: _CREATE or REPLACE FUNCTION
>> logextract(date_start integer, date_end integer) _- But what
>> should I
>> use instead?
>>
>>
>> <mailto:adrian(dot)klaver(at)aklaver(dot)com>
>>
>>
>> You mean the error would be:
>> select logextract(201612015, 201612015);
>>
>> When it was supposed to be: select logextract(201611015, 201612015);???
>>
>> This is not the cause, because it was a mistake when I typed the email.
>> Even doing:
>>
>> select logextract(20161115,20161215);
>>
>>
>> I get same error.
>>
>
> You would. The error is:
>
> ERROR: operator does not exist: timestamp without time zone >= integer
>
> Change this:
>
>
> BETWEEN
>
> ' || date_start || '
>
> AND
>
> ' || date_end || '
>
> to
>
> BETWEEN
>
> date_start::text
>
> AND
>
> date_end::text
>
> Or change the argument types to text and then:
>
> BETWEEN
>
> date_start
>
> AND
>
> date_end
>
> In either case you will have your original query.
>
> --
> Adrian Klaver
> adrian(dot)klaver(at)aklaver(dot)com

I tried either changing the argument types:

logextract(date_start text, date_end text)

and also the Between:

BETWEEN

date_start::text

AND

date_end::text

None of those worked:

ERROR: function logextract(integer, integer) does not exist

LINE 1: select logextract(20160901,20161001);

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2016-12-15 00:00:23 Re: Plpgsql - Custom fields Postgres 9.5
Previous Message Adrian Klaver 2016-12-14 21:40:10 Re: Plpgsql - Custom fields Postgres 9.5