From: | "lmanorders" <lmanorders(at)gmail(dot)com> |
---|---|
To: | <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: How to determine if a function exists |
Date: | 2012-09-05 22:35:26 |
Message-ID: | 071950FA770E4854B5E609D07EACB389@LynnPC |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
> "lmanorders" <lmanorders(at)gmail(dot)com> writes:
>> I'm attempting to determine if a stored procedure exists. If it doesn't,
>> then I want to create it. I'm developing in C++ using the libpq
>> interface. I found the following suggestion in the docs to determine if a
>> function exists or not. I tried creating what I think is an identical
>> query in pgAdmin and it seems to work ok. Can anyone tell me why the
>> following always returns PGRES_TUPLE_OK, whether the function exists or
>> not?
>
> PGRES_TUPLES_OK means you successfully executed a SELECT (or other
> command capable of returning tuples). It doesn't imply anything about
> how many tuples were returned. In this case, you'd want to check for
> PQntuples() > 0, as well. And perhaps think about what you'd do if
> you got more than one match, which is quite possible in view of function
> overloading, schema search path, etc.
>
> regards, tom lane
>
Thanks. That works great!
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Davis | 2012-09-06 00:48:27 | Re: TimeZone parameter in postgresql.conf |
Previous Message | Tom Lane | 2012-09-05 22:10:49 | Re: How to determine if a function exists |