Re: [Orclib-users] selecting a "date"
Open source C and C++ library for accessing Oracle Databases
Brought to you by:
vince_del_paris
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 |