orclib-users Mailing List for OCILIB - C and C++ Driver for Oracle (Page 4)
Open source C and C++ library for accessing Oracle Databases
Brought to you by:
vince_del_paris
You can subscribe to this list here.
2008 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
2011 |
Jan
(1) |
Feb
(3) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
(5) |
Apr
(16) |
May
(2) |
Jun
(4) |
Jul
|
Aug
(6) |
Sep
(5) |
Oct
(4) |
Nov
|
Dec
(12) |
2013 |
Jan
(6) |
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(5) |
Sep
(4) |
Oct
|
Nov
(8) |
Dec
|
2014 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(4) |
Dec
|
2015 |
Jan
(18) |
Feb
(9) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(5) |
Dec
(1) |
2016 |
Jan
(1) |
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Petr V. <pe...@ya...> - 2012-12-05 08:11:00
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 hi Vincent, yes, it makes perfect sense to me. I'm looking forward to it! p. On 12/5/12 9:07 AM, vincent rogier wrote: > Hi, > > > About coding, this is a secondary easy task that required only just few lines of code. > I'm more focused on how to integrate to OCILIB. > Is the following mock-up all right for you ? > > > #include "ocilib.h" > > #ifdef _WINDOWS > #define sleep(x) Sleep(x*1000) > #endif > > #define PORT 5468 > #define TIMEOUT 0 > > void event_handler(OCI_Event *event); > void error_handler(OCI_Error *err); > > int main(void) > { > OCI_Connection *con; > OCI_Subscription *sub; > OCI_Dequeue *deq1; > OCI_Dequeue *deq2; > > OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT | OCI_ENV_EVENTS | OCI_ENV_THREADED); > > con = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT); > sub = OCI_SubscriptionRegister(con, "SUB-MSG", OCI_CNT_MESSAGE, event_handler, PORT, TIMEOUT); > inf = OCI_TypeInfoGet(con, "MY_MESSAGE", OCI_TIF_TYPE); > deq1 = OCI_DequeueCreate(inf, "MY_QUEUE"); > deq2 = OCI_DequeueCreate(inf, "MY_QUEUE"); > > OCI_DequeueSetConsumer(deq1, "CONSUMER1"); > OCI_DequeueSetConsumer(deq2, "CONSUMER2"); > > OCI_SubscriptionAddDequeue(sub, deq1); > OCI_SubscriptionAddDequeue(sub, deq2); > > sleep(MAX_INT); > > OCI_DequeueFree(deq1); > OCI_DequeueFree(deq2); > OCI_SubscriptionUnregister(sub); > OCI_ConnectionFree(con); > > OCI_Cleanup(); > > return EXIT_SUCCESS; > } > > void error_handler(OCI_Error *err) > { > printf("*** error : %s\n", OCI_ErrorGetString(err)); > } > > void event_handler(OCI_Event *event) > { > OCI_Dequeue *deq = OCI_EventGetDequeue(event); > OCI_Msg *msg = OCI_DequeueGet(deq); > > /* process payload */ > } > > > > On Tue, Dec 4, 2012 at 8:57 PM, Petr Vaněk <pe...@ya... <mailto:pe...@ya...>> wrote: > > OCI_SubscriptionAddDequeue > > > > > -- > Vincent Rogier -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with undefined - http://www.enigmail.net/ iQEcBAEBAgAGBQJQvwGAAAoJEC8yRjM4uE2t7MwH/iYJyM13uHjr7pEYewQJ+cLV 5iYQTyB6RrD5TCVDXyid9KB55AVHHtef4yr24HDkMTxAit0D+ayP3T51EqV7ojuf ncqMR895TJMleK01+NSy9W0jzevj81/K8Tia3QO6QdXJd7EPNHiBY0m2EYJaTPbI AY1H47IKTWadMs2VCEuvV5zMzTf/RP7765FpKB/91/+Tm14A6A4SUY1QRc9mLRJ2 +vCy6UU8MXhEngKmFUKB+ZBte7YB8GdxrNeStM2vIHTYuRqYEgvzZLmU3oIwubw6 kOSOy1evKLuXNqe9DxbIwfMdE2T1DMvEtryLGUrHLG3UR35r5LwkhIW7Fp00VD8= =vGEd -----END PGP SIGNATURE----- |
From: vincent r. <vin...@ya...> - 2012-12-05 08:07:37
|
Hi, About coding, this is a secondary easy task that required only just few lines of code. I'm more focused on how to integrate to OCILIB. Is the following mock-up all right for you ? #include "ocilib.h" #ifdef _WINDOWS #define sleep(x) Sleep(x*1000) #endif #define PORT 5468 #define TIMEOUT 0 void event_handler(OCI_Event *event); void error_handler(OCI_Error *err); int main(void) { OCI_Connection *con; OCI_Subscription *sub; OCI_Dequeue *deq1; OCI_Dequeue *deq2; OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT | OCI_ENV_EVENTS | OCI_ENV_THREADED); con = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT); sub = OCI_SubscriptionRegister(con, "SUB-MSG", OCI_CNT_MESSAGE, event_handler, PORT, TIMEOUT); inf = OCI_TypeInfoGet(con, "MY_MESSAGE", OCI_TIF_TYPE); deq1 = OCI_DequeueCreate(inf, "MY_QUEUE"); deq2 = OCI_DequeueCreate(inf, "MY_QUEUE"); OCI_DequeueSetConsumer(deq1, "CONSUMER1"); OCI_DequeueSetConsumer(deq2, "CONSUMER2"); OCI_SubscriptionAddDequeue(sub, deq1); OCI_SubscriptionAddDequeue(sub, deq2); sleep(MAX_INT); OCI_DequeueFree(deq1); OCI_DequeueFree(deq2); OCI_SubscriptionUnregister(sub); OCI_ConnectionFree(con); OCI_Cleanup(); return EXIT_SUCCESS; } void error_handler(OCI_Error *err) { printf("*** error : %s\n", OCI_ErrorGetString(err)); } void event_handler(OCI_Event *event) { OCI_Dequeue *deq = OCI_EventGetDequeue(event); OCI_Msg *msg = OCI_DequeueGet(deq); /* process payload */ } On Tue, Dec 4, 2012 at 8:57 PM, Petr Vaněk <pe...@ya...> wrote: > OCI_SubscriptionAddDequeue -- Vincent Rogier |
From: Petr V. <pe...@ya...> - 2012-12-04 19:57:36
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 it sounds really great (except some minor things). OCI_CNT_ENQUEUE is quite cryptic to me. I use OCI_CNT_AQMESSAGES in my code as it sounds more descriptive to me (if course it's just a minor stuff). The proposed OCI_EventGetDequeue() - I assume it should use only previously registered OCI_Dequeue by OCI_SubscriptionAddDequeue, right? I fully agree that contain OCI_Dequeue in OCI_event is much better than diplicated "queue name" and "consumer" etc. attributes. So what about implementation, please? Should I do it or do you want to do it yourself? (remember that you know OCI much better than me probably ;)). In the case I should do it: can I access the latest code? Or should I use the latest release? thanks, petr On 12/4/12 3:34 PM, vincent rogier wrote: > Hi Petr, > > > Got the logic :) > > Thus, I would suggest another implementation : > > > * Add flag OCI_CNT_ENQUEUE to OCI_SubscriptionRegister() documented as exclusive (cannot be combined with other ones) > * Add value OCI_ENT_ENQUEUE to OCI_EventGetType() > * Add Method OCI_EventGetDequeue() that returns an OCI_Dequeue object > * Add method OCI_SubscriptionAddDequeue(OCI_Subscription *sub, OCI_Dequeue *dequeue) that will add an existing dequeues objects to an internal list of dequeue objects > * When the internal callback is fired, it looks up the matching OCI_Dequeue object (queue name and current consumer or consumer list) and if found fires the event with the Dequeue property set > > Thus you can have directly the Dequeue object from the event :) > > > What do you think ? > > > On Tue, Dec 4, 2012 at 2:00 PM, Petr Vaněk <pe...@ya... <mailto:pe...@ya...>> wrote: > > real dequeueing will > > > > > -- > Vincent Rogier -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with undefined - http://www.enigmail.net/ iQEcBAEBAgAGBQJQvlWjAAoJEC8yRjM4uE2tAF0H/AxHvym+vSpo037JGF4Qqwqk eESHU0nKGp/z/oAmubYO/yUfnEI6FtsRuCUhMHJY0Xu2E4Da5DpZw6Yci3ldqh+C 68PsI47QzRATzTwxY3o0bIlRaXPZAIMl5qvR3g/EvOkDOmrDxs655h+CAi3ugNI6 4PUXvNproFWUXm/pCBNFMO0SViVgOJTZz7qB7Sr5323C1mtQ/vWP6AZvYs298DTd +rcZSrTwdR/S+KcH3tF5A3FQsQv8qU1xEswzNq0xz9gTZbQshoq5rBqS1zPk/F7a LB2nDvYeqW25H9cOKSHvASctjDvK+rsAgd0dl+FaEdbuU/D4xAt4IVkcZkcDNP8= =3s+g -----END PGP SIGNATURE----- |
From: vincent r. <vin...@ya...> - 2012-12-04 14:34:41
|
Hi Petr, Got the logic :) Thus, I would suggest another implementation : * Add flag OCI_CNT_ENQUEUE to OCI_SubscriptionRegister() documented as exclusive (cannot be combined with other ones) * Add value OCI_ENT_ENQUEUE to OCI_EventGetType() * Add Method OCI_EventGetDequeue() that returns an OCI_Dequeue object * Add method OCI_SubscriptionAddDequeue(OCI_Subscription *sub, OCI_Dequeue *dequeue) that will add an existing dequeues objects to an internal list of dequeue objects * When the internal callback is fired, it looks up the matching OCI_Dequeue object (queue name and current consumer or consumer list) and if found fires the event with the Dequeue property set Thus you can have directly the Dequeue object from the event :) What do you think ? On Tue, Dec 4, 2012 at 2:00 PM, Petr Vaněk <pe...@ya...> wrote: > real dequeueing will -- Vincent Rogier |
From: Petr V. <pe...@ya...> - 2012-12-04 13:00:38
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Vincent, the basic usecase is to have resource friendly way how to get AQ messages from the server. The main purbose is to inform client that data are ready to be dequeued. Lets take an example: there is a PL/SQL app doing various business logic resulting in unpredictable timing of posting messages to queues (some kind of notifications to an external app). Currently the external app have to perform polling against the DB/queue to get these messages. In the case you have more queues you need to poll in more loops etc. When there will be a subscription to AQ available we will be able to just wait for an event = to work fully asynchronously (external app is already doing some stuff etc.). So basically - yes, it's something like "monitoring" but it could allow stuff like this (pseudocode): installAQSubscription(...); ... do something ... ... and when DB writes a message to the queue, notify arrives... my_aq_handler(...) { if (queue_name == 'user.foo') handleMessagesFromFoo(); ... } real dequeueing will be done by already existing AQ ocilib implementation. thanks, petr On 12/4/12 1:45 PM, vincent rogier wrote: > Hi Petr, > > I already have in my plans to add support to CQN.. > > OCILIB currently support CDN introduced in 10g. > CQN is an extension of CDN and has been introduced in 11g. > > when I added support for CDN, I saw that subscription could be done against AQ. > when I looked at it, i thought that implementing notifications just for being notified of enqueuing was not a priority. > I may have misunderstood its pertinence. > > If I have well understood, you want to add event notification on AQ for being informed that a user has received a message into queue ? Kind of monitoring ? > Or is there more information you want to get ? More information that the one you've exposed in your code are available > > Regards, > > vincent > > > > > On Mon, Dec 3, 2012 at 7:53 PM, Petr Vaněk <pe...@ya... <mailto:pe...@ya...>> wrote: > > hi Vincent and gang, > > I'd like to introduce you an idea about an addon to DCN or CQN > notifications/callback ocilib framework - notifications and callback > API for Advanced Queueing (AQ). > > You can see it in this temporary git repository: > > https://github.com/pvanek/ocilib > > this is based on the latest ocilib 3.10.0 with these changes: > > > - an initial support for AQ callback: > https://github.com/pvanek/ocilib/commit/0b44a5247829ef52c61694cfc2187396f88ef62f > > Note: this is not a final code, I'd like to know your opinion first. > There is no doc etc. > > * backward compatibility stays as is - there are no changes in > existing public API > * new function OCI_SubscriptionRegisterAQ, similar to > OCI_SubscriptionRegister but it uses AQ's OCI_SUBSCR_NAMESPACE_AQ > subscription context (instead of OCI_SUBSCR_NAMESPACE_DBCHANGE) > * new functions OCI_EventGetAQQueueName and > OCI_EventGetAQConsumerName to get AQ related attributes from OCI_Event > OCI_Event structure has been expanded to hold AQ attributes. > > Here I'm not sure if it's a good idea to expanc existing OCI_Event or > create new AQ-only similar struct and related functions. I'm open to > suggestions here. > > a small example: > > #include "ocilib.h" > > #ifdef _WINDOWS > #define sleep(x) Sleep(x*1000) > #else > #include <unistd.h> > #endif > > #define wait_for_events() sleep(15) > > void event_handler(OCI_Event *event); > void error_handler(OCI_Error *err); > > int main(void) > { > OCI_Connection *con; > OCI_Subscription *sub; > OCI_Statement *st; > > printf("=> Initializing OCILIB in event mode...\n\n"); > > if (!OCI_Initialize(error_handler, NULL, OCI_ENV_EVENTS)) > return EXIT_FAILURE; > > con = OCI_ConnectionCreate("stimpy", "omquser", "omquser", > OCI_SESSION_DEFAULT); > > sub = OCI_SubscriptionRegisterAQ(con, "omquser.testaq", > event_handler, 5468, 0); > > wait_for_events(); > > OCI_ConnectionFree(con); > OCI_SubscriptionUnregister(sub); > OCI_Cleanup(); > return EXIT_SUCCESS; > } > > void error_handler(OCI_Error *err) > { > int err_type = OCI_ErrorGetType(err); > const char *err_msg = OCI_ErrorGetString(err); > > printf("** %s - %s\n", err_type == OCI_ERR_WARNING ? "Warning" : > "Error", err_msg); > } > > void event_handler(OCI_Event *event) > { > unsigned int type = OCI_EventGetType(event); > unsigned int op = OCI_EventGetOperation(event); > OCI_Subscription *sub = OCI_EventGetSubscription(event); > > printf("** Notification : %s\n\n", OCI_SubscriptionGetName(sub)); > printf("... Queue Name : %s\n", > OCI_EventGetAQQueueName(event)); > printf(". Consumer Name : %s\n", > OCI_EventGetAQConsumerName(event)); > > printf("\n"); > } > > > > > > - pkg-config feature added (ocilib.pc): > https://github.com/pvanek/ocilib/commit/6ba08629bb3be6229b19bae577af241fade2202c > This feature is ready to be merged. It allows easy use of ocilib in > cmake, autotools, and similar build tools > > cmake example: > find_package(PkgConfig) > pkg_check_modules(OCILIB REQUIRED ocilib>=3.10) > message(STATUS "includes: ${OCILIB_INCLUDE_DIRS}") > message(STATUS " libs: ${OCILIB_LIBRARIES}") > message(STATUS "lib dirs: ${OCILIB_LIBRARY_DIRS}") > > > > looking forward your comments, > petr > > ------------------------------------------------------------------------------ > Keep yourself connected to Go Parallel: > BUILD Helping you discover the best ways to construct your parallel projects. > http://goparallel.sourceforge.net > _______________________________________________ > Orclib-users mailing list > Orc...@li... <mailto:Orc...@li...> > https://lists.sourceforge.net/lists/listinfo/orclib-users > > > > > -- > Vincent Rogier -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with undefined - http://www.enigmail.net/ iQEcBAEBAgAGBQJQvfPlAAoJEC8yRjM4uE2tdYgH/RMXV8tA/muGigVVN38Fhxhu ltj/CvPmYfUDAK+MAbRStmpumz4uAvYPeawCJEWhHHUCBsthgeRwdXUUs0H+OMg7 aVcvU/KkCIoYBD1navDEYY1+uVldIciUxf36FfHnk7fwQtNXlZi3VRr6UPRkCjGn XK/KiR0udfe2hrB+pVSh0ImXFD08kj2JyQSV6P+ZF69Kd/2wFCJdAOAgWDpWADMX SuYrRKpidpmjqBcLNT0PbyMDcoXihzho/MpAMfr24nhLCBPJAT5nJP2TA6OfMVqC nAKmmExDDFk2bGVcFrF+R18Bac2l6L636nR2OMy4F8A+ZE6InPK8HRbRHKccEVM= =n04O -----END PGP SIGNATURE----- |
From: vincent r. <vin...@ya...> - 2012-12-04 12:46:21
|
Hi Petr, I already have in my plans to add support to CQN.. OCILIB currently support CDN introduced in 10g. CQN is an extension of CDN and has been introduced in 11g. when I added support for CDN, I saw that subscription could be done against AQ. when I looked at it, i thought that implementing notifications just for being notified of enqueuing was not a priority. I may have misunderstood its pertinence. If I have well understood, you want to add event notification on AQ for being informed that a user has received a message into queue ? Kind of monitoring ? Or is there more information you want to get ? More information that the one you've exposed in your code are available Regards, vincent On Mon, Dec 3, 2012 at 7:53 PM, Petr Vaněk <pe...@ya...> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > hi Vincent and gang, > > I'd like to introduce you an idea about an addon to DCN or CQN > notifications/callback ocilib framework - notifications and callback > API for Advanced Queueing (AQ). > > You can see it in this temporary git repository: > > https://github.com/pvanek/ocilib > > this is based on the latest ocilib 3.10.0 with these changes: > > > - - an initial support for AQ callback: > > https://github.com/pvanek/ocilib/commit/0b44a5247829ef52c61694cfc2187396f88ef62f > > Note: this is not a final code, I'd like to know your opinion first. > There is no doc etc. > > * backward compatibility stays as is - there are no changes in > existing public API > * new function OCI_SubscriptionRegisterAQ, similar to > OCI_SubscriptionRegister but it uses AQ's OCI_SUBSCR_NAMESPACE_AQ > subscription context (instead of OCI_SUBSCR_NAMESPACE_DBCHANGE) > * new functions OCI_EventGetAQQueueName and > OCI_EventGetAQConsumerName to get AQ related attributes from OCI_Event > OCI_Event structure has been expanded to hold AQ attributes. > > Here I'm not sure if it's a good idea to expanc existing OCI_Event or > create new AQ-only similar struct and related functions. I'm open to > suggestions here. > > a small example: > > #include "ocilib.h" > > #ifdef _WINDOWS > #define sleep(x) Sleep(x*1000) > #else > #include <unistd.h> > #endif > > #define wait_for_events() sleep(15) > > void event_handler(OCI_Event *event); > void error_handler(OCI_Error *err); > > int main(void) > { > OCI_Connection *con; > OCI_Subscription *sub; > OCI_Statement *st; > > printf("=> Initializing OCILIB in event mode...\n\n"); > > if (!OCI_Initialize(error_handler, NULL, OCI_ENV_EVENTS)) > return EXIT_FAILURE; > > con = OCI_ConnectionCreate("stimpy", "omquser", "omquser", > OCI_SESSION_DEFAULT); > > sub = OCI_SubscriptionRegisterAQ(con, "omquser.testaq", > event_handler, 5468, 0); > > wait_for_events(); > > OCI_ConnectionFree(con); > OCI_SubscriptionUnregister(sub); > OCI_Cleanup(); > return EXIT_SUCCESS; > } > > void error_handler(OCI_Error *err) > { > int err_type = OCI_ErrorGetType(err); > const char *err_msg = OCI_ErrorGetString(err); > > printf("** %s - %s\n", err_type == OCI_ERR_WARNING ? "Warning" : > "Error", err_msg); > } > > void event_handler(OCI_Event *event) > { > unsigned int type = OCI_EventGetType(event); > unsigned int op = OCI_EventGetOperation(event); > OCI_Subscription *sub = OCI_EventGetSubscription(event); > > printf("** Notification : %s\n\n", OCI_SubscriptionGetName(sub)); > printf("... Queue Name : %s\n", > OCI_EventGetAQQueueName(event)); > printf(". Consumer Name : %s\n", > OCI_EventGetAQConsumerName(event)); > > printf("\n"); > } > > > > > > - - pkg-config feature added (ocilib.pc): > > https://github.com/pvanek/ocilib/commit/6ba08629bb3be6229b19bae577af241fade2202c > This feature is ready to be merged. It allows easy use of ocilib in > cmake, autotools, and similar build tools > > cmake example: > find_package(PkgConfig) > pkg_check_modules(OCILIB REQUIRED ocilib>=3.10) > message(STATUS "includes: ${OCILIB_INCLUDE_DIRS}") > message(STATUS " libs: ${OCILIB_LIBRARIES}") > message(STATUS "lib dirs: ${OCILIB_LIBRARY_DIRS}") > > > > looking forward your comments, > petr > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.12 (Darwin) > Comment: GPGTools - http://gpgtools.org > Comment: Using GnuPG with undefined - http://www.enigmail.net/ > > iQEcBAEBAgAGBQJQvPU0AAoJEC8yRjM4uE2t7mUIAIKZw2C6kbylNE3ndmTSpl6t > xEjVpKxnrVtc65G3bXhk19b2HhiseMXjNqMLW80+1Q5IvOHF4rpJew8m5vS29Lq/ > HOOhKfSL1xa9N/MQ9oorMwi+eZDsK1MEJlh8e9okdSnrEoYkX9BRX7P0u0XyiPk7 > 3HiatyEkPKS1zh2PKqfQyeXKxweQloceDQbe8Q4RtseeG9yB3dylq2qjtsB/17MG > rqUNm8Dl8Ws1dxTyjfamjtSUxzRPVYIW0QjcH+bQlvlBxnBOgStQqBHT/34v5w1x > /LoPhXCUa7zlfXvRVP6F9JSKWQ+clm6my7rrL+2gLL4Z3VeMWqfg1IR+lkvQJaM= > =I1ma > -----END PGP SIGNATURE----- > > > ------------------------------------------------------------------------------ > Keep yourself connected to Go Parallel: > BUILD Helping you discover the best ways to construct your parallel > projects. > http://goparallel.sourceforge.net > _______________________________________________ > Orclib-users mailing list > Orc...@li... > https://lists.sourceforge.net/lists/listinfo/orclib-users > -- Vincent Rogier |
From: Petr V. <pe...@ya...> - 2012-12-03 19:12:47
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 hi Vincent and gang, I'd like to introduce you an idea about an addon to DCN or CQN notifications/callback ocilib framework - notifications and callback API for Advanced Queueing (AQ). You can see it in this temporary git repository: https://github.com/pvanek/ocilib this is based on the latest ocilib 3.10.0 with these changes: - - an initial support for AQ callback: https://github.com/pvanek/ocilib/commit/0b44a5247829ef52c61694cfc2187396f88ef62f Note: this is not a final code, I'd like to know your opinion first. There is no doc etc. * backward compatibility stays as is - there are no changes in existing public API * new function OCI_SubscriptionRegisterAQ, similar to OCI_SubscriptionRegister but it uses AQ's OCI_SUBSCR_NAMESPACE_AQ subscription context (instead of OCI_SUBSCR_NAMESPACE_DBCHANGE) * new functions OCI_EventGetAQQueueName and OCI_EventGetAQConsumerName to get AQ related attributes from OCI_Event OCI_Event structure has been expanded to hold AQ attributes. Here I'm not sure if it's a good idea to expanc existing OCI_Event or create new AQ-only similar struct and related functions. I'm open to suggestions here. a small example: #include "ocilib.h" #ifdef _WINDOWS #define sleep(x) Sleep(x*1000) #else #include <unistd.h> #endif #define wait_for_events() sleep(15) void event_handler(OCI_Event *event); void error_handler(OCI_Error *err); int main(void) { OCI_Connection *con; OCI_Subscription *sub; OCI_Statement *st; printf("=> Initializing OCILIB in event mode...\n\n"); if (!OCI_Initialize(error_handler, NULL, OCI_ENV_EVENTS)) return EXIT_FAILURE; con = OCI_ConnectionCreate("stimpy", "omquser", "omquser", OCI_SESSION_DEFAULT); sub = OCI_SubscriptionRegisterAQ(con, "omquser.testaq", event_handler, 5468, 0); wait_for_events(); OCI_ConnectionFree(con); OCI_SubscriptionUnregister(sub); OCI_Cleanup(); return EXIT_SUCCESS; } void error_handler(OCI_Error *err) { int err_type = OCI_ErrorGetType(err); const char *err_msg = OCI_ErrorGetString(err); printf("** %s - %s\n", err_type == OCI_ERR_WARNING ? "Warning" : "Error", err_msg); } void event_handler(OCI_Event *event) { unsigned int type = OCI_EventGetType(event); unsigned int op = OCI_EventGetOperation(event); OCI_Subscription *sub = OCI_EventGetSubscription(event); printf("** Notification : %s\n\n", OCI_SubscriptionGetName(sub)); printf("... Queue Name : %s\n", OCI_EventGetAQQueueName(event)); printf(". Consumer Name : %s\n", OCI_EventGetAQConsumerName(event)); printf("\n"); } - - pkg-config feature added (ocilib.pc): https://github.com/pvanek/ocilib/commit/6ba08629bb3be6229b19bae577af241fade2202c This feature is ready to be merged. It allows easy use of ocilib in cmake, autotools, and similar build tools cmake example: find_package(PkgConfig) pkg_check_modules(OCILIB REQUIRED ocilib>=3.10) message(STATUS "includes: ${OCILIB_INCLUDE_DIRS}") message(STATUS " libs: ${OCILIB_LIBRARIES}") message(STATUS "lib dirs: ${OCILIB_LIBRARY_DIRS}") looking forward your comments, petr -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with undefined - http://www.enigmail.net/ iQEcBAEBAgAGBQJQvPU0AAoJEC8yRjM4uE2t7mUIAIKZw2C6kbylNE3ndmTSpl6t xEjVpKxnrVtc65G3bXhk19b2HhiseMXjNqMLW80+1Q5IvOHF4rpJew8m5vS29Lq/ HOOhKfSL1xa9N/MQ9oorMwi+eZDsK1MEJlh8e9okdSnrEoYkX9BRX7P0u0XyiPk7 3HiatyEkPKS1zh2PKqfQyeXKxweQloceDQbe8Q4RtseeG9yB3dylq2qjtsB/17MG rqUNm8Dl8Ws1dxTyjfamjtSUxzRPVYIW0QjcH+bQlvlBxnBOgStQqBHT/34v5w1x /LoPhXCUa7zlfXvRVP6F9JSKWQ+clm6my7rrL+2gLL4Z3VeMWqfg1IR+lkvQJaM= =I1ma -----END PGP SIGNATURE----- |
From: Kourosh A. <kou...@gm...> - 2012-10-12 14:50:00
|
Hi, Thanks! I will look further in the documentation about use of thread keys. Kourosh At 11:53 PM 10/11/2012, vincent rogier wrote: >Hi, > >Can you be more precise ? > >You can use thread keys (see their use in OCILIB documentation). > >Regards, > >Vincent > >On Tue, Oct 9, 2012 at 5:26 AM, Kourosh Ashkon ><<mailto:kou...@gm...>kou...@gm...> wrote: >Hi, > >A C program creates a few threads and they all call the same C >function but each thread passes its own unique value to the C function. > >However, as new threads are called, they over-ride a previous threads' values! > >How can threads be used to ensure that the same C programming >function called by them, do not use or over-ride another thread's >previous values. > >Any suggestions and/or comments would be appreciated. > >Thank you! > > >------------------------------------------------------------------------------ >Don't let slow site performance ruin your business. Deploy New Relic APM >Deploy New Relic app performance management and know exactly >what is happening inside your Ruby, Python, PHP, Java, and .NET app >Try New Relic at no cost today and get our sweet Data Nerd shirt too! ><http://p.sf.net/sfu/newrelic-dev2dev>http://p.sf.net/sfu/newrelic-dev2dev >_______________________________________________ >Orclib-users mailing list ><mailto:Orc...@li...>Orc...@li... >https://lists.sourceforge.net/lists/listinfo/orclib-users > > > > >-- >Vincent Rogier |
From: vincent r. <vin...@ya...> - 2012-10-12 06:54:29
|
Hi, Can you be more precise ? You can use thread keys (see their use in OCILIB documentation). Regards, Vincent On Tue, Oct 9, 2012 at 5:26 AM, Kourosh Ashkon <kou...@gm...>wrote: > Hi, > > A C program creates a few threads and they all call the same C > function but each thread passes its own unique value to the C function. > > However, as new threads are called, they over-ride a previous threads' > values! > > How can threads be used to ensure that the same C programming > function called by them, do not use or over-ride another thread's > previous values. > > Any suggestions and/or comments would be appreciated. > > Thank you! > > > > ------------------------------------------------------------------------------ > Don't let slow site performance ruin your business. Deploy New Relic APM > Deploy New Relic app performance management and know exactly > what is happening inside your Ruby, Python, PHP, Java, and .NET app > Try New Relic at no cost today and get our sweet Data Nerd shirt too! > http://p.sf.net/sfu/newrelic-dev2dev > _______________________________________________ > Orclib-users mailing list > Orc...@li... > https://lists.sourceforge.net/lists/listinfo/orclib-users > -- Vincent Rogier |
From: Kourosh A. <kou...@gm...> - 2012-10-09 03:27:11
|
Hi, A C program creates a few threads and they all call the same C function but each thread passes its own unique value to the C function. However, as new threads are called, they over-ride a previous threads' values! How can threads be used to ensure that the same C programming function called by them, do not use or over-ride another thread's previous values. Any suggestions and/or comments would be appreciated. Thank you! |
From: Kourosh A. <kou...@gm...> - 2012-10-07 09:15:15
|
Hi, I am using OCILIB direct path loading. You can refer to the example provided in the documentation. I want to load about 200 data files using OCILIB direct path loading. My code is very similar to the OCILIB example. The program terminates with an error message that "A null Statement handle has been provided" once it gets to the 138th data file. The first 137 data files load successfully without any errors. I added a conditional that after 130 data files have been loaded to commit the changes (OCI_DirPathFinish (dp)), and also free the direct path object (OCI_DirPathFree (dp)) and then re-create the direct path handle, set optional direct path loads, etc. The program successfully loads the first 130 data files. It then loads 7 more data files successfully and on the 8th one (138th) it terminates with the same error message that a null handle was passed. I increased the buffer size, and it did not fix the error. Any suggestions, comments would be appreciated. Thank you! |
From: Kourosh A. <kou...@gm...> - 2012-09-27 00:18:24
|
Hi, Thanks for the error handler. It showed that OCI_ObjectSetString works fine. But, OCI_ElemSetObject and OCI_CollAppend report errors that " A null Statement handle has been provided". That seems to be the reason a null is inserted for the collection. I checked the syntax and I could not find anything wrong with the two following high lighted in red: : : field6_col_obj = OCI_ObjectCreate (cn, OCI_TypeInfoGet(cn, "field6_col_typ", OCI_TIF_TYPE)); field6_col_elem = OCI_ElemCreate (OCI_TypeInfoGet(cn, "field6_col_typ", OCI_TIF_TYPE)); field6_col_coll = OCI_CollCreate (OCI_TypeInfoGet(cn, "field6_col_tab_typ", OCI_TIF_TYPE)); OCI_ObjectSetString (field6_col_obj, "field6_name", "test123"); error: OCI_ElemSetObject (field6_col_elem, field6_col_obj); error: OCI_CollAppend (field6_col_coll, field6_col_elem); : : At 02:03 PM 9/26/2012, vincent rogier wrote: >Let me know if you have solved your problem > >On Wed, Sep 26, 2012 at 10:48 PM, Kourosh Ashkon ><<mailto:kou...@gm...>kou...@gm...> wrote: >Thank you! >Regards, > >At 01:37 PM 9/26/2012, vincent rogier wrote: >>Hi, >>First, always use an error handler. This would tell why i does not >>work. Try again with an error handler. >>Also, use OCI_CollAppend() instead of OCI_CollSetAt(). >>Regards, >>Vincent >> >>On Wed, Sep 26, 2012 at 9:38 PM, Kourosh Ashkon >><<mailto:kou...@gm...>kou...@gm... > wrote: >>Hi, >>I have a simple table with the last column as a collection. I >>created an object and assigned a value to it. Then I created an >>element and assigned the object to it. Then I created a collection >>and assigned the element to it. When I insert in to the table it >>enters null for the collection. Can you help? >>The following are the type definitions and the C code. >>Thank you in advance! >>==================================================================================================== >> >>CREATE OR REPLACE TYPE field6_coltyp AS OBJECT >>( >> field6_name varchar2(50), >>) >>/ >>CREATE OR REPLACE TYPE field6_coltab_typ AS table of field6_coltyp ; >>CREATE OR REPLACE TYPE test_table_typ AS OBJECT >> ( >> field1 varchar2(25), >> field2 varchar2(25), >> field3 varchar2(20), >> field4 timestamp, >> field5 number, >> field6 field6_coltab_typ) >>/ >>CREATE table test_table >> ( >> field1 varchar2(25), >> field2 varchar2(25), >> field3 varchar2(20), >> field4 timestamp, >> field5 number, >> field6 field6_coltab_typ) >> NESTED TABLE field6 STORE AS field6_tab >>/ >> >>----------------------------------------------- >>#include <stdio.h> >>#include <ctype.h> >>#include <stdlib.h> >>#include <string.h> >>#include <time.h> >>#include "ocilib.h" >>int main(void) >>{ >> OCI_Connection *cn; >> OCI_Statement *st; >> char field1 [25]; >> char field2 [25]; >> char field3 [25]; >> char field4 [30]; >> char field5 [25]; >> OCI_Coll* field6_col_coll; >> OCI_Elem* field6_col_elem; >> OCI_Object* field6_col_obj; >> OCI_TypeInfo *type; >> OCI_Iter *iter; >> >> int i; >> if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) >> return EXIT_FAILURE; >> cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT); >> if (cn != NULL) >> { >> st = OCI_StatementCreate(cn); >> field6_col_obj = OCI_ObjectCreate (cn, OCI_TypeInfoGet(cn, >> "field6_col_typ", OCI_TIF_TYPE)); >> field6_col_elem = OCI_ElemCreate (OCI_TypeInfoGet(cn, >> "field6_col_typ", OCI_TIF_TYPE)); >> field6_col_coll = OCI_CollCreate (OCI_TypeInfoGet(cn, >> "field6_col_tab_typ", OCI_TIF_TYPE)); >> OCI_ObjectSetString (field6_col_obj, "field6_name", "test123"); >> OCI_ElemSetObject (field6_col_elem, field6_col_obj); >> OCI_CollSetAt (field6_col_coll, 1, field6_col_elem); >> OCI_Prepare(st, "INSERT INTO test_table VALUES (:c, :s, :x, >> :d, :g, :h)"); >> memset (field1, 0, sizeof (field1)); >> memset (field2, 0, sizeof (field2)); >> memset (field3, 0, sizeof (field3)); >> memset (field4, 0, sizeof (field4)); >> memset (field5, 0, sizeof (field5)); >> strcpy (field1, "field1_val"); >> strcpy (field2, "field2_val"); >> strcpy (field3, "field3_val"); >> strcpy (field4, "field4_val"); >> strcpy (field5, "field5_val"); >> OCI_BindString(st, ":c", field1, 25); >> OCI_BindString(st, ":s", field2, 25); >> OCI_BindString(st, ":x", field3, 25); >> OCI_BindString(st, ":d", field4, 30); >> OCI_BindString(st, ":g", field5, 25); >> OCI_BindColl(st, ":h", field6_col_coll); >> >> OCI_Execute(st); >> OCI_Commit(cn); >> OCI_ElemFree (field6_col_elem); >> OCI_CollFree (field6_col_coll); >> OCI_StatementFree(st); >> OCI_ConnectionFree(cn); >> } >> else >> printf("Failure\n"); >> OCI_Cleanup(); >> return EXIT_SUCCESS; >>} >>------------------------------------------------------------------------------ >> >>How fast is your code? >>3 out of 4 devs don\\\'t know how their code performs in production. >>Find out how slow your code is with AppDynamics Lite. >><http://ad.doubleclick.net/clk;262219672;13503038;z>http://ad.doubleclick.net/clk;262219672;13503038;z? >> >>http://info.appdynamics.com/FreeJavaPerformanceDownload.html >>_______________________________________________ >>Orclib-users mailing list >><mailto:Orc...@li...>Orc...@li... >> >>https://lists.sourceforge.net/lists/listinfo/orclib-users >> >> >> >> >>-- >>Vincent Rogier > > > >-- >Vincent Rogier |
From: vincent r. <vin...@ya...> - 2012-09-26 21:04:13
|
Let me know if you have solved your problem On Wed, Sep 26, 2012 at 10:48 PM, Kourosh Ashkon <kou...@gm...>wrote: > Thank you! > > Regards, > > > At 01:37 PM 9/26/2012, vincent rogier wrote: > > Hi, > > First, always use an error handler. This would tell why i does not work. > Try again with an error handler. > > Also, use OCI_CollAppend() instead of OCI_CollSetAt(). > > Regards, > > Vincent > > > On Wed, Sep 26, 2012 at 9:38 PM, Kourosh Ashkon <kou...@gm...> wrote: > Hi, > > I have a simple table with the last column as a collection. I created an > object and assigned a value to it. Then I created an element and assigned > the object to it. Then I created a collection and assigned the element to > it. When I insert in to the table it enters null for the collection. Can > you help? > > The following are the type definitions and the C code. > > Thank you in advance! > ==================================================================================================== > > CREATE OR REPLACE TYPE field6_coltyp AS OBJECT > ( > field6_name varchar2(50), > ) > / > > CREATE OR REPLACE TYPE field6_coltab_typ AS table of field6_coltyp ; > > CREATE OR REPLACE TYPE test_table_typ AS OBJECT > ( > field1 varchar2(25), > field2 varchar2(25), > field3 varchar2(20), > field4 timestamp, > field5 number, > field6 field6_coltab_typ) > / > > CREATE table test_table > ( > field1 varchar2(25), > field2 varchar2(25), > field3 varchar2(20), > field4 timestamp, > field5 number, > field6 field6_coltab_typ) > NESTED TABLE field6 STORE AS field6_tab > / > > > > ----------------------------------------------- > #include <stdio.h> > #include <ctype.h> > #include <stdlib.h> > #include <string.h> > #include <time.h> > > #include "ocilib.h" > int main(void) > { > OCI_Connection *cn; > OCI_Statement *st; > > char field1 [25]; > char field2 [25]; > char field3 [25]; > char field4 [30]; > char field5 [25]; > OCI_Coll* field6_col_coll; > OCI_Elem* field6_col_elem; > OCI_Object* field6_col_obj; > > OCI_TypeInfo *type; > > OCI_Iter *iter; > > int i; > > if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) > return EXIT_FAILURE; > > cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT); > if (cn != NULL) > { > st = OCI_StatementCreate(cn); > > field6_col_obj = OCI_ObjectCreate (cn, OCI_TypeInfoGet(cn, > "field6_col_typ", OCI_TIF_TYPE)); > field6_col_elem = OCI_ElemCreate (OCI_TypeInfoGet(cn, > "field6_col_typ", OCI_TIF_TYPE)); > field6_col_coll = OCI_CollCreate (OCI_TypeInfoGet(cn, > "field6_col_tab_typ", OCI_TIF_TYPE)); > > OCI_ObjectSetString (field6_col_obj, "field6_name", "test123"); > OCI_ElemSetObject (field6_col_elem, field6_col_obj); > OCI_CollSetAt (field6_col_coll, 1, field6_col_elem); > > OCI_Prepare(st, "INSERT INTO test_table VALUES (:c, :s, :x, :d, :g, > :h)"); > > memset (field1, 0, sizeof (field1)); > memset (field2, 0, sizeof (field2)); > memset (field3, 0, sizeof (field3)); > memset (field4, 0, sizeof (field4)); > memset (field5, 0, sizeof (field5)); > > strcpy (field1, "field1_val"); > strcpy (field2, "field2_val"); > strcpy (field3, "field3_val"); > strcpy (field4, "field4_val"); > strcpy (field5, "field5_val"); > > OCI_BindString(st, ":c", field1, 25); > OCI_BindString(st, ":s", field2, 25); > OCI_BindString(st, ":x", field3, 25); > OCI_BindString(st, ":d", field4, 30); > OCI_BindString(st, ":g", field5, 25); > OCI_BindColl(st, ":h", field6_col_coll); > > OCI_Execute(st); > OCI_Commit(cn); > > OCI_ElemFree (field6_col_elem); > OCI_CollFree (field6_col_coll); > OCI_StatementFree(st); > OCI_ConnectionFree(cn); > } > else > printf("Failure\n"); > > OCI_Cleanup(); > return EXIT_SUCCESS; > } > > ------------------------------------------------------------------------------ > How fast is your code? > 3 out of 4 devs don\\\'t know how their code performs in production. > Find out how slow your code is with AppDynamics Lite. > http://ad.doubleclick.net/clk;262219672;13503038;z? > http://info.appdynamics.com/FreeJavaPerformanceDownload.html > _______________________________________________ > Orclib-users mailing list > Orc...@li... > https://lists.sourceforge.net/lists/listinfo/orclib-users > > > > > -- > Vincent Rogier > > -- Vincent Rogier |
From: Kourosh A. <kou...@gm...> - 2012-09-26 20:49:15
|
Thank you! Regards, At 01:37 PM 9/26/2012, vincent rogier wrote: >Hi, > >First, always use an error handler. This would tell why i does not >work. Try again with an error handler. > >Also, use OCI_CollAppend() instead of OCI_CollSetAt(). > >Regards, > >Vincent > > >On Wed, Sep 26, 2012 at 9:38 PM, Kourosh Ashkon ><<mailto:kou...@gm...>kou...@gm...> wrote: >Hi, > >I have a simple table with the last column as a collection. I >created an object and assigned a value to it. Then I created an >element and assigned the object to it. Then I created a collection >and assigned the element to it. When I insert in to the table it >enters null for the collection. Can you help? > >The following are the type definitions and the C code. > >Thank you in advance! >==================================================================================================== > >CREATE OR REPLACE TYPE field6_coltyp AS OBJECT >( > field6_name varchar2(50), >) >/ > >CREATE OR REPLACE TYPE field6_coltab_typ AS table of field6_coltyp ; > >CREATE OR REPLACE TYPE test_table_typ AS OBJECT > ( > field1 varchar2(25), > field2 varchar2(25), > field3 varchar2(20), > field4 timestamp, > field5 number, > field6 field6_coltab_typ) >/ > >CREATE table test_table > ( > field1 varchar2(25), > field2 varchar2(25), > field3 varchar2(20), > field4 timestamp, > field5 number, > field6 field6_coltab_typ) > NESTED TABLE field6 STORE AS field6_tab >/ > > > >----------------------------------------------- >#include <stdio.h> >#include <ctype.h> >#include <stdlib.h> >#include <string.h> >#include <time.h> > >#include "ocilib.h" >int main(void) >{ > OCI_Connection *cn; > OCI_Statement *st; > > char field1 [25]; > char field2 [25]; > char field3 [25]; > char field4 [30]; > char field5 [25]; > OCI_Coll* field6_col_coll; > OCI_Elem* field6_col_elem; > OCI_Object* field6_col_obj; > > OCI_TypeInfo *type; > > OCI_Iter *iter; > > int i; > > if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) > return EXIT_FAILURE; > > cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT); > if (cn != NULL) > { > st = OCI_StatementCreate(cn); > > field6_col_obj = OCI_ObjectCreate (cn, OCI_TypeInfoGet(cn, > "field6_col_typ", OCI_TIF_TYPE)); > field6_col_elem = OCI_ElemCreate (OCI_TypeInfoGet(cn, > "field6_col_typ", OCI_TIF_TYPE)); > field6_col_coll = OCI_CollCreate (OCI_TypeInfoGet(cn, > "field6_col_tab_typ", OCI_TIF_TYPE)); > > OCI_ObjectSetString (field6_col_obj, "field6_name", "test123"); > OCI_ElemSetObject (field6_col_elem, field6_col_obj); > OCI_CollSetAt (field6_col_coll, 1, field6_col_elem); > > OCI_Prepare(st, "INSERT INTO test_table VALUES (:c, :s, :x, > :d, :g, :h)"); > > memset (field1, 0, sizeof (field1)); > memset (field2, 0, sizeof (field2)); > memset (field3, 0, sizeof (field3)); > memset (field4, 0, sizeof (field4)); > memset (field5, 0, sizeof (field5)); > > strcpy (field1, "field1_val"); > strcpy (field2, "field2_val"); > strcpy (field3, "field3_val"); > strcpy (field4, "field4_val"); > strcpy (field5, "field5_val"); > > OCI_BindString(st, ":c", field1, 25); > OCI_BindString(st, ":s", field2, 25); > OCI_BindString(st, ":x", field3, 25); > OCI_BindString(st, ":d", field4, 30); > OCI_BindString(st, ":g", field5, 25); > OCI_BindColl(st, ":h", field6_col_coll); > > OCI_Execute(st); > OCI_Commit(cn); > > OCI_ElemFree (field6_col_elem); > OCI_CollFree (field6_col_coll); > OCI_StatementFree(st); > OCI_ConnectionFree(cn); > } > else > printf("Failure\n"); > > OCI_Cleanup(); > return EXIT_SUCCESS; >} > >------------------------------------------------------------------------------ >How fast is your code? >3 out of 4 devs don\\\'t know how their code performs in production. >Find out how slow your code is with AppDynamics Lite. ><http://ad.doubleclick.net/clk;262219672;13503038;z>http://ad.doubleclick.net/clk;262219672;13503038;z? >http://info.appdynamics.com/FreeJavaPerformanceDownload.html >_______________________________________________ >Orclib-users mailing list ><mailto:Orc...@li...>Orc...@li... >https://lists.sourceforge.net/lists/listinfo/orclib-users > > > > >-- >Vincent Rogier |
From: vincent r. <vin...@ya...> - 2012-09-26 20:37:33
|
Hi, First, always use an error handler. This would tell why i does not work. Try again with an error handler. Also, use OCI_CollAppend() instead of OCI_CollSetAt(). Regards, Vincent On Wed, Sep 26, 2012 at 9:38 PM, Kourosh Ashkon <kou...@gm...>wrote: > Hi, > > I have a simple table with the last column as a collection. I created an > object and assigned a value to it. Then I created an element and assigned > the object to it. Then I created a collection and assigned the element to > it. When I insert in to the table it enters null for the collection. Can > you help? > > The following are the type definitions and the C code. > > Thank you in advance! > > ==================================================================================================== > > CREATE OR REPLACE TYPE field6_coltyp AS OBJECT > ( > field6_name varchar2(50), > ) > / > > CREATE OR REPLACE TYPE field6_coltab_typ AS table of field6_coltyp ; > > CREATE OR REPLACE TYPE test_table_typ AS OBJECT > ( > field1 varchar2(25), > field2 varchar2(25), > field3 varchar2(20), > field4 timestamp, > field5 number, > field6 field6_coltab_typ) > / > > CREATE table test_table > ( > field1 varchar2(25), > field2 varchar2(25), > field3 varchar2(20), > field4 timestamp, > field5 number, > field6 field6_coltab_typ) > NESTED TABLE field6 STORE AS field6_tab > / > > > > ----------------------------------------------- > #include <stdio.h> > #include <ctype.h> > #include <stdlib.h> > #include <string.h> > #include <time.h> > > #include "ocilib.h" > int main(void) > { > OCI_Connection *cn; > OCI_Statement *st; > > char field1 [25]; > char field2 [25]; > char field3 [25]; > char field4 [30]; > char field5 [25]; > OCI_Coll* field6_col_coll; > OCI_Elem* field6_col_elem; > OCI_Object* field6_col_obj; > > OCI_TypeInfo *type; > > OCI_Iter *iter; > > int i; > > if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) > return EXIT_FAILURE; > > cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT); > if (cn != NULL) > { > st = OCI_StatementCreate(cn); > > * field6_col_obj = OCI_ObjectCreate (cn, OCI_TypeInfoGet(cn, > "field6_col_typ", OCI_TIF_TYPE)); > field6_col_elem = OCI_ElemCreate (OCI_TypeInfoGet(cn, > "field6_col_typ", OCI_TIF_TYPE)); > field6_col_coll = OCI_CollCreate (OCI_TypeInfoGet(cn, > "field6_col_tab_typ", OCI_TIF_TYPE)); > > OCI_ObjectSetString (field6_col_obj, "field6_name", "test123"); > OCI_ElemSetObject (field6_col_elem, field6_col_obj); > OCI_CollSetAt (field6_col_coll, 1, field6_col_elem); > > * OCI_Prepare(st, "INSERT INTO test_table VALUES (:c, :s, :x, :d, > :g, :h)"); > > memset (field1, 0, sizeof (field1)); > memset (field2, 0, sizeof (field2)); > memset (field3, 0, sizeof (field3)); > memset (field4, 0, sizeof (field4)); > memset (field5, 0, sizeof (field5)); > > strcpy (field1, "field1_val"); > strcpy (field2, "field2_val"); > strcpy (field3, "field3_val"); > strcpy (field4, "field4_val"); > strcpy (field5, "field5_val"); > > OCI_BindString(st, ":c", field1, 25); > OCI_BindString(st, ":s", field2, 25); > OCI_BindString(st, ":x", field3, 25); > OCI_BindString(st, ":d", field4, 30); > OCI_BindString(st, ":g", field5, 25); > OCI_BindColl(st, ":h", field6_col_coll); > > OCI_Execute(st); > OCI_Commit(cn); > > OCI_ElemFree (field6_col_elem); > OCI_CollFree (field6_col_coll); > OCI_StatementFree(st); > OCI_ConnectionFree(cn); > } > else > printf("Failure\n"); > > OCI_Cleanup(); > return EXIT_SUCCESS; > } > > > ------------------------------------------------------------------------------ > How fast is your code? > 3 out of 4 devs don\\\'t know how their code performs in production. > Find out how slow your code is with AppDynamics Lite. > http://ad.doubleclick.net/clk;262219672;13503038;z? > http://info.appdynamics.com/FreeJavaPerformanceDownload.html > _______________________________________________ > Orclib-users mailing list > Orc...@li... > https://lists.sourceforge.net/lists/listinfo/orclib-users > > -- Vincent Rogier |
From: Kourosh A. <kou...@gm...> - 2012-09-26 19:39:33
|
Hi, I have a simple table with the last column as a collection. I created an object and assigned a value to it. Then I created an element and assigned the object to it. Then I created a collection and assigned the element to it. When I insert in to the table it enters null for the collection. Can you help? The following are the type definitions and the C code. Thank you in advance! ==================================================================================================== CREATE OR REPLACE TYPE field6_coltyp AS OBJECT ( field6_name varchar2(50), ) / CREATE OR REPLACE TYPE field6_coltab_typ AS table of field6_coltyp ; CREATE OR REPLACE TYPE test_table_typ AS OBJECT ( field1 varchar2(25), field2 varchar2(25), field3 varchar2(20), field4 timestamp, field5 number, field6 field6_coltab_typ) / CREATE table test_table ( field1 varchar2(25), field2 varchar2(25), field3 varchar2(20), field4 timestamp, field5 number, field6 field6_coltab_typ) NESTED TABLE field6 STORE AS field6_tab / ----------------------------------------------- #include <stdio.h> #include <ctype.h> #include <stdlib.h> #include <string.h> #include <time.h> #include "ocilib.h" int main(void) { OCI_Connection *cn; OCI_Statement *st; char field1 [25]; char field2 [25]; char field3 [25]; char field4 [30]; char field5 [25]; OCI_Coll* field6_col_coll; OCI_Elem* field6_col_elem; OCI_Object* field6_col_obj; OCI_TypeInfo *type; OCI_Iter *iter; int i; if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) return EXIT_FAILURE; cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT); if (cn != NULL) { st = OCI_StatementCreate(cn); field6_col_obj = OCI_ObjectCreate (cn, OCI_TypeInfoGet(cn, "field6_col_typ", OCI_TIF_TYPE)); field6_col_elem = OCI_ElemCreate (OCI_TypeInfoGet(cn, "field6_col_typ", OCI_TIF_TYPE)); field6_col_coll = OCI_CollCreate (OCI_TypeInfoGet(cn, "field6_col_tab_typ", OCI_TIF_TYPE)); OCI_ObjectSetString (field6_col_obj, "field6_name", "test123"); OCI_ElemSetObject (field6_col_elem, field6_col_obj); OCI_CollSetAt (field6_col_coll, 1, field6_col_elem); OCI_Prepare(st, "INSERT INTO test_table VALUES (:c, :s, :x, :d, :g, :h)"); memset (field1, 0, sizeof (field1)); memset (field2, 0, sizeof (field2)); memset (field3, 0, sizeof (field3)); memset (field4, 0, sizeof (field4)); memset (field5, 0, sizeof (field5)); strcpy (field1, "field1_val"); strcpy (field2, "field2_val"); strcpy (field3, "field3_val"); strcpy (field4, "field4_val"); strcpy (field5, "field5_val"); OCI_BindString(st, ":c", field1, 25); OCI_BindString(st, ":s", field2, 25); OCI_BindString(st, ":x", field3, 25); OCI_BindString(st, ":d", field4, 30); OCI_BindString(st, ":g", field5, 25); OCI_BindColl(st, ":h", field6_col_coll); OCI_Execute(st); OCI_Commit(cn); OCI_ElemFree (field6_col_elem); OCI_CollFree (field6_col_coll); OCI_StatementFree(st); OCI_ConnectionFree(cn); } else printf("Failure\n"); OCI_Cleanup(); return EXIT_SUCCESS; } |
From: <mod...@co...> - 2012-08-30 18:20:20
|
Thanks Vincent, Perhaps the note on page 3-11 of the OCI Programmer's Guide, http://docs.oracle.com/cd/E14072_01/appdev.112/e10646.pdf is relevant here: "You may receive a round-off error when converting between FLOAT and NUMBER." Besides this loss of precision, they should have also documented the loss of range from (-1e308 to 1e308) down to (1e-87 to 1e127) when writing/reading 8 bit FLOATs to/from the database. In the JDBC world there's a useful flag called "SetFloatAndDoubleUseBinary", as shown in page 4-16 of http://docs.oracle.com/cd/E14072_01/java.112/e10589.pdf that when set "true" causes binary transfer, thereby avoiding conversion to NUMBER. There might be an easy fix if something similar already exists for OCI (I searched, but couldn't find). ----- Original Message ----- From: "vincent rogier" <vin...@ya...> To: mod...@co... Cc: orc...@li... Sent: Thursday, August 30, 2012 1:20:35 AM Subject: Re: how to write C double variable into Oracle BINARY_DOUBLE column without conversion (errors) to NUMBER? Hi, I'm on vacation until this weekend. I'll have a look at your problems asap once home and let you know. Regarding binding double, the binding call uses the oracle SQLT_FLOAT type with a size of 8 bytes. Oracle client may uses a number for converting value when it id binary double.... In this case, i will have to add a calls like OCI_BindBinaryDouble() to pass the SQLT_xxx value dedicated to binary boubles... Same for binary floats... Le 30 août 2012 03:24, < mod...@co... > a écrit : Hi Vincent, From experimentation of OCI_BindDouble in writing C double variables into an Oracle 11.2 table BINARY_DOUBLE column, such as, OCI_BindDouble(st, ":in_my_double", &my_double_variable); overflow errors occur when the value of my_double_variable is larger than the allowed value for Oracle NUMBER datatype. Thus, it appears the somewhere in the sequence of events the C variable in double-precision gets converted to Oracle NUMBER datatype, before being converted to BINARY_DOUBLE and stored in the table. This introduces conversion errors into the stored number in the database, and limits the useable range of values (BINARY_DOUBLE and C double-precision range from -1e308 to 1e308, versus NUMBER's -1e87 to 1e127). Per Oracle's documentation for Numerical Precedence (see below), this should not happen if Oracle receives double values. Does OCILIB use something similar to JDBC driver's setDouble()? If so, that would explain it, because Oracle's documentation http://docs.oracle.com/cd/E14072_01/java.112/e10589.pdf on page 4-16 states: "A call to the JDBC standard setDouble(int, double) method of the PreparedStatement interface converts the Java double argument to Oracle NUMBER style bits and send them to the database. In contrast, the setBinaryDouble(int, double) method of the oracle.jdbc.OraclePreparedStatement interface converts the data to the internal binary bits and sends them to the database." As as aside, fortunately, getDouble() avoids the conversion to NUMBER. Assuming you can reproduce this (just try a write a large number like 1e200 into a BINARY_DOUBLE column), do you know how I can get a C double variable accurately into an Oracle database BINARY_DOUBLE column using OCILIB? I suppose this would be of interest to anyone using BINARY_DOUBLE and BINARY_FLOAT with OCILIB. I do a lot of engineering/scientific work where precision and accuracy are critical. The only way I can think of is to convert the number to a string, and write that to the database, but that is not efficient. Ultimately I need to avoid conversion errors to NUMBER by preserving all the bits of BINARY_DOUBLE, along with its full range of values. Thanks in advance for any consideration. ----- Original Message ----- From: "vincent rogier" < vin...@ya... > To: mod...@co... Cc: orc...@li... Sent: Sunday, August 26, 2012 1:27:06 PM Subject: Re: installing latest OCILIB release; does OCILIB convert to Number when working with BINARY_DOUBLE? Hi, 1=> it is better to uninstall previous version and make a clean new install 2=> when using double C datatype in binding operation, the double host variable or array is directly passed to oracle. Bu you don't know how the oracle performs the values assigment. Regarding the documentation it seems to be a direct assignment. Regards Vincent Le 25 août 2012 16:18, < mod...@co... > a écrit : Hello, I have two OCILIB questions. 1) I installed OCILIB last year and have been happily using it. Now I see there is a new release with some features I'd like to use. If I wish to install the latest release, what is the procedure? That is, do I need to un-install anything? Or, do I simply follow the original installation instructions again, as documented in the OCILIB User Guide (and OCILIB with take care of itself)? 2) I don't see mention of BINARY_DOUBLE in the OCILIB User Guide, or anywhere else. Suppose I have a table in Oracle 11.2 database, with a column that is BINARY_DOUBLE datatype, and I use a PL/SQL stored procedure to select data from that column and place it, for example, in a variable out_data. When I retrieve out_data into the C variable myData using the following lines, double myData=0; ... OCI_Prepare(st, "begin get_my_data(:out_data); end;") OCI_BindDouble(st, ":out_data", &myData); OCI_Execute(st); will OCILIB convert the PL/SQL BINARY_DOUBLE variable out_data to Number datatype? Or, will OCILIB simply take the BINARY_DOUBLE variable out_data and map it exactly (via IEEE 754) into the C variable myData which is double datatype? I'm hoping there is a straight mapping to double so there's no conversion to Number that introduces conversion errors. If OCILIB does first convert to Number, is there a workaround? I also have this same question for OCI_BindArrayOfDoubles. I would think Oracle's Numerical Precedence would prevent conversion to Number, since it first looks at whether the variables involved are BINARY_DOUBLE and should therefore not convert to Number since out_data is BINARY_DOUBLE and myData is double. But I really have no idea what OCILIB is doing. ----------------------------------------------------------- The following is from Oracle documentation: Numeric Precedence Numeric precedence determines, for operations that support numeric datatypes, the datatype Oracle uses if the arguments to the operation have different datatypes. BINARY_DOUBLE has the highest numeric precedence, followed by BINARY_FLOAT, and finally by NUMBER. Therefore, in any operation on multiple numeric values: •If any of the operands is BINARY_DOUBLE, then Oracle attempts to convert all the operands implicitly to BINARY_DOUBLE before performing the operation. •If none of the operands is BINARY_DOUBLE but any of the operands is BINARY_FLOAT, then Oracle attempts to convert all the operands implicitly to BINARY_FLOAT before performing the operation. •Otherwise, Oracle attempts to convert all the operands to NUMBER before performing the operation. |
From: vincent r. <vin...@ya...> - 2012-08-30 08:20:42
|
Hi, I'm on vacation until this weekend. I'll have a look at your problems asap once home and let you know. Regarding binding double, the binding call uses the oracle SQLT_FLOAT type with a size of 8 bytes. Oracle client may uses a number for converting value when it id binary double.... In this case, i will have to add a calls like OCI_BindBinaryDouble() to pass the SQLT_xxx value dedicated to binary boubles... Same for binary floats... Le 30 août 2012 03:24, <mod...@co...> a écrit : > Hi Vincent, From experimentation of OCI_BindDouble in writing C double > variables into an Oracle 11.2 table BINARY_DOUBLE column, such as, > > OCI_BindDouble(st, ":in_my_double", &my_double_variable); > > overflow errors occur when the value of my_double_variable is larger than > the allowed value for Oracle NUMBER datatype. Thus, it appears the > somewhere in the sequence of events the C variable in double-precision gets > converted to Oracle NUMBER datatype, before being converted to > BINARY_DOUBLE and stored in the table. This introduces conversion errors > into the stored number in the database, and limits the useable range of > values (BINARY_DOUBLE and C double-precision range from -1e308 to 1e308, > versus NUMBER's -1e87 to 1e127). Per Oracle's documentation for Numerical > Precedence (see below), this should not happen if Oracle receives double > values. > > Does OCILIB use something similar to JDBC driver's setDouble()? If so, > that would explain it, because Oracle's documentation > http://docs.oracle.com/cd/E14072_01/java.112/e10589.pdf on page 4-16 > states: > > "A call to the JDBC standard setDouble(int, double) method of the > PreparedStatement interface converts the Java double argument to Oracle > NUMBER style bits and send them to the database. In contrast, the > setBinaryDouble(int, double) method of the > oracle.jdbc.OraclePreparedStatement interface converts the data to the > internal binary bits and sends them to the database." > > As as aside, fortunately, getDouble() avoids the conversion to NUMBER. > > Assuming you can reproduce this (just try a write a large number like > 1e200 into a BINARY_DOUBLE column), do you know how I can get a C double > variable accurately into an Oracle database BINARY_DOUBLE column using > OCILIB? I suppose this would be of interest to anyone using BINARY_DOUBLE > and BINARY_FLOAT with OCILIB. I do a lot of engineering/scientific work > where precision and accuracy are critical. > > The only way I can think of is to convert the number to a string, and > write that to the database, but that is not efficient. Ultimately I need to > avoid conversion errors to NUMBER by preserving all the bits of > BINARY_DOUBLE, along with its full range of values. > > Thanks in advance for any consideration. > > ----- Original Message ----- > From: "vincent rogier" <vin...@ya...> > To: mod...@co... > Cc: orc...@li... > Sent: Sunday, August 26, 2012 1:27:06 PM > Subject: Re: installing latest OCILIB release; does OCILIB convert to > Number when working with BINARY_DOUBLE? > > Hi, > > 1=> it is better to uninstall previous version and make a clean new install > > 2=> when using double C datatype in binding operation, the double host > variable or array is directly passed to oracle. Bu you don't know how the > oracle performs the values assigment. Regarding the documentation it seems > to be a direct assignment. > > Regards > > Vincent > Le 25 août 2012 16:18, < mod...@co... > a écrit : > > > Hello, I have two OCILIB questions. > > 1) I installed OCILIB last year and have been happily using it. Now I see > there is a new release with some features I'd like to use. If I wish to > install the latest release, what is the procedure? That is, do I need to > un-install anything? Or, do I simply follow the original installation > instructions again, as documented in the OCILIB User Guide (and OCILIB with > take care of itself)? > > 2) I don't see mention of BINARY_DOUBLE in the OCILIB User Guide, or > anywhere else. Suppose I have a table in Oracle 11.2 database, with a > column that is BINARY_DOUBLE datatype, and I use a PL/SQL stored procedure > to select data from that column and place it, for example, in a variable > out_data. When I retrieve out_data into the C variable myData using the > following lines, > > double myData=0; > ... > OCI_Prepare(st, "begin get_my_data(:out_data); end;") > OCI_BindDouble(st, ":out_data", &myData); > OCI_Execute(st); > > will OCILIB convert the PL/SQL BINARY_DOUBLE variable out_data to Number > datatype? Or, will OCILIB simply take the BINARY_DOUBLE variable out_data > and map it exactly (via IEEE 754) into the C variable myData which is > double datatype? I'm hoping there is a straight mapping to double so > there's no conversion to Number that introduces conversion errors. If > OCILIB does first convert to Number, is there a workaround? > > I also have this same question for OCI_BindArrayOfDoubles. > > I would think Oracle's Numerical Precedence would prevent conversion to > Number, since it first looks at whether the variables involved are > BINARY_DOUBLE and should therefore not convert to Number since out_data is > BINARY_DOUBLE and myData is double. But I really have no idea what OCILIB > is doing. > > ----------------------------------------------------------- > The following is from Oracle documentation: > > Numeric Precedence Numeric precedence determines, for operations that > support numeric datatypes, the datatype Oracle uses if the arguments to the > operation have different datatypes. BINARY_DOUBLE has the highest numeric > precedence, followed by BINARY_FLOAT, and finally by NUMBER. Therefore, in > any operation on multiple numeric values: > > •If any of the operands is BINARY_DOUBLE, then Oracle attempts to convert > all the operands implicitly to BINARY_DOUBLE before performing the > operation. > > •If none of the operands is BINARY_DOUBLE but any of the operands is > BINARY_FLOAT, then Oracle attempts to convert all the operands implicitly > to BINARY_FLOAT before performing the operation. > > •Otherwise, Oracle attempts to convert all the operands to NUMBER before > performing the operation. > |
From: <mod...@co...> - 2012-08-30 01:24:54
|
Hi Vincent, From experimentation of OCI_BindDouble in writing C double variables into an Oracle 11.2 table BINARY_DOUBLE column, such as, OCI_BindDouble(st, ":in_my_double", &my_double_variable); overflow errors occur when the value of my_double_variable is larger than the allowed value for Oracle NUMBER datatype. Thus, it appears the somewhere in the sequence of events the C variable in double-precision gets converted to Oracle NUMBER datatype, before being converted to BINARY_DOUBLE and stored in the table. This introduces conversion errors into the stored number in the database, and limits the useable range of values (BINARY_DOUBLE and C double-precision range from -1e308 to 1e308, versus NUMBER's -1e87 to 1e127). Per Oracle's documentation for Numerical Precedence (see below), this should not happen if Oracle receives double values. Does OCILIB use something similar to JDBC driver's setDouble()? If so, that would explain it, because Oracle's documentation http://docs.oracle.com/cd/E14072_01/java.112/e10589.pdf on page 4-16 states: "A call to the JDBC standard setDouble(int, double) method of the PreparedStatement interface converts the Java double argument to Oracle NUMBER style bits and send them to the database. In contrast, the setBinaryDouble(int, double) method of the oracle.jdbc.OraclePreparedStatement interface converts the data to the internal binary bits and sends them to the database." As as aside, fortunately, getDouble() avoids the conversion to NUMBER. Assuming you can reproduce this (just try a write a large number like 1e200 into a BINARY_DOUBLE column), do you know how I can get a C double variable accurately into an Oracle database BINARY_DOUBLE column using OCILIB? I suppose this would be of interest to anyone using BINARY_DOUBLE and BINARY_FLOAT with OCILIB. I do a lot of engineering/scientific work where precision and accuracy are critical. The only way I can think of is to convert the number to a string, and write that to the database, but that is not efficient. Ultimately I need to avoid conversion errors to NUMBER by preserving all the bits of BINARY_DOUBLE, along with its full range of values. Thanks in advance for any consideration. ----- Original Message ----- From: "vincent rogier" <vin...@ya...> To: mod...@co... Cc: orc...@li... Sent: Sunday, August 26, 2012 1:27:06 PM Subject: Re: installing latest OCILIB release; does OCILIB convert to Number when working with BINARY_DOUBLE? Hi, 1=> it is better to uninstall previous version and make a clean new install 2=> when using double C datatype in binding operation, the double host variable or array is directly passed to oracle. Bu you don't know how the oracle performs the values assigment. Regarding the documentation it seems to be a direct assignment. Regards Vincent Le 25 août 2012 16:18, < mod...@co... > a écrit : Hello, I have two OCILIB questions. 1) I installed OCILIB last year and have been happily using it. Now I see there is a new release with some features I'd like to use. If I wish to install the latest release, what is the procedure? That is, do I need to un-install anything? Or, do I simply follow the original installation instructions again, as documented in the OCILIB User Guide (and OCILIB with take care of itself)? 2) I don't see mention of BINARY_DOUBLE in the OCILIB User Guide, or anywhere else. Suppose I have a table in Oracle 11.2 database, with a column that is BINARY_DOUBLE datatype, and I use a PL/SQL stored procedure to select data from that column and place it, for example, in a variable out_data. When I retrieve out_data into the C variable myData using the following lines, double myData=0; ... OCI_Prepare(st, "begin get_my_data(:out_data); end;") OCI_BindDouble(st, ":out_data", &myData); OCI_Execute(st); will OCILIB convert the PL/SQL BINARY_DOUBLE variable out_data to Number datatype? Or, will OCILIB simply take the BINARY_DOUBLE variable out_data and map it exactly (via IEEE 754) into the C variable myData which is double datatype? I'm hoping there is a straight mapping to double so there's no conversion to Number that introduces conversion errors. If OCILIB does first convert to Number, is there a workaround? I also have this same question for OCI_BindArrayOfDoubles. I would think Oracle's Numerical Precedence would prevent conversion to Number, since it first looks at whether the variables involved are BINARY_DOUBLE and should therefore not convert to Number since out_data is BINARY_DOUBLE and myData is double. But I really have no idea what OCILIB is doing. ----------------------------------------------------------- The following is from Oracle documentation: Numeric Precedence Numeric precedence determines, for operations that support numeric datatypes, the datatype Oracle uses if the arguments to the operation have different datatypes. BINARY_DOUBLE has the highest numeric precedence, followed by BINARY_FLOAT, and finally by NUMBER. Therefore, in any operation on multiple numeric values: •If any of the operands is BINARY_DOUBLE, then Oracle attempts to convert all the operands implicitly to BINARY_DOUBLE before performing the operation. •If none of the operands is BINARY_DOUBLE but any of the operands is BINARY_FLOAT, then Oracle attempts to convert all the operands implicitly to BINARY_FLOAT before performing the operation. •Otherwise, Oracle attempts to convert all the operands to NUMBER before performing the operation. |
From: <mod...@co...> - 2012-08-26 20:44:42
|
Thanks so much, Regarding question 1, I'm not much of a Linux expert. If I installed using: # ./configure --with-oracle-headers-path=/usr/include/oracle/11.2/client64 --with-oracle-lib-path=/usr/lib/oracle/11.2/client64/lib # make # su root # make install what would be the procedure to uninstall? Regarding question 2, I suppose I can always simply see if I can write a large number like 1e+200 (which exceeds the limit of Number) to a table and if it succeeds then we know there was no conversion to Number during this process. Thanks! ----- Original Message ----- From: "vincent rogier" <vin...@ya...> To: mod...@co... Cc: orc...@li... Sent: Sunday, August 26, 2012 1:27:06 PM Subject: Re: installing latest OCILIB release; does OCILIB convert to Number when working with BINARY_DOUBLE? Hi, 1=> it is better to uninstall previous version and make a clean new install 2=> when using double C datatype in binding operation, the double host variable or array is directly passed to oracle. Bu you don't know how the oracle performs the values assigment. Regarding the documentation it seems to be a direct assignment. Regards Vincent Le 25 août 2012 16:18, < mod...@co... > a écrit : Hello, I have two OCILIB questions. 1) I installed OCILIB last year and have been happily using it. Now I see there is a new release with some features I'd like to use. If I wish to install the latest release, what is the procedure? That is, do I need to un-install anything? Or, do I simply follow the original installation instructions again, as documented in the OCILIB User Guide (and OCILIB with take care of itself)? 2) I don't see mention of BINARY_DOUBLE in the OCILIB User Guide, or anywhere else. Suppose I have a table in Oracle 11.2 database, with a column that is BINARY_DOUBLE datatype, and I use a PL/SQL stored procedure to select data from that column and place it, for example, in a variable out_data. When I retrieve out_data into the C variable myData using the following lines, double myData=0; ... OCI_Prepare(st, "begin get_my_data(:out_data); end;") OCI_BindDouble(st, ":out_data", &myData); OCI_Execute(st); will OCILIB convert the PL/SQL BINARY_DOUBLE variable out_data to Number datatype? Or, will OCILIB simply take the BINARY_DOUBLE variable out_data and map it exactly (via IEEE 754) into the C variable myData which is double datatype? I'm hoping there is a straight mapping to double so there's no conversion to Number that introduces conversion errors. If OCILIB does first convert to Number, is there a workaround? I also have this same question for OCI_BindArrayOfDoubles. I would think Oracle's Numerical Precedence would prevent conversion to Number, since it first looks at whether the variables involved are BINARY_DOUBLE and should therefore not convert to Number since out_data is BINARY_DOUBLE and myData is double. But I really have no idea what OCILIB is doing. ----------------------------------------------------------- The following is from Oracle documentation: Numeric Precedence Numeric precedence determines, for operations that support numeric datatypes, the datatype Oracle uses if the arguments to the operation have different datatypes. BINARY_DOUBLE has the highest numeric precedence, followed by BINARY_FLOAT, and finally by NUMBER. Therefore, in any operation on multiple numeric values: •If any of the operands is BINARY_DOUBLE, then Oracle attempts to convert all the operands implicitly to BINARY_DOUBLE before performing the operation. •If none of the operands is BINARY_DOUBLE but any of the operands is BINARY_FLOAT, then Oracle attempts to convert all the operands implicitly to BINARY_FLOAT before performing the operation. •Otherwise, Oracle attempts to convert all the operands to NUMBER before performing the operation. |
From: vincent r. <vin...@ya...> - 2012-08-26 20:27:13
|
Hi, 1=> it is better to uninstall previous version and make a clean new install 2=> when using double C datatype in binding operation, the double host variable or array is directly passed to oracle. Bu you don't know how the oracle performs the values assigment. Regarding the documentation it seems to be a direct assignment. Regards Vincent Le 25 août 2012 16:18, <mod...@co...> a écrit : > Hello, I have two OCILIB questions. > > 1) I installed OCILIB last year and have been happily using it. Now I see > there is a new release with some features I'd like to use. If I wish to > install the latest release, what is the procedure? That is, do I need to > un-install anything? Or, do I simply follow the original installation > instructions again, as documented in the OCILIB User Guide (and OCILIB with > take care of itself)? > > 2) I don't see mention of BINARY_DOUBLE in the OCILIB User Guide, or > anywhere else. Suppose I have a table in Oracle 11.2 database, with a > column that is BINARY_DOUBLE datatype, and I use a PL/SQL stored procedure > to select data from that column and place it, for example, in a variable > out_data. When I retrieve out_data into the C variable myData using the > following lines, > > double myData=0; > ... > OCI_Prepare(st, "begin get_my_data(:out_data); end;") > OCI_BindDouble(st, ":out_data", &myData); > OCI_Execute(st); > > will OCILIB convert the PL/SQL BINARY_DOUBLE variable out_data to Number > datatype? Or, will OCILIB simply take the BINARY_DOUBLE variable out_data > and map it exactly (via IEEE 754) into the C variable myData which is > double datatype? I'm hoping there is a straight mapping to double so > there's no conversion to Number that introduces conversion errors. If > OCILIB does first convert to Number, is there a workaround? > > I also have this same question for OCI_BindArrayOfDoubles. > > I would think Oracle's Numerical Precedence would prevent conversion to > Number, since it first looks at whether the variables involved are > BINARY_DOUBLE and should therefore not convert to Number since out_data is > BINARY_DOUBLE and myData is double. But I really have no idea what OCILIB > is doing. > > ----------------------------------------------------------- > The following is from Oracle documentation: > > Numeric Precedence Numeric precedence determines, for operations that > support numeric datatypes, the datatype Oracle uses if the arguments to the > operation have different datatypes. BINARY_DOUBLE has the highest numeric > precedence, followed by BINARY_FLOAT, and finally by NUMBER. Therefore, in > any operation on multiple numeric values: > > •If any of the operands is BINARY_DOUBLE, then Oracle attempts to convert > all the operands implicitly to BINARY_DOUBLE before performing the > operation. > > •If none of the operands is BINARY_DOUBLE but any of the operands is > BINARY_FLOAT, then Oracle attempts to convert all the operands implicitly > to BINARY_FLOAT before performing the operation. > > •Otherwise, Oracle attempts to convert all the operands to NUMBER before > performing the operation. > |
From: <mod...@co...> - 2012-08-25 14:19:05
|
Hello, I have two OCILIB questions. 1) I installed OCILIB last year and have been happily using it. Now I see there is a new release with some features I'd like to use. If I wish to install the latest release, what is the procedure? That is, do I need to un-install anything? Or, do I simply follow the original installation instructions again, as documented in the OCILIB User Guide (and OCILIB with take care of itself)? 2) I don't see mention of BINARY_DOUBLE in the OCILIB User Guide, or anywhere else. Suppose I have a table in Oracle 11.2 database, with a column that is BINARY_DOUBLE datatype, and I use a PL/SQL stored procedure to select data from that column and place it, for example, in a variable out_data. When I retrieve out_data into the C variable myData using the following lines, double myData=0; ... OCI_Prepare(st, "begin get_my_data(:out_data); end;") OCI_BindDouble(st, ":out_data", &myData); OCI_Execute(st); will OCILIB convert the PL/SQL BINARY_DOUBLE variable out_data to Number datatype? Or, will OCILIB simply take the BINARY_DOUBLE variable out_data and map it exactly (via IEEE 754) into the C variable myData which is double datatype? I'm hoping there is a straight mapping to double so there's no conversion to Number that introduces conversion errors. If OCILIB does first convert to Number, is there a workaround? I also have this same question for OCI_BindArrayOfDoubles. I would think Oracle's Numerical Precedence would prevent conversion to Number, since it first looks at whether the variables involved are BINARY_DOUBLE and should therefore not convert to Number since out_data is BINARY_DOUBLE and myData is double. But I really have no idea what OCILIB is doing. ----------------------------------------------------------- The following is from Oracle documentation: Numeric Precedence Numeric precedence determines, for operations that support numeric datatypes, the datatype Oracle uses if the arguments to the operation have different datatypes. BINARY_DOUBLE has the highest numeric precedence, followed by BINARY_FLOAT, and finally by NUMBER. Therefore, in any operation on multiple numeric values: •If any of the operands is BINARY_DOUBLE, then Oracle attempts to convert all the operands implicitly to BINARY_DOUBLE before performing the operation. •If none of the operands is BINARY_DOUBLE but any of the operands is BINARY_FLOAT, then Oracle attempts to convert all the operands implicitly to BINARY_FLOAT before performing the operation. •Otherwise, Oracle attempts to convert all the operands to NUMBER before performing the operation. |
From: vincent r. <vin...@ya...> - 2012-06-21 22:55:43
|
Hi, How's going your project ? Vincent On Thu, May 3, 2012 at 11:14 PM, vincent rogier <vin...@ya...>wrote: > Hi Colin, > > You"re welcome :) > > Fell free to contact me for anything related to OCILIB and keep me up to > date with your project ! > > Best regards, > > Vincent > > > > On Wed, May 2, 2012 at 8:25 PM, Colin Doherty <col...@gm...>wrote: > >> Hi, >> >> I'm a Pharo (smalltalk) user. The current solution (DBXTalk) for >> connecting to Oracle in Smalltalk is missing some functionality I need. >> Consequently, I have started to develop a FFI module that wraps your OCILIB >> as your library has the functionality I need. It's nearly there in terms of >> the functionality I need in the short term and I plan to release it to the >> Pharo/Squeak community in case anyone else finds it useful. Just wanted to >> check that you don't have any objections to me doing so ? >> >> Thanks >> Colin >> >> >> ------------------------------------------------------------------------------ >> Live Security Virtual Conference >> Exclusive live event will cover all the ways today's security and >> threat landscape has changed and how IT managers can respond. Discussions >> will include endpoint security, mobile security and the latest in malware >> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >> _______________________________________________ >> Orclib-users mailing list >> Orc...@li... >> https://lists.sourceforge.net/lists/listinfo/orclib-users >> >> > > > -- > Vincent Rogier > -- Vincent Rogier |
From: David N. <da...@qo...> - 2012-06-21 14:02:19
|
Hi Vincent, ok no problem. Since we normally program in C++ (when we're not programming in Qore! :) ), I see ocilib as being a ideal candidate for having a very nice c++ API that could greatly simplify the function calls and additionally be safer to use (regarding resource/memory management with RAII). This could potentially be built on top of any new (or the existing) C API for ocilib (ideally I would also like to export a C API for Qore - it was always my plan - but I never got around to it). I would personally love to see an updated version of ocilib that supports multiple environment handles; it would make it much easier to track further development of ocilib. Basically we have taken ocilib and modified every single function to accept an "OCI_Library* pOCILib" argument as the first arg and removed the global variable of this name entirely. Supporting multiple environment handles I would think would be a must for any more complex use case (or generalized export of your API to a programming language, for example like with Qore). Anyway, we need it, and thanks to the power of open source and your great lib, we have it... Whatever you decide; ocilib remains a great library and a huge benefit to the oracle driver in Qore. thanks, David On Jun 21, 2012, at 3:47 PM, vincent rogier wrote: > Hi, > > Thanks for reporting it. This issue has been identified recently and the upcoming 3.9.4 release (not the one on the svn) already has a fix for it :). > > I know that you using a modified version because ocilib does not support multiple environment and charsets... > Many times, i thought about fixing this but it will have to break the backward compatibility with previous versions... > since version 1.0.0, i kept backward compatibility as a major goal. And i still have to deal with early design errors .... > I was thinking to create a 4.x branch with some changes in the design and keep on supporting 3.x.... > But is worth it ? i don't know... > > Best regards, > > Vincent > > > On Thu, Jun 14, 2012 at 10:48 AM, David Nichols <da...@qo...> wrote: > Hi there, > > I've found what appears to me to be a bug in ocilib - also in svn trunk. > > The problem is in OCI_TypeInfoGet() - if the function fails to get a description for an object, the function returns NULL, however a list entry in con->tinfs is left there anyway - it happens like this (the line numbers below correspond to ocilib in svn trunk as of the time this email was written): > > typeinfo.c:185: the list entry for the OCI_TypeInfo object is created: > item = OCI_ListAppend(pOCILib, con->tinfs, sizeof(OCI_TypeInfo)); > > typeinfo.c:417: checks to see if a description was retrieved; if not, the return value is set to NULL, however the list entry is not removed > if (res == FALSE) > { > OCI_TypeInfoFree2(pOCILib, typinf); > typinf = NULL; > } > > typeinfo.c:160: if OCI_TypeInfoGet() is called again, then the list entry with the invalid description is found and a non-NULL return value is returned: > item = con->tinfs->head; > > /* walk along the list to find the type */ > > while (item != NULL) > { > typinf = (OCI_TypeInfo *) item->data; > > if ((typinf != NULL) && (typinf->type == type)) > { > if ((mtscasecmp(typinf->name, obj_name ) == 0) && > (mtscasecmp(typinf->schema, obj_schema) == 0)) > { > found = TRUE; > break; > } > } > > item = item->next; > } > > > my fix was to change the logic @ typeinfo:417 to remove the value from the list if the calls to get the object description failed and NULL is returned: > if (res == FALSE) > { > OCI_TypeInfoFree2(pOCILib, typinf); > /* delete item from item list */ > if (found == FALSE) > OCI_ListRemove(pOCILib, con->tinfs, item->data); > typinf = NULL; > } > > This scenario may not be important to some people - but it is in the way we use ocilib (as a helper library for the Oracle driver for Qore - qore.org) > > unfortunately we cannot easily track ocilib trunk because we had to heavily modify ocilib to support multiple environment handles, however we try to sync upstream fixes, and will always try to feed back any issues we find to the upstream project. > > thanks for making such a great library! > > thanks, > David > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Orclib-users mailing list > Orc...@li... > https://lists.sourceforge.net/lists/listinfo/orclib-users > > > > -- > Vincent Rogier |
From: vincent r. <vin...@ya...> - 2012-06-21 13:48:23
|
Hi, Thanks for reporting it. This issue has been identified recently and the upcoming 3.9.4 release (not the one on the svn) already has a fix for it :). I know that you using a modified version because ocilib does not support multiple environment and charsets... Many times, i thought about fixing this but it will have to break the backward compatibility with previous versions... since version 1.0.0, i kept backward compatibility as a major goal. And i still have to deal with early design errors .... I was thinking to create a 4.x branch with some changes in the design and keep on supporting 3.x.... But is worth it ? i don't know... Best regards, Vincent On Thu, Jun 14, 2012 at 10:48 AM, David Nichols <da...@qo...> wrote: > Hi there, > > I've found what appears to me to be a bug in ocilib - also in svn trunk. > > The problem is in OCI_TypeInfoGet() - if the function fails to get a > description for an object, the function returns NULL, however a list entry > in con->tinfs is left there anyway - it happens like this (the line numbers > below correspond to ocilib in svn trunk as of the time this email was > written): > > typeinfo.c:185: the list entry for the OCI_TypeInfo object is created: > item = OCI_ListAppend(pOCILib, con->tinfs, sizeof(OCI_TypeInfo)); > > typeinfo.c:417: checks to see if a description was retrieved; if not, the > return value is set to NULL, however the list entry is not removed > if (res == FALSE) > { > OCI_TypeInfoFree2(pOCILib, typinf); > typinf = NULL; > } > > typeinfo.c:160: if OCI_TypeInfoGet() is called again, then the list entry > with the invalid description is found and a non-NULL return value is > returned: > item = con->tinfs->head; > > /* walk along the list to find the type */ > > while (item != NULL) > { > typinf = (OCI_TypeInfo *) item->data; > > if ((typinf != NULL) && (typinf->type == type)) > { > if ((mtscasecmp(typinf->name, obj_name ) == 0) && > (mtscasecmp(typinf->schema, obj_schema) == 0)) > { > found = TRUE; > break; > } > } > > item = item->next; > } > > > my fix was to change the logic @ typeinfo:417 to remove the value from the > list if the calls to get the object description failed and NULL is returned: > if (res == FALSE) > { > OCI_TypeInfoFree2(pOCILib, typinf); > /* delete item from item list */ > if (found == FALSE) > OCI_ListRemove(pOCILib, con->tinfs, item->data); > typinf = NULL; > } > > This scenario may not be important to some people - but it is in the way > we use ocilib (as a helper library for the Oracle driver for Qore - > qore.org) > > unfortunately we cannot easily track ocilib trunk because we had to > heavily modify ocilib to support multiple environment handles, however we > try to sync upstream fixes, and will always try to feed back any issues we > find to the upstream project. > > thanks for making such a great library! > > thanks, > David > > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Orclib-users mailing list > Orc...@li... > https://lists.sourceforge.net/lists/listinfo/orclib-users > -- Vincent Rogier |