Re: PSQL = Yes ... JDBC = no ?? - Mailing list pgsql-general

From Peter J. Holzer
Subject Re: PSQL = Yes ... JDBC = no ??
Date
Msg-id 20230904061534.cwdot6mpaqbbdakx@hjp.at
Whole thread Raw
In response to Re: PSQL = Yes ... JDBC = no ??  (Amn Ojee Uw <amnojeeuw@gmail.com>)
List pgsql-general
On 2023-09-03 20:19:44 -0400, Amn Ojee Uw wrote:
> I see now, any suggestions as work around in JDBC?

Implement the functionality in Java.

You could do it directly:

    execute
    SELECT 'CREATE DATABASE jme_test_database' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname =
'jme_test_database')
    read the result
    for each row returned
        execute it as SQL

But that would be silly.

Instead you would do it like this:

    execute
    SELECT datname FROM pg_database WHERE datname = 'jme_test_database'
    read the result
    if the result is empty:
        execute
        CREATE DATABASE jme_test_database'

        hp

--
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachment

pgsql-general by date:

Previous
From: Jethro Elmer Sanidad
Date:
Subject: Re: [EXTERNAL] Oracle FDW version
Next
From: David Rowley
Date:
Subject: Re: Question on Partition key