orclib-users Mailing List for OCILIB - C and C++ Driver for Oracle
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: vincent r. <vin...@gm...> - 2016-02-24 10:18:38
|
Hi, You should be able to configure it via the SQLNET.ORA file (check Oracle documentation about the right parameter) Best regards, Vincent On Wed, Feb 24, 2016 at 9:10 AM, Peter Olah <p.n...@gm...> wrote: > Hi, > > are there any way to set shorter timeout for ORA connections and > operations? > For example i often get 'ORA-12545: Connect failed because target host or > object does not exist' error 60 secs after the trying to connect. > > Thanks in advance, > Peter > > > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > _______________________________________________ > Orclib-users mailing list > Orc...@li... > https://lists.sourceforge.net/lists/listinfo/orclib-users > > -- Vincent Rogier |
From: Peter O. <p.n...@gm...> - 2016-02-24 08:10:32
|
Hi, are there any way to set shorter timeout for ORA connections and operations? For example i often get 'ORA-12545: Connect failed because target host or object does not exist' error 60 secs after the trying to connect. Thanks in advance, Peter |
From: André D. <and...@wa...> - 2016-01-25 23:45:29
|
Hi, I am able to use ona Windows 32 bit the ocilib library with MYSYS2 mingw32 with the Windows distribution of ocilib 32 bits. When I compile exactly the same program on MYSYS2 64 bits, I get the follwoing error at link phase even if I point on ocilib 64 bits. C:/ocilib/lib64/ociliba.lib(ociliba.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_OCI_ConnectionFree' defined in .idata$5 section in C:/ocilib/lib64/ociliba.lib(ociliba.dll.b) C:/ocilib/lib64/ociliba.lib(ociliba.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_OCI_ConnectionCreate' defined in .idata$5 section in C:/ocilib/lib64/ociliba.lib(ociliba.dll.b) C:/ocilib/lib64/ociliba.lib(ociliba.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_OCI_ErrorGetStatement' defined in .idata$5 section in C:/ocilib/lib64/ociliba.lib(ociliba.dll.b) C:/ocilib/lib64/ociliba.lib(ociliba.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_OCI_ErrorGetOCICode' defined in .idata$5 section in C:/ocilib/lib64/ociliba.lib(ociliba.dll.b) C:/ocilib/lib64/ociliba.lib(ociliba.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_OCI_ErrorGetString' defined in .idata$5 section in C:/ocilib/lib64/ociliba.lib(ociliba.dll.b) Makefile:36: recipe for target 'ExtractEgipte.exe' failed C:/ocilib/lib64/ociliba.lib(ociliba.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_OCI_Cleanup' defined in .idata$5 section in C:/ocilib/lib64/ociliba.lib(ociliba.dll.b) C:/ocilib/lib64/ociliba.lib(ociliba.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_OCI_Initialize' defined in .idata$5 section in C:/ocilib/lib64/ociliba.lib(ociliba.dll.b) C:/ocilib/lib64/ociliba.lib(ociliba.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_OCI_GetFloat2' defined in .idata$5 section in C:/ocilib/lib64/ociliba.lib(ociliba.dll.b) C:/ocilib/lib64/ociliba.lib(ociliba.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_OCI_GetString2' defined in .idata$5 section in C:/ocilib/lib64/ociliba.lib(ociliba.dll.b) C:/ocilib/lib64/ociliba.lib(ociliba.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_OCI_FetchNext' defined in .idata$5 section in C:/ocilib/lib64/ociliba.lib(ociliba.dll.b) C:/ocilib/lib64/ociliba.lib(ociliba.dll.b):(.text+0x2): additional relocation java-scripts omitted from the output Compiler option: CC=gcc CFLAGS = -g -m64 -std=c99 -I. CFLAGS += `pkg-config --cflags libxml-2.0` CFLAGS += `pkg-config --cflags gtk+-3.0` CFLAGS += -IC:/ocilib/include LD=gcc LDFLAGS = -g -m64 LDFLAGS += `pkg-config --libs libxml-2.0` LDFLAGS += `pkg-config --libs gtk+-3.0` LDFLAGS += -LC:/ocilib/lib64 LDFLAGS += -lociliba LDFLAGS += -lmysqlclient I am working on Windows 7 64 bits I have Oracle Client 64 bit installed Could help me to generate my 64 bit version of my program. Regards André |
From: Peter O. <p.n...@gm...> - 2015-12-07 11:36:34
|
Hello, I've been trying to send and receive BLOB typed parameter to/from a stored procedure, but i constantly receive 'ORA-24801: illegal parameter value in OCI lob function' exception. For the input part, i use the Blob class this way: Blob blob(con); blob.Write(data_to_send); blob.Seek(ocilib:SeekSet, 0); // i've just tried everything :) stmt.Bind(":P_NAME", blob, BindInfo::In); Code for the output param: Blob oBlob(con); stmt.Bind(":PO_NAME", oBlob, BindInfo::Out); Then i execute the prepared statement as usual. Clearly i'm using something in an improper manner... Thanks in advance, Peter |
From: Johannsmeier, D. (K-SIPV-4/6) <die...@vo...> - 2015-11-30 15:33:29
|
Hi, I have made a test with a format string “9999999.99“ and test it with a sql statement which contains a to_number call. But if I insert this format into my test program the results are the same. (NULL values) Thank you Dieter Von: vincent rogier [mailto:vin...@gm...] Gesendet: Freitag, 27. November 2015 08:41 An: Johannsmeier, Dieter (K-SIPV-4/6) Cc: orc...@li... Betreff: Re: [Orclib-users] Direct Path with NUMBER (10,2) Hi, Sorry for the late response. There is an issue with the numeric format you passed to oci_dirpathsetcolumn(). It must be an oracle format (see reference of the sql to_number() function). More generally, always use an error handler that will always be triggered in case of oracle or internal error. Best regards, Vincent Le 20 nov. 2015 11:12, "Johannsmeier, Dieter (K-SIPV-4/6)" <die...@vo...<mailto:die...@vo...>> a écrit : > > Hello everybody, > > I am new to OCILIB (4.2.0 on Linux) and I try to extend and run the example ocilib_demo.c > I want to test a NUMBER(10,2) column. > So I extend the test table and add some code to the test program: > > OCI_DirPathSetColumn(dp,1,"VAL_INT", SIZE_COL1,NULL); > OCI_DirPathSetColumn(dp,2,"VAL_STR", SIZE_COL2,NULL); > OCI_DirPathSetColumn(dp,3,"VAL_DATE", SIZE_COL3,"YYYYMMDD"); > OCI_DirPathSetColumn(dp,4,"VAL_FLOAT", SIZE_COL4,NUMFORM); <- new e.g. #define NUMFORM "%f" > > And: > > sprintf(val1, "%4d",i + (i*100)); > sprintf(val2, "value %05d",j + (i*100)); > sprintf(val3, "%04d%02d%02d",(j%23)+1+2000, (j%11)+1, (j%23)+1); > sprintf(val4, "%4.2f",1.01); <-new > > OCI_DirPathSetEntry(dp,j,1,val1,(unsigned int) strlen(val1),TRUE); > OCI_DirPathSetEntry(dp,j,2,val2,(unsigned int) strlen(val2),TRUE); > OCI_DirPathSetEntry(dp,j,3,val3,(unsigned int) strlen(val3),TRUE); > OCI_DirPathSetEntry(dp,j,4,val4,(unsigned int) strlen(val4),TRUE); <- new > > > I try a lot of different things but the column in the database is always NULL. With the help of a debugger I see that > the function OCI_NumberToString doesn’t return something in its output (out_value, out_value_size) > > What’s wrong? > > Thank you in advance > > > Dieter Johannsmeier > > > > > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Orclib-users mailing list > Orc...@li...<mailto:Orc...@li...> > https://lists.sourceforge.net/lists/listinfo/orclib-users > |
From: vincent r. <vin...@gm...> - 2015-11-27 07:40:42
|
Hi, Sorry for the late response. There is an issue with the numeric format you passed to oci_dirpathsetcolumn(). It must be an oracle format (see reference of the sql to_number() function). More generally, always use an error handler that will always be triggered in case of oracle or internal error. Best regards, Vincent Le 20 nov. 2015 11:12, "Johannsmeier, Dieter (K-SIPV-4/6)" < die...@vo...> a écrit : > > Hello everybody, > > I am new to OCILIB (4.2.0 on Linux) and I try to extend and run the example ocilib_demo.c > I want to test a NUMBER(10,2) column. > So I extend the test table and add some code to the test program: > > OCI_DirPathSetColumn(dp,1,"VAL_INT", SIZE_COL1,NULL); > OCI_DirPathSetColumn(dp,2,"VAL_STR", SIZE_COL2,NULL); > OCI_DirPathSetColumn(dp,3,"VAL_DATE", SIZE_COL3,"YYYYMMDD"); > OCI_DirPathSetColumn(dp,4,"VAL_FLOAT", SIZE_COL4,NUMFORM); <- new e.g. #define NUMFORM "%f" > > And: > > sprintf(val1, "%4d",i + (i*100)); > sprintf(val2, "value %05d",j + (i*100)); > sprintf(val3, "%04d%02d%02d",(j%23)+1+2000, (j%11)+1, (j%23)+1); > sprintf(val4, "%4.2f",1.01); <-new > > OCI_DirPathSetEntry(dp,j,1,val1,(unsigned int) strlen(val1),TRUE); > OCI_DirPathSetEntry(dp,j,2,val2,(unsigned int) strlen(val2),TRUE); > OCI_DirPathSetEntry(dp,j,3,val3,(unsigned int) strlen(val3),TRUE); > OCI_DirPathSetEntry(dp,j,4,val4,(unsigned int) strlen(val4),TRUE); <- new > > > I try a lot of different things but the column in the database is always NULL. With the help of a debugger I see that > the function OCI_NumberToString doesn’t return something in its output (out_value, out_value_size) > > What’s wrong? > > Thank you in advance > > > Dieter Johannsmeier > > > > > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Orclib-users mailing list > Orc...@li... > https://lists.sourceforge.net/lists/listinfo/orclib-users > |
From: Johannsmeier, D. (K-SIPV-4/6) <die...@vo...> - 2015-11-24 14:49:37
|
Hi, yes, I pass 4 columns instead of 3. I append the source file to this mail: #define NUM_COLS 4 dp = OCI_DirPathCreate(tbl,NULL,NUM_COLS,nb_rows); Thank you and best regards Dieter Johannsmeier Von: vincent rogier [mailto:vin...@gm...] Gesendet: Sonntag, 22. November 2015 20:10 An: Johannsmeier, Dieter (K-SIPV-4/6) Cc: orc...@li...<mailto:orc...@li...> Betreff: Re: [Orclib-users] Direct Path with NUMBER (10,2) Hi, Did you pass the right number of columns to OCI_DirPathCreate() ? BTW, OCILIB has moved to GitHub ! Can you use GitHub resources for support (https://github.com/vrogier/ocilib) ? Best regards, Vincent On Fri, Nov 20, 2015 at 11:12 AM, Johannsmeier, Dieter (K-SIPV-4/6) <die...@vo...<mailto:die...@vo...>> wrote: Hello everybody, I am new to OCILIB (4.2.0 on Linux) and I try to extend and run the example ocilib_demo.c I want to test a NUMBER(10,2) column. So I extend the test table and add some code to the test program: OCI_DirPathSetColumn(dp,1,"VAL_INT", SIZE_COL1,NULL); OCI_DirPathSetColumn(dp,2,"VAL_STR", SIZE_COL2,NULL); OCI_DirPathSetColumn(dp,3,"VAL_DATE", SIZE_COL3,"YYYYMMDD"); OCI_DirPathSetColumn(dp,4,"VAL_FLOAT", SIZE_COL4,NUMFORM); <- new e.g. #define NUMFORM "%f" And: sprintf(val1, "%4d",i + (i*100)); sprintf(val2, "value %05d",j + (i*100)); sprintf(val3, "%04d%02d%02d",(j%23)+1+2000, (j%11)+1, (j%23)+1); sprintf(val4, "%4.2f",1.01); <-new OCI_DirPathSetEntry(dp,j,1,val1,(unsigned int) strlen(val1),TRUE); OCI_DirPathSetEntry(dp,j,2,val2,(unsigned int) strlen(val2),TRUE); OCI_DirPathSetEntry(dp,j,3,val3,(unsigned int) strlen(val3),TRUE); OCI_DirPathSetEntry(dp,j,4,val4,(unsigned int) strlen(val4),TRUE); <- new I try a lot of different things but the column in the database is always NULL. With the help of a debugger I see that the function OCI_NumberToString doesn’t return something in its output (out_value, out_value_size) What’s wrong? Thank you in advance Dieter Johannsmeier ------------------------------------------------------------------------------ _______________________________________________ Orclib-users mailing list Orc...@li...<mailto:Orc...@li...> https://lists.sourceforge.net/lists/listinfo/orclib-users -- Vincent Rogier |
From: vincent r. <vin...@gm...> - 2015-11-22 19:10:27
|
Hi, Did you pass the right number of columns to OCI_DirPathCreate() ? BTW, OCILIB has moved to GitHub ! Can you use GitHub resources for support (https://github.com/vrogier/ocilib) ? Best regards, Vincent On Fri, Nov 20, 2015 at 11:12 AM, Johannsmeier, Dieter (K-SIPV-4/6) < die...@vo...> wrote: > Hello everybody, > > I am new to OCILIB (4.2.0 on Linux) and I try to extend and run the > example ocilib_demo.c > I want to test a NUMBER(10,2) column. > So I extend the test table and add some code to the test program: > > OCI_DirPathSetColumn(dp,1,"VAL_INT", SIZE_COL1,NULL); > OCI_DirPathSetColumn(dp,2,"VAL_STR", SIZE_COL2,NULL); > OCI_DirPathSetColumn(dp,3,"VAL_DATE", SIZE_COL3,"YYYYMMDD"); > OCI_DirPathSetColumn(dp,4,"VAL_FLOAT", SIZE_COL4,NUMFORM); <- > new e.g. #define NUMFORM "%f" > > And: > > sprintf(val1, "%4d",i + (i*100)); > sprintf(val2, "value %05d",j + (i*100)); > sprintf(val3, "%04d%02d%02d",(j%23)+1+2000, > (j%11)+1, (j%23)+1); > sprintf(val4, > "%4.2f",1.01); <-new > > OCI_DirPathSetEntry(dp,j,1,val1,(unsigned int) > strlen(val1),TRUE); > OCI_DirPathSetEntry(dp,j,2,val2,(unsigned int) > strlen(val2),TRUE); > OCI_DirPathSetEntry(dp,j,3,val3,(unsigned int) > strlen(val3),TRUE); > OCI_DirPathSetEntry(dp,j,4,val4,(unsigned int) > strlen(val4),TRUE); <- new > > > I try a lot of different things but the column in the database is always > NULL. With the help of a debugger I see that > the function OCI_NumberToString doesn’t return something in its output > (out_value, out_value_size) > > What’s wrong? > > Thank you in advance > > > Dieter Johannsmeier > > > > > > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Orclib-users mailing list > Orc...@li... > https://lists.sourceforge.net/lists/listinfo/orclib-users > > -- Vincent Rogier |
From: Johannsmeier, D. (K-SIPV-4/6) <die...@vo...> - 2015-11-20 10:34:00
|
Hello everybody, I am new to OCILIB (4.2.0 on Linux) and I try to extend and run the example ocilib_demo.c I want to test a NUMBER(10,2) column. So I extend the test table and add some code to the test program: OCI_DirPathSetColumn(dp,1,"VAL_INT", SIZE_COL1,NULL); OCI_DirPathSetColumn(dp,2,"VAL_STR", SIZE_COL2,NULL); OCI_DirPathSetColumn(dp,3,"VAL_DATE", SIZE_COL3,"YYYYMMDD"); OCI_DirPathSetColumn(dp,4,"VAL_FLOAT", SIZE_COL4,NUMFORM); <- new e.g. #define NUMFORM "%f" And: sprintf(val1, "%4d",i + (i*100)); sprintf(val2, "value %05d",j + (i*100)); sprintf(val3, "%04d%02d%02d",(j%23)+1+2000, (j%11)+1, (j%23)+1); sprintf(val4, "%4.2f",1.01); <-new OCI_DirPathSetEntry(dp,j,1,val1,(unsigned int) strlen(val1),TRUE); OCI_DirPathSetEntry(dp,j,2,val2,(unsigned int) strlen(val2),TRUE); OCI_DirPathSetEntry(dp,j,3,val3,(unsigned int) strlen(val3),TRUE); OCI_DirPathSetEntry(dp,j,4,val4,(unsigned int) strlen(val4),TRUE); <- new I try a lot of different things but the column in the database is always NULL. With the help of a debugger I see that the function OCI_NumberToString doesn't return something in its output (out_value, out_value_size) What's wrong? Thank you in advance Dieter Johannsmeier |
From: vincent r. <vin...@gm...> - 2015-03-04 12:08:18
|
Hi, Both ways are fine. It depends what you want to do with the date ! For string output only, use Get<ostring>, otherwise (arithmetic or manipulation) use Get<Date> In internal OCILIB C API code, dates ate always fetched as date. Basically when retrieved with OCI_GetString() (and Get<ostring>) , the OCI_Date object (Date in C++) is internally converted to a string using OCI_DateToText() (and Date::FromString()) in C++ Thus, Get<Date> will perform better but useless if you only use it for output as you will end up by calling Date::ToString() About making it streamable, it is planned :) In early days of development of the C++ API, i had started to it but finally removed it as it must be done for all types. I had otter priorities at that time. But be sure i will re add it ! You can extend Resultset::Get<> method if you want. the generic class template method are defined and only "official" supported specializations are implemented with the disbribution. But you can add any specialization for any types wherever in your code :) Regards, Vinent On Wed, Mar 4, 2015 at 12:24 PM, Christoph Duelli <du...@me...> wrote: > Am 04.03.2015 11:52, schrieb Christoph Duelli: > > Hello everybody, > > What is the recommended way to select a date using the C++ API? > > > > Statement st("select sysdate from dual"); > > st.Execute(); > > Resultset rs=st.GetResultset(); > > > > ocilib::Date = rs.Get<ocilib::Date>(1); > > > > or should I do something like > > ocilib::ostring = rs.Get<ocilib::ostring>(1); > > > > or something entirely different? > remark: > the idea is to finally "parse" the date into a custom date type: > like > ocilib::Date odate = rs.Get<ocilib::Date>(1); > MDate date(odate.GetYear(), odate.GetMonth(), odate.GetDay()); > and to continue working with that type. > (Or is it possible to extend Resultset::Get for custom types?) > > -- > Christoph Duelli > > > > > > --------------------------------------------------------------------------------- > MELOS-Medizinische Labor-Organisations-Systeme GmbH > Franz-Beer-Straße 6 > 86459 Gessertshausen > Tel.: +49 8238/9611-0 > Fax: +49 8238/9611-99 > mailto: in...@me... > URL: www.melosgmbh.de > > Amtsgericht Augsburg, HRB 13226 > USt-IdNr. DE 130 958 139 > Geschäftsführer: > Herbert Mayer, Andreas Manntz, Helmut Welsch > -------------------------------------------- > This e-mail (including any attachments) is confidential and may be > privileged. If you have received it by mistake, please notify the sender by > e-mail and delete it from your system. > Any unauthorised use or dissemination of this e-mail or its contents in > whole or in part is strictly prohibited. Please note that e-mails are > susceptible to change. > MELOS GmbH shall not be liable for the improper or incomplete transmission > of the information contained in this communication nor for any delay in its > receipt. > MELOS GmbH does not guarantee that the integrity of this communication has > been maintained nor that this communication is free of viruses, > interceptions or interference. > > > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming The Go Parallel Website, > sponsored > by Intel and developed in partnership with Slashdot Media, is your hub for > all > things parallel software development, from weekly thought leadership blogs > to > news, videos, case studies, tutorials and more. Take a look and join the > conversation now. http://goparallel.sourceforge.net/ > _______________________________________________ > Orclib-users mailing list > Orc...@li... > https://lists.sourceforge.net/lists/listinfo/orclib-users > -- Vincent Rogier |
From: Christoph D. <du...@me...> - 2015-03-04 11:24:51
|
Am 04.03.2015 11:52, schrieb Christoph Duelli: > Hello everybody, > What is the recommended way to select a date using the C++ API? > > Statement st("select sysdate from dual"); > st.Execute(); > Resultset rs=st.GetResultset(); > > ocilib::Date = rs.Get<ocilib::Date>(1); > > or should I do something like > ocilib::ostring = rs.Get<ocilib::ostring>(1); > > or something entirely different? remark: the idea is to finally "parse" the date into a custom date type: like ocilib::Date odate = rs.Get<ocilib::Date>(1); MDate date(odate.GetYear(), odate.GetMonth(), odate.GetDay()); and to continue working with that type. (Or is it possible to extend Resultset::Get for custom types?) -- Christoph Duelli --------------------------------------------------------------------------------- MELOS-Medizinische Labor-Organisations-Systeme GmbH Franz-Beer-Straße 6 86459 Gessertshausen Tel.: +49 8238/9611-0 Fax: +49 8238/9611-99 mailto: in...@me... URL: www.melosgmbh.de Amtsgericht Augsburg, HRB 13226 USt-IdNr. DE 130 958 139 Geschäftsführer: Herbert Mayer, Andreas Manntz, Helmut Welsch -------------------------------------------- This e-mail (including any attachments) is confidential and may be privileged. If you have received it by mistake, please notify the sender by e-mail and delete it from your system. Any unauthorised use or dissemination of this e-mail or its contents in whole or in part is strictly prohibited. Please note that e-mails are susceptible to change. MELOS GmbH shall not be liable for the improper or incomplete transmission of the information contained in this communication nor for any delay in its receipt. MELOS GmbH does not guarantee that the integrity of this communication has been maintained nor that this communication is free of viruses, interceptions or interference. |
From: Christoph D. <du...@me...> - 2015-03-04 10:52:32
|
Hello everybody, What is the recommended way to select a date using the C++ API? Statement st("select sysdate from dual"); st.Execute(); Resultset rs=st.GetResultset(); ocilib::Date = rs.Get<ocilib::Date>(1); or should I do something like ocilib::ostring = rs.Get<ocilib::ostring>(1); or something entirely different? Thank you, and, Best regards @Vincent: PS: It would be nice for if Date was output streamable like (could of course be implemented more efficiently) std::ostream& operator<<(std::ostream &out, const Date &rhs) { out << rhs.ToString(); return out; } -- Christoph Duelli --------------------------------------------------------------------------------- MELOS-Medizinische Labor-Organisations-Systeme GmbH Franz-Beer-Straße 6 86459 Gessertshausen Tel.: +49 8238/9611-0 Fax: +49 8238/9611-99 mailto: in...@me... URL: www.melosgmbh.de Amtsgericht Augsburg, HRB 13226 USt-IdNr. DE 130 958 139 Geschäftsführer: Herbert Mayer, Andreas Manntz, Helmut Welsch -------------------------------------------- This e-mail (including any attachments) is confidential and may be privileged. If you have received it by mistake, please notify the sender by e-mail and delete it from your system. Any unauthorised use or dissemination of this e-mail or its contents in whole or in part is strictly prohibited. Please note that e-mails are susceptible to change. MELOS GmbH shall not be liable for the improper or incomplete transmission of the information contained in this communication nor for any delay in its receipt. MELOS GmbH does not guarantee that the integrity of this communication has been maintained nor that this communication is free of viruses, interceptions or interference. |
From: vincent r. <vin...@gm...> - 2015-02-23 14:40:05
|
Hi, Use oci _lobtruncate() Regards, Vincent Le 23 févr. 2015 14:53, "Rafael Culik" <cu...@gm...> a écrit : > Hi > > Ive created an Structure to have an OCI_Lob for insert used on and bind > for insert operation > > how to clean the data of previus inserted data of this lob > > it apear that the lob is appending the data of each previus oci_lobwrite i > use to feed the data before calling OCI_Execute > > so how to clean the lob before setting new data? > > Regards > Luiz > > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > > http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk > _______________________________________________ > Orclib-users mailing list > Orc...@li... > https://lists.sourceforge.net/lists/listinfo/orclib-users > > |
From: Luiz R. C. <lu...@xh...> - 2015-02-23 14:16:17
|
Hi Ive created an Structure to have an OCI_Lob * variable used on and bind for insert operation how to clean the data of previus inserted data of this lob it apear that the lob is appending the data on the end of each previus oci_lobwrite i use to feed the data before calling OCI_Execute so how to clean the lob before setting new data? Regards Luiz 2015-02-23 10:53 GMT-03:00 Rafael Culik <cu...@gm...>: > Hi > > Ive created an Structure to have an OCI_Lob for insert used on and bind > for insert operation > > how to clean the data of previus inserted data of this lob > > it apear that the lob is appending the data of each previus oci_lobwrite i > use to feed the data before calling OCI_Execute > > so how to clean the lob before setting new data? > > Regards > Luiz > |
From: Rafael C. <cu...@gm...> - 2015-02-23 13:53:37
|
Hi Ive created an Structure to have an OCI_Lob for insert used on and bind for insert operation how to clean the data of previus inserted data of this lob it apear that the lob is appending the data of each previus oci_lobwrite i use to feed the data before calling OCI_Execute so how to clean the lob before setting new data? Regards Luiz |
From: Ivan C. <ich...@qu...> - 2015-02-12 07:51:43
|
Thanks, Vincent! So it is obvious I have to invent my own simple escaping function :) Ivan. On Wed, Feb 11, 2015 at 11:42 PM, vincent rogier <vin...@gm...> wrote: > Hi, > > Oracle OCI requires all binds to be arrays when performing bulk inserts > but does not prevent mixing single and array binds. It only complains when > statement is executed by crashing. > OCILIB is built on top of OCI. > I could check any violation of that OCI paradigm. But then I should check > plenty of other ones that may also change depending on oracle version. Thus > it could lead to an important library code complexification. It may also > require runtime overhead checks that require logic dependent on the sql > statement type... > I will check this at least for that paradigm and see if i can prevent any > mix for bulks without performance or code complexification issues. > But keep in mind that what you want to do (mix single bind and array bind > for bulk inserts) is not possible with oracle ! > > Regards, > > Vincent > Le 12 févr. 2015 00:53, "Ivan Chernetsky" <ich...@qu...> a > écrit : > > Hi Vincent, >> >> The fact that library allows to use BindInt and BindArrayOfInts with the >> same prepared statement implies that >> >> 1. Either it will use the same int that was bind to :single for each >> element that comes from :array. >> 2. Or it uses only the first element of :array along with :single value. >> >> To crash is not among good options. So one of those functions either >> should return an error code, or the library should do either 1 or 2. >> >> For instance, it's quite common when where is a need for an insert like >> "INSERT INTO t (n1, n2) VALUES (:single, :array)", and data for :single and >> :array comes from a user, and by using both BindInt and BindArrayOfInts I >> can be sure that SQL injection cannot happen. Theoretically it can be done >> with OCI_PrepareFmt and the like, and it works fine, if it's me who >> provides a value for single variable. If single[] = "va'lue", PrepareFmt >> cannot escape it and just return an error code. >> >> In C, int array[N] = {0} means array is to be initialized with N zeros. >> int array[N] = {1} means array is to be initialized with 1 and (N-1) zeros. >> >> #include <ocilib.h> >> >> #define N 100000 >> >> int main(void) >> { >> OCI_Connection *cn = NULL; OCI_Statement *st = NULL; >> int i = 0, array[N] = {0}; char single[] = "value"; >> const char *host = "db", *user = "user", *password = "pass"; >> >> for (i = 0; i < N; i++) array[i] = i; >> >> if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) return EXIT_FAILURE; >> cn = OCI_ConnectionCreate(host, user, password, OCI_SESSION_DEFAULT); >> if (cn == NULL) return EXIT_FAILURE; >> >> st = OCI_StatementCreate(cn); >> if (st == NULL) return EXIT_FAILURE; >> >> OCI_Prepare(st, "DROP TABLE ns"); >> OCI_Execute(st); >> OCI_Commit(cn); >> >> OCI_Prepare(st, "CREATE TABLE ns (s VARCHAR2(64), n NUMBER)"); >> OCI_Execute(st); >> OCI_Commit(cn); >> >> if (!OCI_PrepareFmt(st, "INSERT INTO ns (s, n) VALUES (%s, :array)", >> single)) >> return EXIT_FAILURE; >> >> if (!OCI_BindArraySetSize(st, N)) return EXIT_FAILURE; >> if (!OCI_BindArrayOfInts(st, ":array", array, N)) return EXIT_FAILURE; >> >> if (!OCI_Execute(st)) return EXIT_FAILURE; >> printf("rows affected: %u\n", OCI_GetAffectedRows(st)); >> >> if (!OCI_Commit(cn)) return EXIT_FAILURE; >> >> OCI_Cleanup(); >> return EXIT_SUCCESS; >> } >> >> On Wed, Feb 11, 2015 at 2:06 PM, vincent rogier <vin...@gm...> >> wrote: >> >>> Hi, >>> >>> When performing bulk insert, all binding host variables must be arrays. >>> you cannot bind an int to n1 and an array to n2. >>> You need to bind array for both n1 and n2. >>> That's the concept of bulk inserts ! >>> >>> Look at your array variable "array". you declare it of size N but you >>> only initialize the first element !!! Other elements have non defined >>> values ! >>> >>> Regards, >>> >>> Vincent >>> >>> On Wed, Feb 11, 2015 at 9:26 PM, Ivan Chernetsky <ich...@qu... >>> > wrote: >>> >>>> Hello everybody, >>>> >>>> With N sufficiently large (on my machine 100000 is large enough), the >>>> below program segfaults. With N sufficiently small (on my machine 1000 is >>>> small enough) trash values get written into ns table. It is not allowed to >>>> use BindInt with BindArrayOfInts with the same statement, by design, is it? >>>> If so, BindInt should return some error code, instead of silently allowing >>>> it. Again, if so, what is the proper way of binding single variables and >>>> arrays? >>>> >>>> #include <ocilib.h> >>>> >>>> #define N 100000 >>>> >>>> int main(void) >>>> { >>>> OCI_Connection *cn = NULL; OCI_Statement *st = NULL; >>>> int single = 0, array[N] = {1}; >>>> const char *host = "db", *user = "user", *password = "pass"; >>>> >>>> if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) >>>> return EXIT_FAILURE; >>>> cn = OCI_ConnectionCreate(host, user, password, >>>> OCI_SESSION_DEFAULT); >>>> if (cn == NULL) >>>> return EXIT_FAILURE; >>>> >>>> st = OCI_StatementCreate(cn); >>>> if (st == NULL) >>>> return EXIT_FAILURE; >>>> >>>> OCI_Prepare(st, "DROP TABLE ns"); >>>> OCI_Execute(st); >>>> OCI_Commit(cn); >>>> >>>> if (!OCI_Prepare(st, "CREATE TABLE ns (n1 NUMBER, n2 NUMBER)")) >>>> return EXIT_FAILURE; >>>> if (!OCI_Execute(st)) >>>> return EXIT_FAILURE; >>>> if (!OCI_Commit(cn)) >>>> return EXIT_FAILURE; >>>> >>>> if (!OCI_Prepare(st, "INSERT INTO ns (n1, n2) VALUES (:single, >>>> :array)")) >>>> return EXIT_FAILURE; >>>> >>>> if (!OCI_BindArraySetSize(st, N)) >>>> return EXIT_FAILURE; >>>> if (!OCI_BindInt(st, ":single", &single)) >>>> return EXIT_FAILURE; >>>> if (!OCI_BindArrayOfInts(st, ":array", array, N)) >>>> return EXIT_FAILURE; >>>> >>>> if (!OCI_Execute(st)) >>>> return EXIT_FAILURE; >>>> printf("rows affected: %u\n", OCI_GetAffectedRows(st)); >>>> >>>> if (!OCI_Commit(cn)) >>>> return EXIT_FAILURE; >>>> >>>> OCI_Cleanup(); >>>> return EXIT_SUCCESS; >>>> } >>>> >>> |
From: vincent r. <vin...@gm...> - 2015-02-12 07:42:18
|
Hi, Oracle OCI requires all binds to be arrays when performing bulk inserts but does not prevent mixing single and array binds. It only complains when statement is executed by crashing. OCILIB is built on top of OCI. I could check any violation of that OCI paradigm. But then I should check plenty of other ones that may also change depending on oracle version. Thus it could lead to an important library code complexification. It may also require runtime overhead checks that require logic dependent on the sql statement type... I will check this at least for that paradigm and see if i can prevent any mix for bulks without performance or code complexification issues. But keep in mind that what you want to do (mix single bind and array bind for bulk inserts) is not possible with oracle ! Regards, Vincent Le 12 févr. 2015 00:53, "Ivan Chernetsky" <ich...@qu...> a écrit : > Hi Vincent, > > The fact that library allows to use BindInt and BindArrayOfInts with the > same prepared statement implies that > > 1. Either it will use the same int that was bind to :single for each > element that comes from :array. > 2. Or it uses only the first element of :array along with :single value. > > To crash is not among good options. So one of those functions either > should return an error code, or the library should do either 1 or 2. > > For instance, it's quite common when where is a need for an insert like > "INSERT INTO t (n1, n2) VALUES (:single, :array)", and data for :single and > :array comes from a user, and by using both BindInt and BindArrayOfInts I > can be sure that SQL injection cannot happen. Theoretically it can be done > with OCI_PrepareFmt and the like, and it works fine, if it's me who > provides a value for single variable. If single[] = "va'lue", PrepareFmt > cannot escape it and just return an error code. > > In C, int array[N] = {0} means array is to be initialized with N zeros. > int array[N] = {1} means array is to be initialized with 1 and (N-1) zeros. > > #include <ocilib.h> > > #define N 100000 > > int main(void) > { > OCI_Connection *cn = NULL; OCI_Statement *st = NULL; > int i = 0, array[N] = {0}; char single[] = "value"; > const char *host = "db", *user = "user", *password = "pass"; > > for (i = 0; i < N; i++) array[i] = i; > > if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) return EXIT_FAILURE; > cn = OCI_ConnectionCreate(host, user, password, OCI_SESSION_DEFAULT); > if (cn == NULL) return EXIT_FAILURE; > > st = OCI_StatementCreate(cn); > if (st == NULL) return EXIT_FAILURE; > > OCI_Prepare(st, "DROP TABLE ns"); > OCI_Execute(st); > OCI_Commit(cn); > > OCI_Prepare(st, "CREATE TABLE ns (s VARCHAR2(64), n NUMBER)"); > OCI_Execute(st); > OCI_Commit(cn); > > if (!OCI_PrepareFmt(st, "INSERT INTO ns (s, n) VALUES (%s, :array)", > single)) > return EXIT_FAILURE; > > if (!OCI_BindArraySetSize(st, N)) return EXIT_FAILURE; > if (!OCI_BindArrayOfInts(st, ":array", array, N)) return EXIT_FAILURE; > > if (!OCI_Execute(st)) return EXIT_FAILURE; > printf("rows affected: %u\n", OCI_GetAffectedRows(st)); > > if (!OCI_Commit(cn)) return EXIT_FAILURE; > > OCI_Cleanup(); > return EXIT_SUCCESS; > } > > On Wed, Feb 11, 2015 at 2:06 PM, vincent rogier <vin...@gm...> > wrote: > >> Hi, >> >> When performing bulk insert, all binding host variables must be arrays. >> you cannot bind an int to n1 and an array to n2. >> You need to bind array for both n1 and n2. >> That's the concept of bulk inserts ! >> >> Look at your array variable "array". you declare it of size N but you >> only initialize the first element !!! Other elements have non defined >> values ! >> >> Regards, >> >> Vincent >> >> On Wed, Feb 11, 2015 at 9:26 PM, Ivan Chernetsky <ich...@qu...> >> wrote: >> >>> Hello everybody, >>> >>> With N sufficiently large (on my machine 100000 is large enough), the >>> below program segfaults. With N sufficiently small (on my machine 1000 is >>> small enough) trash values get written into ns table. It is not allowed to >>> use BindInt with BindArrayOfInts with the same statement, by design, is it? >>> If so, BindInt should return some error code, instead of silently allowing >>> it. Again, if so, what is the proper way of binding single variables and >>> arrays? >>> >>> #include <ocilib.h> >>> >>> #define N 100000 >>> >>> int main(void) >>> { >>> OCI_Connection *cn = NULL; OCI_Statement *st = NULL; >>> int single = 0, array[N] = {1}; >>> const char *host = "db", *user = "user", *password = "pass"; >>> >>> if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) >>> return EXIT_FAILURE; >>> cn = OCI_ConnectionCreate(host, user, password, OCI_SESSION_DEFAULT); >>> if (cn == NULL) >>> return EXIT_FAILURE; >>> >>> st = OCI_StatementCreate(cn); >>> if (st == NULL) >>> return EXIT_FAILURE; >>> >>> OCI_Prepare(st, "DROP TABLE ns"); >>> OCI_Execute(st); >>> OCI_Commit(cn); >>> >>> if (!OCI_Prepare(st, "CREATE TABLE ns (n1 NUMBER, n2 NUMBER)")) >>> return EXIT_FAILURE; >>> if (!OCI_Execute(st)) >>> return EXIT_FAILURE; >>> if (!OCI_Commit(cn)) >>> return EXIT_FAILURE; >>> >>> if (!OCI_Prepare(st, "INSERT INTO ns (n1, n2) VALUES (:single, >>> :array)")) >>> return EXIT_FAILURE; >>> >>> if (!OCI_BindArraySetSize(st, N)) >>> return EXIT_FAILURE; >>> if (!OCI_BindInt(st, ":single", &single)) >>> return EXIT_FAILURE; >>> if (!OCI_BindArrayOfInts(st, ":array", array, N)) >>> return EXIT_FAILURE; >>> >>> if (!OCI_Execute(st)) >>> return EXIT_FAILURE; >>> printf("rows affected: %u\n", OCI_GetAffectedRows(st)); >>> >>> if (!OCI_Commit(cn)) >>> return EXIT_FAILURE; >>> >>> OCI_Cleanup(); >>> return EXIT_SUCCESS; >>> } >>> >> |
From: Ivan C. <ich...@qu...> - 2015-02-11 23:54:08
|
Hi Vincent, The fact that library allows to use BindInt and BindArrayOfInts with the same prepared statement implies that 1. Either it will use the same int that was bind to :single for each element that comes from :array. 2. Or it uses only the first element of :array along with :single value. To crash is not among good options. So one of those functions either should return an error code, or the library should do either 1 or 2. For instance, it's quite common when where is a need for an insert like "INSERT INTO t (n1, n2) VALUES (:single, :array)", and data for :single and :array comes from a user, and by using both BindInt and BindArrayOfInts I can be sure that SQL injection cannot happen. Theoretically it can be done with OCI_PrepareFmt and the like, and it works fine, if it's me who provides a value for single variable. If single[] = "va'lue", PrepareFmt cannot escape it and just return an error code. In C, int array[N] = {0} means array is to be initialized with N zeros. int array[N] = {1} means array is to be initialized with 1 and (N-1) zeros. #include <ocilib.h> #define N 100000 int main(void) { OCI_Connection *cn = NULL; OCI_Statement *st = NULL; int i = 0, array[N] = {0}; char single[] = "value"; const char *host = "db", *user = "user", *password = "pass"; for (i = 0; i < N; i++) array[i] = i; if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) return EXIT_FAILURE; cn = OCI_ConnectionCreate(host, user, password, OCI_SESSION_DEFAULT); if (cn == NULL) return EXIT_FAILURE; st = OCI_StatementCreate(cn); if (st == NULL) return EXIT_FAILURE; OCI_Prepare(st, "DROP TABLE ns"); OCI_Execute(st); OCI_Commit(cn); OCI_Prepare(st, "CREATE TABLE ns (s VARCHAR2(64), n NUMBER)"); OCI_Execute(st); OCI_Commit(cn); if (!OCI_PrepareFmt(st, "INSERT INTO ns (s, n) VALUES (%s, :array)", single)) return EXIT_FAILURE; if (!OCI_BindArraySetSize(st, N)) return EXIT_FAILURE; if (!OCI_BindArrayOfInts(st, ":array", array, N)) return EXIT_FAILURE; if (!OCI_Execute(st)) return EXIT_FAILURE; printf("rows affected: %u\n", OCI_GetAffectedRows(st)); if (!OCI_Commit(cn)) return EXIT_FAILURE; OCI_Cleanup(); return EXIT_SUCCESS; } On Wed, Feb 11, 2015 at 2:06 PM, vincent rogier <vin...@gm...> wrote: > Hi, > > When performing bulk insert, all binding host variables must be arrays. > you cannot bind an int to n1 and an array to n2. > You need to bind array for both n1 and n2. > That's the concept of bulk inserts ! > > Look at your array variable "array". you declare it of size N but you only > initialize the first element !!! Other elements have non defined values ! > > Regards, > > Vincent > > On Wed, Feb 11, 2015 at 9:26 PM, Ivan Chernetsky <ich...@qu...> > wrote: > >> Hello everybody, >> >> With N sufficiently large (on my machine 100000 is large enough), the >> below program segfaults. With N sufficiently small (on my machine 1000 is >> small enough) trash values get written into ns table. It is not allowed to >> use BindInt with BindArrayOfInts with the same statement, by design, is it? >> If so, BindInt should return some error code, instead of silently allowing >> it. Again, if so, what is the proper way of binding single variables and >> arrays? >> >> #include <ocilib.h> >> >> #define N 100000 >> >> int main(void) >> { >> OCI_Connection *cn = NULL; OCI_Statement *st = NULL; >> int single = 0, array[N] = {1}; >> const char *host = "db", *user = "user", *password = "pass"; >> >> if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) >> return EXIT_FAILURE; >> cn = OCI_ConnectionCreate(host, user, password, OCI_SESSION_DEFAULT); >> if (cn == NULL) >> return EXIT_FAILURE; >> >> st = OCI_StatementCreate(cn); >> if (st == NULL) >> return EXIT_FAILURE; >> >> OCI_Prepare(st, "DROP TABLE ns"); >> OCI_Execute(st); >> OCI_Commit(cn); >> >> if (!OCI_Prepare(st, "CREATE TABLE ns (n1 NUMBER, n2 NUMBER)")) >> return EXIT_FAILURE; >> if (!OCI_Execute(st)) >> return EXIT_FAILURE; >> if (!OCI_Commit(cn)) >> return EXIT_FAILURE; >> >> if (!OCI_Prepare(st, "INSERT INTO ns (n1, n2) VALUES (:single, >> :array)")) >> return EXIT_FAILURE; >> >> if (!OCI_BindArraySetSize(st, N)) >> return EXIT_FAILURE; >> if (!OCI_BindInt(st, ":single", &single)) >> return EXIT_FAILURE; >> if (!OCI_BindArrayOfInts(st, ":array", array, N)) >> return EXIT_FAILURE; >> >> if (!OCI_Execute(st)) >> return EXIT_FAILURE; >> printf("rows affected: %u\n", OCI_GetAffectedRows(st)); >> >> if (!OCI_Commit(cn)) >> return EXIT_FAILURE; >> >> OCI_Cleanup(); >> return EXIT_SUCCESS; >> } >> > |
From: Rafael C. <cu...@gm...> - 2015-02-11 22:24:16
|
Hi Vincent 4.0.1 under msvc and gcc(linux) Regards Luiz 2015-02-11 20:20 GMT-02:00 vincent rogier <vin...@gm...>: > Hi, > > What version are you using ? > > Regards, > > Vincent > > On Sat, Jan 24, 2015 at 9:49 PM, Rafael Culik <cu...@gm...> wrote: > >> Hi >> Is possible to reuse the same OCI_Statement variable multiple times? >> >> I have an small program that i prepare an select statement and save it >> prepared handle to an variable . >> when i call the first time, it execute ok, but on second pass >> >> here the call stack >> >> ╔═[■]═Stack═════════════4═[↑][↓]═ >> ║OCI_BatchErrorClear(:03ED46B8) on stament.c line 1432 >> ║OCI_ExecuteInternal(:03ED46B8, 1 >> ║OCI_Execute(:03ED46B8) >> ║getPreparedSeekora(:047BFEE4, 1, >> ║#..\source\sqlex1ora#sqlExOraSee >> >> >> also when i finish I call OCI_StatementFree inside getPreparedSeekOra >> >> so for reuse, i can supress the call to OCI_StatementFree inside >> getPreparedSeekOra? >> >> Regards >> Luiz >> >> >> ------------------------------------------------------------------------------ >> New Year. New Location. New Benefits. New Data Center in Ashburn, VA. >> GigeNET is offering a free month of service with a new server in Ashburn. >> Choose from 2 high performing configs, both with 100TB of bandwidth. >> Higher redundancy.Lower latency.Increased capacity.Completely compliant. >> http://p.sf.net/sfu/gigenet >> _______________________________________________ >> Orclib-users mailing list >> Orc...@li... >> https://lists.sourceforge.net/lists/listinfo/orclib-users >> >> > > > -- > Vincent Rogier > |
From: vincent r. <vin...@gm...> - 2015-02-11 22:06:50
|
Hi, When performing bulk insert, all binding host variables must be arrays. you cannot bind an int to n1 and an array to n2. You need to bind array for both n1 and n2. That's the concept of bulk inserts ! Look at your array variable "array". you declare it of size N but you only initialize the first element !!! Other elements have non defined values ! Regards, Vincent On Wed, Feb 11, 2015 at 9:26 PM, Ivan Chernetsky <ich...@qu...> wrote: > Hello everybody, > > With N sufficiently large (on my machine 100000 is large enough), the > below program segfaults. With N sufficiently small (on my machine 1000 is > small enough) trash values get written into ns table. It is not allowed to > use BindInt with BindArrayOfInts with the same statement, by design, is it? > If so, BindInt should return some error code, instead of silently allowing > it. Again, if so, what is the proper way of binding single variables and > arrays? > > #include <ocilib.h> > > #define N 100000 > > int main(void) > { > OCI_Connection *cn = NULL; OCI_Statement *st = NULL; > int single = 0, array[N] = {1}; > const char *host = "db", *user = "user", *password = "pass"; > > if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) > return EXIT_FAILURE; > cn = OCI_ConnectionCreate(host, user, password, OCI_SESSION_DEFAULT); > if (cn == NULL) > return EXIT_FAILURE; > > st = OCI_StatementCreate(cn); > if (st == NULL) > return EXIT_FAILURE; > > OCI_Prepare(st, "DROP TABLE ns"); > OCI_Execute(st); > OCI_Commit(cn); > > if (!OCI_Prepare(st, "CREATE TABLE ns (n1 NUMBER, n2 NUMBER)")) > return EXIT_FAILURE; > if (!OCI_Execute(st)) > return EXIT_FAILURE; > if (!OCI_Commit(cn)) > return EXIT_FAILURE; > > if (!OCI_Prepare(st, "INSERT INTO ns (n1, n2) VALUES (:single, > :array)")) > return EXIT_FAILURE; > > if (!OCI_BindArraySetSize(st, N)) > return EXIT_FAILURE; > if (!OCI_BindInt(st, ":single", &single)) > return EXIT_FAILURE; > if (!OCI_BindArrayOfInts(st, ":array", array, N)) > return EXIT_FAILURE; > > if (!OCI_Execute(st)) > return EXIT_FAILURE; > printf("rows affected: %u\n", OCI_GetAffectedRows(st)); > > if (!OCI_Commit(cn)) > return EXIT_FAILURE; > > OCI_Cleanup(); > return EXIT_SUCCESS; > } > > -- > Ivan Chernetsky > Qualys, Inc. | Continuous Security | www.qualys.com > Work: (650) 801-7737 | Cell: (650) 422-9092 > > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming. The Go Parallel Website, > sponsored by Intel and developed in partnership with Slashdot Media, is > your > hub for all things parallel software development, from weekly thought > leadership blogs to news, videos, case studies, tutorials and more. Take a > look and join the conversation now. http://goparallel.sourceforge.net/ > _______________________________________________ > Orclib-users mailing list > Orc...@li... > https://lists.sourceforge.net/lists/listinfo/orclib-users > > -- Vincent Rogier |
From: Ivan C. <ich...@qu...> - 2015-02-11 21:30:11
|
Hello everybody, With N sufficiently large (on my machine 100000 is large enough), the below program segfaults. With N sufficiently small (on my machine 1000 is small enough) trash values get written into ns table. It is not allowed to use BindInt with BindArrayOfInts with the same statement, by design, is it? If so, BindInt should return some error code, instead of silently allowing it. Again, if so, what is the proper way of binding single variables and arrays? #include <ocilib.h> #define N 100000 int main(void) { OCI_Connection *cn = NULL; OCI_Statement *st = NULL; int single = 0, array[N] = {1}; const char *host = "db", *user = "user", *password = "pass"; if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) return EXIT_FAILURE; cn = OCI_ConnectionCreate(host, user, password, OCI_SESSION_DEFAULT); if (cn == NULL) return EXIT_FAILURE; st = OCI_StatementCreate(cn); if (st == NULL) return EXIT_FAILURE; OCI_Prepare(st, "DROP TABLE ns"); OCI_Execute(st); OCI_Commit(cn); if (!OCI_Prepare(st, "CREATE TABLE ns (n1 NUMBER, n2 NUMBER)")) return EXIT_FAILURE; if (!OCI_Execute(st)) return EXIT_FAILURE; if (!OCI_Commit(cn)) return EXIT_FAILURE; if (!OCI_Prepare(st, "INSERT INTO ns (n1, n2) VALUES (:single, :array)")) return EXIT_FAILURE; if (!OCI_BindArraySetSize(st, N)) return EXIT_FAILURE; if (!OCI_BindInt(st, ":single", &single)) return EXIT_FAILURE; if (!OCI_BindArrayOfInts(st, ":array", array, N)) return EXIT_FAILURE; if (!OCI_Execute(st)) return EXIT_FAILURE; printf("rows affected: %u\n", OCI_GetAffectedRows(st)); if (!OCI_Commit(cn)) return EXIT_FAILURE; OCI_Cleanup(); return EXIT_SUCCESS; } -- Ivan Chernetsky Qualys, Inc. | Continuous Security | www.qualys.com Work: (650) 801-7737 | Cell: (650) 422-9092 |
From: Rafael C. <cu...@gm...> - 2015-01-24 20:49:12
|
Hi Is possible to reuse the same OCI_Statement variable multiple times? I have an small program that i prepare an select statement and save it prepared handle to an variable . when i call the first time, it execute ok, but on second pass here the call stack ╔═[■]═Stack═════════════4═[↑][↓]═ ║OCI_BatchErrorClear(:03ED46B8) on stament.c line 1432 ║OCI_ExecuteInternal(:03ED46B8, 1 ║OCI_Execute(:03ED46B8) ║getPreparedSeekora(:047BFEE4, 1, ║#..\source\sqlex1ora#sqlExOraSee also when i finish I call OCI_StatementFree inside getPreparedSeekOra so for reuse, i can supress the call to OCI_StatementFree inside getPreparedSeekOra? Regards Luiz |
From: Miguel V. <pag...@gm...> - 2015-01-13 22:51:36
|
Great stuff. Better support is impossible. :-) Going to download it right away. Thanks for everything, Vincent. best regards, Miguel On Tue, Jan 13, 2015 at 10:46 PM, vincent rogier <vin...@gm...> wrote: > Btw, version 4.0.1 released :) > > On Tue, Jan 13, 2015 at 10:53 PM, vincent rogier <vin...@gm...> > wrote: > >> you can create a procedure that takes an collection (PL/SQL table, VARRAY >> or nested tables) as input parameter. >> In the app code, you can use a collection<T> and bind it to the statement. >> check the C++ main demo app and the collection cpp demo >> As well you can refer to the C documentation - section Collection for >> more information >> >> On Tue, Jan 13, 2015 at 10:47 PM, Miguel Vaz <pag...@gm...> wrote: >> >>> Yes, i understand the impossibility of sending a class, what i meant was >>> send bulk rows of data in one go. >>> >>> Dont worry. Get that realeas done. And thanks. :-) >>> >>> best regards, >>> MV >>> >>> On Tue, Jan 13, 2015 at 9:37 PM, vincent rogier <vin...@gm...> >>> wrote: >>> >>>> I'm currently finishing creating release packages for v4.0.1. >>>> They will be online wihtin the next hour. >>>> >>>> You cannot send a C++ class to an oracle procedure. >>>> >>>> Regards, >>>> >>>> Vincent >>>> >>>> On Tue, Jan 13, 2015 at 10:34 PM, Miguel Vaz <pag...@gm...> >>>> wrote: >>>> >>>>> Hi Vincent, >>>>> >>>>> Thats perfectly ok. Just glad you know what the problem is. I did >>>>> spend the whole afternoon cursing over my code and lack of skills, hehe. :-) >>>>> >>>>> On a different note, how can i send a simple class over to an oracle >>>>> procedure? >>>>> >>>>> Something like: >>>>> >>>>> class person{ >>>>> string nome; >>>>> int id; >>>>> } >>>>> >>>>> on the oracle side somethign like: >>>>> >>>>> create ... >>>>> procedure_name(indata IN cursor){ >>>>> >>>>> >>>>> } >>>>> >>>>> Any pointer on this is great help. >>>>> >>>>> Again, no worries about the bug. :-) >>>>> >>>>> best regards, >>>>> MV >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> On Tue, Jan 13, 2015 at 6:40 PM, vincent rogier < >>>>> vin...@gm...> wrote: >>>>> >>>>>> Hi Miguel, >>>>>> >>>>>> I apologize as there is an issue with binding string in the released >>>>>> header files. >>>>>> >>>>>> I'm going to release an version 4.0.1 with some fixes for both C and >>>>>> C++ APIs this week. >>>>>> >>>>>> Regarding your issue, while waiting for the new packages, you can fix >>>>>> it quickly by making the following simple modification : >>>>>> >>>>>> * in the file ocilib_impl.hpp, line 3860 (BindAdaptor template class >>>>>> constructor) >>>>>> * replace _size by size >>>>>> >>>>>> and it should work again :) >>>>>> >>>>>> Sorry for the inconvenience ! >>>>>> >>>>>> Regards, >>>>>> >>>>>> Vincent >>>>>> >>>>>> >>>>>> On Tue, Jan 13, 2015 at 6:15 PM, Miguel Vaz <pag...@gm...> >>>>>> wrote: >>>>>> >>>>>>> Hi, >>>>>>> I cant a simple insert to work using a procedure and ocilib. >>>>>>> >>>>>>> The procedure: >>>>>>> >>>>>>> CREATE OR REPLACE >>>>>>> PROCEDURE criasistema(idout OUT NUMBER, nm IN VARCHAR2) AS >>>>>>> BEGIN >>>>>>> insert into sistemas(NOME) values(nm) returning id_sistema into >>>>>>> idout; >>>>>>> >>>>>>> END; >>>>>>> >>>>>>> >>>>>>> Heres the c++ code: >>>>>>> >>>>>>> Environment::Initialize(Environment::Default | >>>>>>> Environment::Threaded); >>>>>>> string sql = "declare ids NUMBER begin criasistema(:ids,:nm); end;"; >>>>>>> >>>>>>> try{ >>>>>>> con.Open(connectString, user, passw); >>>>>>> Statement st(con); >>>>>>> Statement st2(con); >>>>>>> st.Prepare(sql); >>>>>>> st.Bind(":ids", st2, BindInfo::Out); >>>>>>> st.Bind(":nm", nome, 255, BindInfo::In); >>>>>>> st.Execute(); >>>>>>> >>>>>>> con.Commit(); >>>>>>> con.Close(); >>>>>>> >>>>>>> } >>>>>>> catch (Exception &ex){ >>>>>>> cout << ex.what() << endl; >>>>>>> } >>>>>>> >>>>>>> Environment::Cleanup(); >>>>>>> >>>>>>> It compiles but breaks at st.Bind(":nm", nome, 255, BindInfo::In); >>>>>>> What am i doing wrong? >>>>>>> >>>>>>> I assumed it would be simply a matter of binding in and out >>>>>>> variables and it shuld work, but not so easy.. :-P >>>>>>> >>>>>>> I am really not at easy with the binds. Next step will be to send a >>>>>>> full object (int,string,...) array, but if i cant solve this simple string >>>>>>> issue, i am not going anywahere. >>>>>>> >>>>>>> Thanks. >>>>>>> MV >>>>>>> >>>>>>> >>>>>>> ------------------------------------------------------------------------------ >>>>>>> New Year. New Location. New Benefits. New Data Center in Ashburn, VA. >>>>>>> GigeNET is offering a free month of service with a new server in >>>>>>> Ashburn. >>>>>>> Choose from 2 high performing configs, both with 100TB of bandwidth. >>>>>>> Higher redundancy.Lower latency.Increased capacity.Completely >>>>>>> compliant. >>>>>>> http://p.sf.net/sfu/gigenet >>>>>>> _______________________________________________ >>>>>>> Orclib-users mailing list >>>>>>> Orc...@li... >>>>>>> https://lists.sourceforge.net/lists/listinfo/orclib-users >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Vincent Rogier >>>>>> >>>>> >>>>> >>>> >>>> >>>> -- >>>> Vincent Rogier >>>> >>> >>> >> >> >> -- >> Vincent Rogier >> > > > > -- > Vincent Rogier > |
From: vincent r. <vin...@gm...> - 2015-01-13 22:46:55
|
Btw, version 4.0.1 released :) On Tue, Jan 13, 2015 at 10:53 PM, vincent rogier <vin...@gm...> wrote: > you can create a procedure that takes an collection (PL/SQL table, VARRAY > or nested tables) as input parameter. > In the app code, you can use a collection<T> and bind it to the statement. > check the C++ main demo app and the collection cpp demo > As well you can refer to the C documentation - section Collection for more > information > > On Tue, Jan 13, 2015 at 10:47 PM, Miguel Vaz <pag...@gm...> wrote: > >> Yes, i understand the impossibility of sending a class, what i meant was >> send bulk rows of data in one go. >> >> Dont worry. Get that realeas done. And thanks. :-) >> >> best regards, >> MV >> >> On Tue, Jan 13, 2015 at 9:37 PM, vincent rogier <vin...@gm...> >> wrote: >> >>> I'm currently finishing creating release packages for v4.0.1. >>> They will be online wihtin the next hour. >>> >>> You cannot send a C++ class to an oracle procedure. >>> >>> Regards, >>> >>> Vincent >>> >>> On Tue, Jan 13, 2015 at 10:34 PM, Miguel Vaz <pag...@gm...> >>> wrote: >>> >>>> Hi Vincent, >>>> >>>> Thats perfectly ok. Just glad you know what the problem is. I did spend >>>> the whole afternoon cursing over my code and lack of skills, hehe. :-) >>>> >>>> On a different note, how can i send a simple class over to an oracle >>>> procedure? >>>> >>>> Something like: >>>> >>>> class person{ >>>> string nome; >>>> int id; >>>> } >>>> >>>> on the oracle side somethign like: >>>> >>>> create ... >>>> procedure_name(indata IN cursor){ >>>> >>>> >>>> } >>>> >>>> Any pointer on this is great help. >>>> >>>> Again, no worries about the bug. :-) >>>> >>>> best regards, >>>> MV >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> On Tue, Jan 13, 2015 at 6:40 PM, vincent rogier <vin...@gm... >>>> > wrote: >>>> >>>>> Hi Miguel, >>>>> >>>>> I apologize as there is an issue with binding string in the released >>>>> header files. >>>>> >>>>> I'm going to release an version 4.0.1 with some fixes for both C and >>>>> C++ APIs this week. >>>>> >>>>> Regarding your issue, while waiting for the new packages, you can fix >>>>> it quickly by making the following simple modification : >>>>> >>>>> * in the file ocilib_impl.hpp, line 3860 (BindAdaptor template class >>>>> constructor) >>>>> * replace _size by size >>>>> >>>>> and it should work again :) >>>>> >>>>> Sorry for the inconvenience ! >>>>> >>>>> Regards, >>>>> >>>>> Vincent >>>>> >>>>> >>>>> On Tue, Jan 13, 2015 at 6:15 PM, Miguel Vaz <pag...@gm...> >>>>> wrote: >>>>> >>>>>> Hi, >>>>>> I cant a simple insert to work using a procedure and ocilib. >>>>>> >>>>>> The procedure: >>>>>> >>>>>> CREATE OR REPLACE >>>>>> PROCEDURE criasistema(idout OUT NUMBER, nm IN VARCHAR2) AS >>>>>> BEGIN >>>>>> insert into sistemas(NOME) values(nm) returning id_sistema into idout; >>>>>> >>>>>> END; >>>>>> >>>>>> >>>>>> Heres the c++ code: >>>>>> >>>>>> Environment::Initialize(Environment::Default | Environment::Threaded); >>>>>> string sql = "declare ids NUMBER begin criasistema(:ids,:nm); end;"; >>>>>> >>>>>> try{ >>>>>> con.Open(connectString, user, passw); >>>>>> Statement st(con); >>>>>> Statement st2(con); >>>>>> st.Prepare(sql); >>>>>> st.Bind(":ids", st2, BindInfo::Out); >>>>>> st.Bind(":nm", nome, 255, BindInfo::In); >>>>>> st.Execute(); >>>>>> >>>>>> con.Commit(); >>>>>> con.Close(); >>>>>> >>>>>> } >>>>>> catch (Exception &ex){ >>>>>> cout << ex.what() << endl; >>>>>> } >>>>>> >>>>>> Environment::Cleanup(); >>>>>> >>>>>> It compiles but breaks at st.Bind(":nm", nome, 255, BindInfo::In); >>>>>> What am i doing wrong? >>>>>> >>>>>> I assumed it would be simply a matter of binding in and out variables >>>>>> and it shuld work, but not so easy.. :-P >>>>>> >>>>>> I am really not at easy with the binds. Next step will be to send a >>>>>> full object (int,string,...) array, but if i cant solve this simple string >>>>>> issue, i am not going anywahere. >>>>>> >>>>>> Thanks. >>>>>> MV >>>>>> >>>>>> >>>>>> ------------------------------------------------------------------------------ >>>>>> New Year. New Location. New Benefits. New Data Center in Ashburn, VA. >>>>>> GigeNET is offering a free month of service with a new server in >>>>>> Ashburn. >>>>>> Choose from 2 high performing configs, both with 100TB of bandwidth. >>>>>> Higher redundancy.Lower latency.Increased capacity.Completely >>>>>> compliant. >>>>>> http://p.sf.net/sfu/gigenet >>>>>> _______________________________________________ >>>>>> Orclib-users mailing list >>>>>> Orc...@li... >>>>>> https://lists.sourceforge.net/lists/listinfo/orclib-users >>>>>> >>>>>> >>>>> >>>>> >>>>> -- >>>>> Vincent Rogier >>>>> >>>> >>>> >>> >>> >>> -- >>> Vincent Rogier >>> >> >> > > > -- > Vincent Rogier > -- Vincent Rogier |
From: Miguel V. <pag...@gm...> - 2015-01-13 21:47:29
|
Yes, i understand the impossibility of sending a class, what i meant was send bulk rows of data in one go. Dont worry. Get that realeas done. And thanks. :-) best regards, MV On Tue, Jan 13, 2015 at 9:37 PM, vincent rogier <vin...@gm...> wrote: > I'm currently finishing creating release packages for v4.0.1. > They will be online wihtin the next hour. > > You cannot send a C++ class to an oracle procedure. > > Regards, > > Vincent > > On Tue, Jan 13, 2015 at 10:34 PM, Miguel Vaz <pag...@gm...> wrote: > >> Hi Vincent, >> >> Thats perfectly ok. Just glad you know what the problem is. I did spend >> the whole afternoon cursing over my code and lack of skills, hehe. :-) >> >> On a different note, how can i send a simple class over to an oracle >> procedure? >> >> Something like: >> >> class person{ >> string nome; >> int id; >> } >> >> on the oracle side somethign like: >> >> create ... >> procedure_name(indata IN cursor){ >> >> >> } >> >> Any pointer on this is great help. >> >> Again, no worries about the bug. :-) >> >> best regards, >> MV >> >> >> >> >> >> >> >> >> >> >> >> >> On Tue, Jan 13, 2015 at 6:40 PM, vincent rogier <vin...@gm...> >> wrote: >> >>> Hi Miguel, >>> >>> I apologize as there is an issue with binding string in the released >>> header files. >>> >>> I'm going to release an version 4.0.1 with some fixes for both C and C++ >>> APIs this week. >>> >>> Regarding your issue, while waiting for the new packages, you can fix it >>> quickly by making the following simple modification : >>> >>> * in the file ocilib_impl.hpp, line 3860 (BindAdaptor template class >>> constructor) >>> * replace _size by size >>> >>> and it should work again :) >>> >>> Sorry for the inconvenience ! >>> >>> Regards, >>> >>> Vincent >>> >>> >>> On Tue, Jan 13, 2015 at 6:15 PM, Miguel Vaz <pag...@gm...> wrote: >>> >>>> Hi, >>>> I cant a simple insert to work using a procedure and ocilib. >>>> >>>> The procedure: >>>> >>>> CREATE OR REPLACE >>>> PROCEDURE criasistema(idout OUT NUMBER, nm IN VARCHAR2) AS >>>> BEGIN >>>> insert into sistemas(NOME) values(nm) returning id_sistema into idout; >>>> >>>> END; >>>> >>>> >>>> Heres the c++ code: >>>> >>>> Environment::Initialize(Environment::Default | Environment::Threaded); >>>> string sql = "declare ids NUMBER begin criasistema(:ids,:nm); end;"; >>>> >>>> try{ >>>> con.Open(connectString, user, passw); >>>> Statement st(con); >>>> Statement st2(con); >>>> st.Prepare(sql); >>>> st.Bind(":ids", st2, BindInfo::Out); >>>> st.Bind(":nm", nome, 255, BindInfo::In); >>>> st.Execute(); >>>> >>>> con.Commit(); >>>> con.Close(); >>>> >>>> } >>>> catch (Exception &ex){ >>>> cout << ex.what() << endl; >>>> } >>>> >>>> Environment::Cleanup(); >>>> >>>> It compiles but breaks at st.Bind(":nm", nome, 255, BindInfo::In); >>>> What am i doing wrong? >>>> >>>> I assumed it would be simply a matter of binding in and out variables >>>> and it shuld work, but not so easy.. :-P >>>> >>>> I am really not at easy with the binds. Next step will be to send a >>>> full object (int,string,...) array, but if i cant solve this simple string >>>> issue, i am not going anywahere. >>>> >>>> Thanks. >>>> MV >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> New Year. New Location. New Benefits. New Data Center in Ashburn, VA. >>>> GigeNET is offering a free month of service with a new server in >>>> Ashburn. >>>> Choose from 2 high performing configs, both with 100TB of bandwidth. >>>> Higher redundancy.Lower latency.Increased capacity.Completely compliant. >>>> http://p.sf.net/sfu/gigenet >>>> _______________________________________________ >>>> Orclib-users mailing list >>>> Orc...@li... >>>> https://lists.sourceforge.net/lists/listinfo/orclib-users >>>> >>>> >>> >>> >>> -- >>> Vincent Rogier >>> >> >> > > > -- > Vincent Rogier > |