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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| |||
| 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 |
| |||
| 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 |
| |||
| 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 |
| |||
| 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 |
| ||||
| 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 |