Re: plpgsql, dynamic variable lengths..

From: Wells Oliver <wells(dot)oliver(at)gmail(dot)com>
To: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: plpgsql, dynamic variable lengths..
Date: 2020-02-08 20:41:13
Message-ID: CAOC+FBVHAN-7YiowdvD5JkOtDv2y10XnT0jnFC++MDQAhGBSdQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Beaut, that's it.

I still can't tell if this is too hacky to bear, but it works. Trying to
essentially use a python-style kwargs declaration, but with a jsonb object.
We'll see.

Thanks!

On Sat, Feb 8, 2020 at 12:54 AM Guillaume Lelarge <guillaume(at)lelarge(dot)info>
wrote:

> Le sam. 8 févr. 2020 à 03:36, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> a écrit :
>
>> Wells Oliver <wells(dot)oliver(at)gmail(dot)com> writes:
>> > Yes, but the issue is it won't always be three params, and not always
>> the
>> > same variable in $1, $2, etc. It depends on which keys are present in
>> the
>> > passed JSON object. Which I why I think I need to do something else like
>> > create a recordset and pass that in USING, or something. Just can't
>> quite
>> > figure it out...
>>
>> Maybe just pass the JSON object as the only USING param, and do the
>> field selections in the SQL fragments?
>>
>>
> And why don't you do this instead?
>
> SQLSTRING := SQLSTRING || ' AND col1 = ' || quote_literal(args->>'col1');
>
>
> --
> Guillaume.
>

--
Wells Oliver
wells(dot)oliver(at)gmail(dot)com <wellsoliver(at)gmail(dot)com>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Sanjib Mohanty 2020-02-09 07:15:30 Re: pg_basebackup fails to connect from slave server
Previous Message Guillaume Lelarge 2020-02-08 08:54:45 Re: plpgsql, dynamic variable lengths..