Unix Technical Forum

Reg:Connection Object

This is a discussion on Reg:Connection Object within the pgsql Admins forums, part of the PostgreSQL category; --> Hi, How to pass connection object across the functions.So that there is no need for me to connect to ...


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

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 06:12 AM
sandhya
 
Posts: n/a
Default Reg:Connection Object

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 06:12 AM
Michael Fuhr
 
Posts: n/a
Default Re: 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

---------------------------(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
  #3 (permalink)  
Old 04-10-2008, 06:12 AM
sandhya
 
Posts: n/a
Default Re: Reg:Connection Object

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



---------------------------(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
  #4 (permalink)  
Old 04-10-2008, 06:12 AM
Michael Fuhr
 
Posts: n/a
Default Re: 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

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-10-2008, 06:12 AM
sandhya
 
Posts: n/a
Default Re: Reg:Connection Object

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



---------------------------(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
  #6 (permalink)  
Old 04-10-2008, 06:12 AM
Michael Fuhr
 
Posts: n/a
Default Re: 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

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 10:54 AM.


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