pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedReg:Connection Object
7+ messages / 3 participants
[nested] [flat]
* Reg:Connection Object
@ 2005-09-01 10:42 sandhya <sandhyar@amiindia.co.in>
0 siblings, 1 reply; 7+ messages in thread
From: sandhya @ 2005-09-01 10:42 UTC (permalink / raw)
To: pgsql-admin; +Cc: sandhya <sandhyar@amiindia.co.in>
Hi,
How to pass connection object across the functions.So that there is no need for me to connect to postgres database in each and every function.
For Ex:If i have say 3 functions:
One function i use to connect to the database.
In the other function, if i want to creat a table ...I need this persistant connection object which holds the details of the dbname and user etc.
Pls..help me in solving this.
Thank you very much
Regards,
Sandhya R
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Reg:Connection Object
@ 2005-09-01 13:46 Michael Fuhr <mike@fuhr.org>
parent: sandhya <sandhyar@amiindia.co.in>
0 siblings, 1 reply; 7+ messages in thread
From: Michael Fuhr @ 2005-09-01 13:46 UTC (permalink / raw)
To: sandhya <sandhyar@amiindia.co.in>; +Cc: pgsql-admin
On Thu, Sep 01, 2005 at 04:12:17PM +0530, sandhya wrote:
> How to pass connection object across the functions.So that there
> is no need for me to connect to postgres database in each and every
> function.
What functions? You didn't say what language you're using, nor
whether you're writing client-side code or server-side code.
BTW, this thread seems off-topic for pgsql-admin because it doesn't
concern PostgreSQL administration. You're more likely to get help
in pgsql-interfaces or pgsql-general, or in one of the more specific
lists like pgsql-jdbc or pgsql-php if you're using one of those
interfaces.
--
Michael Fuhr
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Reg:Connection Object
@ 2005-09-02 04:26 sandhya <sandhyar@amiindia.co.in>
parent: Michael Fuhr <mike@fuhr.org>
0 siblings, 1 reply; 7+ messages in thread
From: sandhya @ 2005-09-02 04:26 UTC (permalink / raw)
To: Michael Fuhr <mike@fuhr.org>; Askar Zaidi <askar@mail.nplindia.ernet.in>; +Cc: pgsql-admin
I am using normal C-Functions,In one function i will make connection with
the database.This connection object i need to get in my all other functions
where i will do the other operations like creating a table ,altering a table
in their respective functions.So..There is no need for me to ask the user to
pass the user ,password,database name in all other functions.Pls suggest me
-Sandhya
----- Original Message -----
From: "Michael Fuhr" <mike@fuhr.org>
To: "sandhya" <sandhyar@amiindia.co.in>
Cc: "postgre" <pgsql-admin@postgresql.org>
Sent: Thursday, September 01, 2005 7:16 PM
Subject: Re: [ADMIN] Reg:Connection Object
> On Thu, Sep 01, 2005 at 04:12:17PM +0530, sandhya wrote:
> > How to pass connection object across the functions.So that there
> > is no need for me to connect to postgres database in each and every
> > function.
>
> What functions? You didn't say what language you're using, nor
> whether you're writing client-side code or server-side code.
>
> BTW, this thread seems off-topic for pgsql-admin because it doesn't
> concern PostgreSQL administration. You're more likely to get help
> in pgsql-interfaces or pgsql-general, or in one of the more specific
> lists like pgsql-jdbc or pgsql-php if you're using one of those
> interfaces.
>
> --
> Michael Fuhr
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Reg:Connection Object
@ 2005-09-02 05:16 Michael Fuhr <mike@fuhr.org>
parent: sandhya <sandhyar@amiindia.co.in>
0 siblings, 1 reply; 7+ messages in thread
From: Michael Fuhr @ 2005-09-02 05:16 UTC (permalink / raw)
To: sandhya <sandhyar@amiindia.co.in>; +Cc: Askar Zaidi <askar@mail.nplindia.ernet.in>; pgsql-admin
On Fri, Sep 02, 2005 at 09:56:19AM +0530, sandhya wrote:
> I am using normal C-Functions,In one function i will make connection with
> the database.This connection object i need to get in my all other functions
> where i will do the other operations like creating a table ,altering a table
> in their respective functions.So..There is no need for me to ask the user to
> pass the user ,password,database name in all other functions.Pls suggest me
Do you mean you're writing C code using libpq? If so, why can't
you just pass the PGconn * as another argument to your functions?
Or use a global variable (although some programmers would consider
that bad style)? It's not clear what difficulties you're having.
--
Michael Fuhr
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Reg:Connection Object
@ 2005-09-02 05:49 sandhya <sandhyar@amiindia.co.in>
parent: Michael Fuhr <mike@fuhr.org>
0 siblings, 1 reply; 7+ messages in thread
From: sandhya @ 2005-09-02 05:49 UTC (permalink / raw)
To: Michael Fuhr <mike@fuhr.org>; +Cc: Askar Zaidi <askar@mail.nplindia.ernet.in>; pgsql-admin
In case of multiple users what will happen?
Each must have different connection objects right!
----- Original Message -----
From: "Michael Fuhr" <mike@fuhr.org>
To: "sandhya" <sandhyar@amiindia.co.in>
Cc: "Askar Zaidi" <askar@mail.nplindia.ernet.in>; "postgre"
<pgsql-admin@postgresql.org>
Sent: Friday, September 02, 2005 10:46 AM
Subject: Re: [ADMIN] Reg:Connection Object
> On Fri, Sep 02, 2005 at 09:56:19AM +0530, sandhya wrote:
> > I am using normal C-Functions,In one function i will make connection
with
> > the database.This connection object i need to get in my all other
functions
> > where i will do the other operations like creating a table ,altering a
table
> > in their respective functions.So..There is no need for me to ask the
user to
> > pass the user ,password,database name in all other functions.Pls suggest
me
>
> Do you mean you're writing C code using libpq? If so, why can't
> you just pass the PGconn * as another argument to your functions?
> Or use a global variable (although some programmers would consider
> that bad style)? It's not clear what difficulties you're having.
>
> --
> Michael Fuhr
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Reg:Connection Object
@ 2005-09-02 05:58 Michael Fuhr <mike@fuhr.org>
parent: sandhya <sandhyar@amiindia.co.in>
0 siblings, 0 replies; 7+ messages in thread
From: Michael Fuhr @ 2005-09-02 05:58 UTC (permalink / raw)
To: sandhya <sandhyar@amiindia.co.in>; +Cc: Askar Zaidi <askar@mail.nplindia.ernet.in>; pgsql-admin
On Fri, Sep 02, 2005 at 11:19:53AM +0530, sandhya wrote:
> In case of multiple users what will happen?
> Each must have different connection objects right!
That's why global variables are bad. But what's wrong with passing
a PGconn * to various functions? If that's a problem in your
application then please explain why; it's still not clear what
difficulties you're having. Perhaps it would help if you posted a
simple but complete example program that shows what you're trying
to do.
As I mentioned before, this thread is off-topic for pgsql-admin;
it would be more appropriate in pgsql-interfaces or pgsql-general.
--
Michael Fuhr
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Reg:Connection Object
@ 2005-09-02 07:57 Manikandan C <manikandanc@pervasive-postgres.com>
0 siblings, 0 replies; 7+ messages in thread
From: Manikandan C @ 2005-09-02 07:57 UTC (permalink / raw)
To: sandhya <sandhyar@amiindia.co.in>; +Cc: Askar Zaidi <askar@mail.nplindia.ernet.in>; pgsql-admin
I hope, U can have a structure that have members as the "user name" and the "Connection object". Whenever a new connection is made, U can create instances of this structure. Based on the user name, you can pass the appropriate instance to the function.
Hope this will help you.
Is this what you want?
Regards,
Mani
-----Original Message-----
From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Michael Fuhr
Sent: Friday, September 02, 2005 11:29 AM
To: sandhya
Cc: Askar Zaidi; postgre
Subject: Re: [ADMIN] Reg:Connection Object
On Fri, Sep 02, 2005 at 11:19:53AM +0530, sandhya wrote:
> In case of multiple users what will happen?
> Each must have different connection objects right!
That's why global variables are bad. But what's wrong with passing
a PGconn * to various functions? If that's a problem in your
application then please explain why; it's still not clear what
difficulties you're having. Perhaps it would help if you posted a
simple but complete example program that shows what you're trying
to do.
As I mentioned before, this thread is off-topic for pgsql-admin;
it would be more appropriate in pgsql-interfaces or pgsql-general.
--
Michael Fuhr
---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2005-09-02 07:57 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-09-01 10:42 Reg:Connection Object sandhya <sandhyar@amiindia.co.in>
2005-09-01 13:46 ` Michael Fuhr <mike@fuhr.org>
2005-09-02 04:26 ` sandhya <sandhyar@amiindia.co.in>
2005-09-02 05:16 ` Michael Fuhr <mike@fuhr.org>
2005-09-02 05:49 ` sandhya <sandhyar@amiindia.co.in>
2005-09-02 05:58 ` Michael Fuhr <mike@fuhr.org>
2005-09-02 07:57 Re: Reg:Connection Object Manikandan C <manikandanc@pervasive-postgres.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox