Re: [Orclib-users] How to pass OCILIB connection to a function in C
Open source C and C++ library for accessing Oracle Databases
Brought to you by:
vince_del_paris
|
From: Michael F. <mic...@un...> - 2012-04-10 16:25:44
|
On 2012-04-10 18:16, mod...@co... wrote:
> Nevermind... I got it working by declaring
>
> OCI_Connection *cn;
> OCI_Statement *st;
>
> in the header file. Then I declared in the main() file as global variables:
>
> OCI_Connection *cn = NULL; /* file scope, external linkage */
> OCI_Statement *st = NULL; /* file scope, external linkage */
>
> The OCILIB connection is now seen by all functions and all files used by the program.
>
>
> ----- Original Message -----
> From: mod...@co...
> To: "vincent rogier"<vin...@ya...>
> Cc: orc...@li...
> Sent: Tuesday, April 10, 2012 8:04:29 AM
> Subject: [Orclib-users] How to pass OCILIB connection to a function in C?
>
> Hello, If I'm using OCILIB in the main function, such as:
>
> int main (void)
> {
> OCI_Connection *cn;
> OCI_Statement *st;
> ...
> OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT);
> OCI_EnableWarnings(TRUE);
> cn = OCI_ConnectionCreate(...);
> st = OCI_StatementCreate(cn);
> ...
> my_function(...);
> }
>
>
> When I create a new function, my_function, how do I pass the existing OCILIB connection into my_function for use? I want to avoid opening a new connection in my_function if it is not necessary.
>
> For example, I'd like to pass *cn and *st above into my_function.
i'd rather wrap those attributes into a struct being passed to the
called function. see how it's done within icinga idoutils using ocilib.
>
>
>
> ------------------------------------------------------------------------------
> Better than sec? Nothing is better than sec when it comes to
> monitoring Big Data applications. Try Boundary one-second
> resolution app monitoring today. Free.
> http://p.sf.net/sfu/Boundary-dev2dev
> _______________________________________________
> Orclib-users mailing list
> Orc...@li...
> https://lists.sourceforge.net/lists/listinfo/orclib-users
>
> ------------------------------------------------------------------------------
> Better than sec? Nothing is better than sec when it comes to
> monitoring Big Data applications. Try Boundary one-second
> resolution app monitoring today. Free.
> http://p.sf.net/sfu/Boundary-dev2dev
> _______________________________________________
> Orclib-users mailing list
> Orc...@li...
> https://lists.sourceforge.net/lists/listinfo/orclib-users
--
DI (FH) Michael Friedrich
Vienna University Computer Center
Universitaetsstrasse 7 A-1010 Vienna, Austria
email: mic...@un...
phone: +43 1 4277 14359
mobile: +43 664 60277 14359
fax: +43 1 4277 14338
web: http://www.univie.ac.at/zid
http://www.aco.net
Lead Icinga Core Developer
http://www.icinga.org
|