From: | aditya desai <admad123(at)gmail(dot)com> |
---|---|
To: | Joe Conway <mail(at)joeconway(dot)com> |
Cc: | pgsql-sql <pgsql-sql(at)lists(dot)postgresql(dot)org> |
Subject: | Re: How can i pass variable in dblink_connect_u ? |
Date: | 2022-02-03 11:38:17 |
Message-ID: | CAN0SRDHFGFPZE_QN0pUnLZ53qOgf7R70UrL4XJnjLMAwoDBNxw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Thanks Joe
On Tue, Feb 1, 2022 at 7:11 PM Joe Conway <mail(at)joeconway(dot)com> wrote:
> On 2/1/22 05:42, aditya desai wrote:
> > Hi All,
> > how can I pass variables in dblink_connect_u ?
> >
> > Current code hardcoded DB name:
> > perform * from dblink_connect_u('myconn','dbname=mydb');
> >
> > Expected:
> > databasename=current_database();
> > perform * from dblink_connect_u('myconn','dbname=databasename');
> >
> > databasename is getting considered as text.
>
> Correct, it is a string literal. So just create the string literal using
> string manipulation functionality -- e.g.:
>
> SELECT
> dblink_connect_u('myconn','dbname=' ||
> current_database());
> dblink_connect_u
> ------------------
> OK
> (1 row)
>
> HTH,
>
> Joe
>
> --
> Crunchy Data - http://crunchydata.com
> PostgreSQL Support for Secure Enterprises
> Consulting, Training, & Open Source Development
>
From | Date | Subject | |
---|---|---|---|
Next Message | aditya desai | 2022-02-03 11:40:44 | Increase fetch fize of oracl_fdw(ALTER SERVER) |
Previous Message | David G. Johnston | 2022-02-02 05:47:11 | Re: |