Unix Technical Forum

Regarding PL/SQL with C

This is a discussion on Regarding PL/SQL with C within the pgsql Novice forums, part of the PostgreSQL category; --> Dear All, Iam a newbiw to PL/SQL. So iam having a query regarding accessing PL/SQL through C program. I ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Novice

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 10:37 PM
Krishnaprasad
 
Posts: n/a
Default Regarding PL/SQL with C

Dear All,

Iam a newbiw to PL/SQL. So iam having a query regarding
accessing PL/SQL through C program.

I have written code for connecting to a database and select one row and
just print it out.. Iam able to make a connection with the databse. But
after connection it is showing that select query failed.... but if iam
directly selecting through PL/SQL prompt iam able to do the same.......

I have attached the source file also.........

thanks & regards
krishnaprasd

-



---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 10:37 PM
Michael Fuhr
 
Posts: n/a
Default Re: Regarding PL/SQL with C

On Sat, Feb 25, 2006 at 02:03:51PM +0530, Krishnaprasad wrote:
> I have written code for connecting to a database and select one row and
> just print it out.. Iam able to make a connection with the databse. But
> after connection it is showing that select query failed.... but if iam
> directly selecting through PL/SQL prompt iam able to do the same.......


You're connecting to the database thusly:

> conn = PQconnectStart("user=postgres,dbname=krishna");


Parameters in the connect string should be space-separated, not
comma-separated. The select is probably failing because the connect
failed; you're not seeing the connection failure because you're
calling PQconnectStart to make a nonblocking connection and you're
not waiting for the connection to complete before making the query.
Unless you need a nonblocking connection use PQconnectdb instead:

conn = PQconnectdb("user=postgres dbname=krishna");

Then check for CONNECTION_OK, not CONNECTION_MADE.

When an operation has failed, you can use PQerrorMessage or
PQresultErrorMessage to display the reason.

--
Michael Fuhr

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-17-2008, 10:38 PM
Krishnaprasad
 
Posts: n/a
Default Re: Regarding PL/SQL with C


hi michael

thanks for ur input... I tried with *PQconnectdb* also. But
still it is showing connection error
when I tried with PQErrorMessage it is coming as below.

*FATAL: IDENT authentication failed for user "postgres" ...

pls help..

thanks
krishna
*
Michael Fuhr wrote:

>On Sat, Feb 25, 2006 at 02:03:51PM +0530, Krishnaprasad wrote:
>
>
>>I have written code for connecting to a database and select one row and
>>just print it out.. Iam able to make a connection with the databse. But
>>after connection it is showing that select query failed.... but if iam
>>directly selecting through PL/SQL prompt iam able to do the same.......
>>
>>

>
>You're connecting to the database thusly:
>
>
>
>> conn = PQconnectStart("user=postgres,dbname=krishna");
>>
>>

>
>Parameters in the connect string should be space-separated, not
>comma-separated. The select is probably failing because the connect
>failed; you're not seeing the connection failure because you're
>calling PQconnectStart to make a nonblocking connection and you're
>not waiting for the connection to complete before making the query.
>Unless you need a nonblocking connection use PQconnectdb instead:
>
> conn = PQconnectdb("user=postgres dbname=krishna");
>
>Then check for CONNECTION_OK, not CONNECTION_MADE.
>
>When an operation has failed, you can use PQerrorMessage or
>PQresultErrorMessage to display the reason.
>
>
>



--
Rgds

KRISHNAPRASAD.K
R&D Engineer
HCL INFOSYSTEMS LTD
PONDICHERRY
Mob:09894530948


---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-17-2008, 10:38 PM
Michael Fuhr
 
Posts: n/a
Default Re: Regarding PL/SQL with C

On Mon, Feb 27, 2006 at 09:24:33AM +0530, Krishnaprasad wrote:
> thanks for ur input... I tried with *PQconnectdb* also. But
> still it is showing connection error
> when I tried with PQErrorMessage it is coming as below.
>
> *FATAL: IDENT authentication failed for user "postgres" ...


What operating system user is the program running as? What connect
string are you using now (the previous one was erroneous)? Does
pg_hba.conf have an ident map that would allow the operating system
user to connect to the specified database as the specified database
user?

If you're not sure how to check pg_hba.conf then see the "Client
Authentication" chapter in the documentation, in particular the
"Ident-based authentication" section:

http://www.postgresql.org/docs/8.1/i...ntication.html
http://www.postgresql.org/docs/8.1/i...tml#AUTH-IDENT

--
Michael Fuhr

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:12 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com