Re: libpq confusion

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Igor Korot <ikorot01(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: libpq confusion
Date: 2017-09-20 04:14:10
Message-ID: CAFj8pRCco=y_AMz5Pe4+tKic1aCWr=g9oMMC4Va8ZSBmRHOdww@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2017-09-20 5:36 GMT+02:00 Igor Korot <ikorot01(at)gmail(dot)com>:

> Hi, ALL,
>
> draft=# SELECT 1 FROM abcattbl WHERE abt_tnam = 'leagues';
> ?column?
> ----------
> (0 rows)
>
>
> However running it thru the PQexecParam() I am getting "PGRES_TUPLES_OK"
> which means that the such record exist.
>

That means so this command doesn't fail - not so there are some record.

you can use different query, that returns true, false

SELECT EXISTS(SELECT * FROM abcattbl WHERE abt_tnam = 'leagues');

Regards

Pavel

> How do I properly check if the record exists from libpq?
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Allan Harvey 2017-09-20 04:20:28 Re: libpq confusion
Previous Message Igor Korot 2017-09-20 03:36:53 libpq confusion