From boris at codesynthesis.com Tue May 2 10:10:42 2023 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue May 2 10:02:26 2023 Subject: [odb-users] Strange behavior of odb::details::transfer_ptr In-Reply-To: References: Message-ID: Reilly He writes: > And in the constructor of odb::sqlite::database, *it takes a transfer_ptr > via its copy constructor:* > > > database:: > > database (const string& name, > > int flags, > > bool foreign_keys, > > const string& vfs, > > transfer_ptr factory) This is an implementation detail (in order to support both std::auto_ptr and std::unique_ptr in the same codebase until we get rid of C++98 support). In your code, if you are using C++11 or later you should just treat it as if it were std::unique_ptr, per the documentation: https://www.codesynthesis.com/products/odb/doc/manual.xhtml#18.2 For example: std::unique_ptr f ( new odb::sqlite::connection_pool_factory (20)); std::unique_ptr db ( new odb::sqlite::database (...., std::move (f))); From odb at a-cunningham.com Thu May 4 17:07:18 2023 From: odb at a-cunningham.com (Andrew Cunningham) Date: Thu May 4 16:59:27 2023 Subject: [odb-users] Problem using Message-ID: Hi, I am using an older version of ODB (2.5.0-b.3) , for an previous version of our software, and I need to use std::complex in a class for an patch upgrade Whenever I include in a header file to be processed by ODB I get many of the following types of errors. I will be making the complex data member persistent. I can reproduce with a simple case based on one of the ODB examples. 1>d:\odb2.5.0\odb-2.5.0-b.3-i686-windows\mingw\include\c++\4.9.3\cmath(102,11): error G5885A27A: '::acos' has not been declared 1> using ::acos; 1> ^ 1>d:\odb2.5.0\odb-2.5.0-b.3-i686-windows\mingw\include\c++\4.9.3\cmath(121,11): error G0EE8A278: '::asin' has not been declared 1> using ::asin; 1> ^ 1>d:\odb2.5.0\odb-2.5.0-b.3-i686-windows\mingw\include\c++\4.9.3\cmath(140,11): error G8383A270: '::atan' has not been declared I have been unable to come up with a workaround so far. Andrew From roberto.minarelli.de at gmail.com Thu May 4 09:55:32 2023 From: roberto.minarelli.de at gmail.com (roberto minarelli) Date: Fri May 5 06:21:29 2023 Subject: [odb-users] cannot compile object view Message-ID: Dear odb-users, when compiling file that contains definition of an object view I always obtain this error version odb 2.4.0 error: view type data member cannot be designated as an object id I used the following cmd line odb -I/usr/local/lib/libodb -d oracle --generate-query provaView.h the pseudocode inside the file is as follows #pragma db view table("Table1") table("Table2") struct Tab1_Tab2 { unsigned long tab1Field; unsigned short tab2Field; #pragma db id column(Table1::key) type("VARCHAR2(40)") std::string tab1_tab2_key; }; Files Tab?-odb.?xx have been regurarly generated. Could you please give me an advice on what I am doing wrong? Thanks a lot Best regards Roberto Minarelli Delli Della Valle From boris at codesynthesis.com Fri May 5 06:35:24 2023 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri May 5 06:27:06 2023 Subject: [odb-users] cannot compile object view In-Reply-To: References: Message-ID: roberto minarelli writes: > error: view type data member cannot be designated as an object id > > #pragma db view table("Table1") table("Table2") > struct Tab1_Tab2 > { > unsigned long tab1Field; > unsigned short tab2Field; > > #pragma db id column(Table1::key) type("VARCHAR2(40)") > std::string tab1_tab2_key; > }; The `id` specifier does not make sense in a view, only in an object. So just remove it (along with `columnt(Table1::key)`, which also doesn't make sense in a table view): #pragma db type("VARCHAR2(40)") std::string tab1_tab2_key; For details on table views, see: https://www.codesynthesis.com/products/odb/doc/manual.xhtml#10.3 From boris at codesynthesis.com Fri May 5 06:50:06 2023 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri May 5 06:41:47 2023 Subject: [odb-users] Problem using In-Reply-To: References: Message-ID: Andrew Cunningham writes: > Whenever I include in a header file to be processed by ODB > I get many of the following types of errors. I will be making the > complex data member persistent. > > [...] > > I have been unable to come up with a workaround so far. If upgrading to a later version of ODB is not an option here, I would probably resort to emulating std::complex during the ODB compilation. Something along these lines: #ifndef ODB_COMPILER # include #else namespace std { template class complex { T re_; T im_; public: using value_type = T; complex(T re = T(), T im = T()): re_ (re), im_ (im) {} complex(const complex&) = default; complex& operator=(const complex&) = default; T real() const {return re_;} void real(T re) {re_ = re;} T imag() const {return im_;} void imag(T im) {im_ = im;}; }; } #endif You may also need to #ifdef-out any inline code that requires a proper definition std::complex based on the ODB_COMPILER macro. From odb at a-cunningham.com Fri May 5 11:12:27 2023 From: odb at a-cunningham.com (Andrew Cunningham) Date: Fri May 5 11:04:35 2023 Subject: [odb-users] Problem using In-Reply-To: References: Message-ID: Hi Boris, Yes, that would be a workable solution. The latest ODB 2.5 does not have this issue, I'll probably just do the upgrade for the older version. It should be painless. Andrew On Fri, May 5, 2023 at 3:50?AM Boris Kolpackov wrote: > > Andrew Cunningham writes: > > > Whenever I include in a header file to be processed by ODB > > I get many of the following types of errors. I will be making the > > complex data member persistent. > > > > [...] > > > > I have been unable to come up with a workaround so far. > > If upgrading to a later version of ODB is not an option here, I would > probably resort to emulating std::complex during the ODB compilation. > Something along these lines: > > #ifndef ODB_COMPILER > # include > #else > namespace std > { > template > class complex > { > T re_; > T im_; > > public: > using value_type = T; > > complex(T re = T(), T im = T()): re_ (re), im_ (im) {} > > complex(const complex&) = default; > complex& operator=(const complex&) = default; > > T real() const {return re_;} > void real(T re) {re_ = re;} > T imag() const {return im_;} > void imag(T im) {im_ = im;}; > }; > } > #endif > > You may also need to #ifdef-out any inline code that requires a proper > definition std::complex based on the ODB_COMPILER macro. From odb at a-cunningham.com Fri May 5 11:51:21 2023 From: odb at a-cunningham.com (Andrew Cunningham) Date: Fri May 5 11:43:29 2023 Subject: [odb-users] Problem using In-Reply-To: References: Message-ID: Hi Boris, Just following up on this issue. Let's assume I have upgraded ODB and no longer hit the compile errors and don't need the workaround. Then I must admit I am struggling with the correct #pragma db pattern to persist a 'complex' value. We do not know the names of the private data members of 'complex' so can only use the public member functions which are standardized across all implementations. I have tried the following, but I am flailing around and getting nowhere. using FComplex=std::complex; #ifdef ODB_COMPILER #pragma db value(FComplex) definition #pragma db member(FComplex::real) virtual(float) get(real) \ set(real) column("re") #pragma db member(FComplex::imag) virtual(float) get(imag) \ set(imag) column("im") #endif Andrew On Fri, May 5, 2023 at 3:50?AM Boris Kolpackov wrote: > > Andrew Cunningham writes: > > > Whenever I include in a header file to be processed by ODB > > I get many of the following types of errors. I will be making the > > complex data member persistent. > > > > [...] > > > > I have been unable to come up with a workaround so far. > > If upgrading to a later version of ODB is not an option here, I would > probably resort to emulating std::complex during the ODB compilation. > Something along these lines: > > #ifndef ODB_COMPILER > # include > #else > namespace std > { > template > class complex > { > T re_; > T im_; > > public: > using value_type = T; > > complex(T re = T(), T im = T()): re_ (re), im_ (im) {} > > complex(const complex&) = default; > complex& operator=(const complex&) = default; > > T real() const {return re_;} > void real(T re) {re_ = re;} > T imag() const {return im_;} > void imag(T im) {im_ = im;}; > }; > } > #endif > > You may also need to #ifdef-out any inline code that requires a proper > definition std::complex based on the ODB_COMPILER macro. From odb at a-cunningham.com Fri May 5 16:20:36 2023 From: odb at a-cunningham.com (Andrew Cunningham) Date: Fri May 5 16:12:46 2023 Subject: [odb-users] Problem using In-Reply-To: References: Message-ID: Never mind, I figured it out. The "transient" keyword is required - it tells ODB to ignore the data fields of the object. Obvious when you think about it! #pragma db value(FComplex) definition transient #pragma db member(FComplex::real) virtual(float) get(real) set(real) column("re") #pragma db member(FComplex::imag) virtual(float) get(imag) set(imag) column("im") On Fri, May 5, 2023 at 8:51?AM Andrew Cunningham wrote: > > Hi Boris, > Just following up on this issue. > > Let's assume I have upgraded ODB and no longer hit the compile errors > and don't need the workaround. > > Then I must admit I am struggling with the correct #pragma db pattern > to persist a 'complex' value. > > We do not know the names of the private data members of 'complex' so > can only use the public member functions which are standardized across > all implementations. > > I have tried the following, but I am flailing around and getting nowhere. > > using FComplex=std::complex; > > #ifdef ODB_COMPILER > #pragma db value(FComplex) definition > #pragma db member(FComplex::real) virtual(float) get(real) \ > set(real) column("re") > #pragma db member(FComplex::imag) virtual(float) get(imag) \ > set(imag) column("im") > #endif > > > Andrew > > On Fri, May 5, 2023 at 3:50?AM Boris Kolpackov wrote: > > > > Andrew Cunningham writes: > > > > > Whenever I include in a header file to be processed by ODB > > > I get many of the following types of errors. I will be making the > > > complex data member persistent. > > > > > > [...] > > > > > > I have been unable to come up with a workaround so far. > > > > If upgrading to a later version of ODB is not an option here, I would > > probably resort to emulating std::complex during the ODB compilation. > > Something along these lines: > > > > #ifndef ODB_COMPILER > > # include > > #else > > namespace std > > { > > template > > class complex > > { > > T re_; > > T im_; > > > > public: > > using value_type = T; > > > > complex(T re = T(), T im = T()): re_ (re), im_ (im) {} > > > > complex(const complex&) = default; > > complex& operator=(const complex&) = default; > > > > T real() const {return re_;} > > void real(T re) {re_ = re;} > > T imag() const {return im_;} > > void imag(T im) {im_ = im;}; > > }; > > } > > #endif > > > > You may also need to #ifdef-out any inline code that requires a proper > > definition std::complex based on the ODB_COMPILER macro. From roberto.minarelli.de at gmail.com Mon May 8 10:24:19 2023 From: roberto.minarelli.de at gmail.com (roberto minarelli) Date: Wed May 10 08:52:03 2023 Subject: [odb-users] Cannot generate classes with gcc compiler 8 and above Message-ID: Dear odb-user I cannot generate the classes with the gcc compilare I have on my Linux OS I currently using OL8 g++ 8.50 or above odb version 2.4.0 If I don't add the file xlocale.h to the /usr/include dir I get as result a very long list of errors If I add the xlocale.h file to the /usr/include directory I always obtain the error "In file included from /usr/local/app/odb-2.4.0-x86_64-linux-gnu/lib/odb/x86_64-linux-gnu/include/c++/4.9.3/cwchar:44:0, from /usr/local/app/odb-2.4.0-x86_64-linux-gnu/lib/odb/x86_64-linux-gnu/include/c++/4.9.3/bits/postypes.h:40, from /usr/local/app/odb-2.4.0-x86_64-linux-gnu/lib/odb/x86_64-linux-gnu/include/c++/4.9.3/bits/char_traits.h:40, from /usr/local/app/odb-2.4.0-x86_64-linux-gnu/lib/odb/x86_64-linux-gnu/include/c++/4.9.3/string:40, from :7: /usr/local/app/odb-2.4.0-x86_64-linux-gnu/lib/odb/x86_64-linux-gnu/lib/gcc/x86_64-linux-gnu/4.9.3/include-fixed/wchar.h:175:22: fatal error: xlocale.h: No such file or directory # include " I am trying to generate the class with the command odb -I/usr/local/lib/libodb -d oracle --generate-query MyClass.h Thanks in advance for any help Best regards Roberto MInarelli Della Valle From boris at codesynthesis.com Wed May 10 09:03:10 2023 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed May 10 08:54:45 2023 Subject: [odb-users] Cannot generate classes with gcc compiler 8 and above In-Reply-To: References: Message-ID: roberto minarelli writes: > I cannot generate the classes with the gcc compilare I have on my Linux OS > I currently using OL8 > g++ 8.50 or above > odb version 2.4.0 The recommended way to resolve this is to upgrade to the latest pre-release of ODB using the following instructions: https://codesynthesis.com/products/odb/doc/install-build2.xhtml From roberto.minarelli.de at gmail.com Fri May 12 09:56:24 2023 From: roberto.minarelli.de at gmail.com (roberto minarelli) Date: Fri May 12 09:56:36 2023 Subject: [odb-users] Cannot generate classes with gcc compiler 8 and above In-Reply-To: References: Message-ID: Hi again Boris, I follow the recommendation that you addressed me in the last mail, but the fact is that when I try to install libod-oracle I alway got always an error message Following are the steps I have done Step 1) bpkg create -d libodb-gcc-8 cc \ config.cxx=g++ \ config.cc.coptions=-O3 \ config.install.root=/usr/local \ config.install.sudo=sudo it installed the libod correctly but for libodb-oracle I got this error [root@vrplbears02 libodb-gcc-8]# bpkg build libodb-oracle libodb-oracle-2.5.0-b.23.tar.gz 100%[==========================================================================>] 87.25K --.-KB/s in 0.05s fetched libodb-oracle/2.5.0-b.23 unpacked libodb-oracle/2.5.0-b.23 error: unable to import target liboci%lib{clntsh} info: use config.import.liboci configuration variable to specify its project out_root error: unable to import target liboci%lib{clntsh} info: use config.import.liboci configuration variable to specify its project out_root info: while configuring libodb-oracle Step 2) I clean the installation made before and try as suggested by the hint given above bpkg create -d libodb-gcc-8 cc \ config.cxx=g++ \ config.cc.coptions=-O3 \ config.install.root=/usr/local \ config.install.sudo=sudo \ config.import.liboci=$ORACLE_HOME again I got an error message bpkg build libodb-oracle libodb-oracle-2.5.0-b.23.tar.gz 100%[==========================================================================>] 87.25K --.-KB/s in 0.05s fetched libodb-oracle/2.5.0-b.23 unpacked libodb-oracle/2.5.0-b.23 libodb-oracle-2.5.0-b.23/odb/oracle/buildfile:9:21: error: unable to determine src_root for imported liboci info: consider configuring $ORACLE_HOME I really don't know what is wrong in my approach Can you help me please? Thanks in advance Best Regards Roberto Minarelli Della Valle Il giorno mer 10 mag 2023 alle ore 15:03 Boris Kolpackov < boris@codesynthesis.com> ha scritto: > roberto minarelli writes: > > > I cannot generate the classes with the gcc compilare I have on my Linux > OS > > I currently using OL8 > > g++ 8.50 or above > > odb version 2.4.0 > > The recommended way to resolve this is to upgrade to the latest pre-release > of ODB using the following instructions: > > https://codesynthesis.com/products/odb/doc/install-build2.xhtml > > From finjulhich at gmail.com Sat May 13 15:07:57 2023 From: finjulhich at gmail.com (MM) Date: Sun May 14 10:23:15 2023 Subject: [odb-users] build2 interactive confirm : Y vs y Message-ID: While building odb with build2 >>>> cd odb-gcc-13 && bpkg build odb new libstudxml/1.1.0-b.10+1 (required by odb) new libcutl/1.11.0-b.9 (required by odb) new odb/2.5.0-b.23 continue? [Y/n] Y continue? [Y/n] y If one enters uppercase Y, if fails to start. lowercase y is accepted. Rds, From boris at codesynthesis.com Sun May 14 10:40:49 2023 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun May 14 10:32:20 2023 Subject: [odb-users] build2 interactive confirm : Y vs y In-Reply-To: References: Message-ID: MM writes: > continue? [Y/n] Y > continue? [Y/n] y > > > If one enters uppercase Y, if fails to start. lowercase y is accepted. By convention a capital Y or N in a prompt indicates the default answer, that is, the answer that will be assumed if one just presses Enter. But you are the second person who insist on typing an explicit, capitalized answer, so we've fixed the prompt to accept both cases. From roberto.minarelli.de at gmail.com Tue May 16 06:09:17 2023 From: roberto.minarelli.de at gmail.com (roberto minarelli) Date: Tue May 16 08:56:12 2023 Subject: [odb-users] stuck with installation of libodb-oracle-2.5.0-b.23 Message-ID: Dear odb user, following the advice I follow the instruction and successfully installed either odb either the libod version 2.5.0-b.23 I know it's the first time I use bpkg so I don't know all its parameters The fact is that whenever I try to build and install libodb-oracle I got always an error If I give this configuration bpkg create -d libodb-gcc-8 cc \ config.cxx=g++ \ config.cc.coptions=-O3 \ config.install.root=/usr/local \ config.install.sudo=sudo \ config.import.liboci=$ORACLE_HOME this is the error I got bpkg build libodb-oracle libodb-oracle-2.5.0-b.23.tar.gz 100%[==========================================================================>] 87.25K --.-KB/s in 0.05s fetched libodb-oracle/2.5.0-b.23 unpacked libodb-oracle/2.5.0-b.23 libodb-oracle-2.5.0-b.23/odb/oracle/buildfile:9:21: error: unable to determine src_root for imported liboci info: consider configuring $ORACLE_HOME I try to put the $ORACLE_HOME inside the configuration bpkg create -d libodb-gcc-8 cc \ config.cxx=g++ \ config.cc.coptions=-O3 \ config.install.root=/usr/local \ config.install.sudo=sudo \ config.ORACLE_HOME=$ORACLE_HOME \ config.import.liboci=$ORACLE_HOME and the result is an error libodb-gcc-8/build/config.build: warning: dropping no longer used variable config.ORACLE_HOME How should I configure bpkg in order to have a succesful installation of the libodb-oracle? Thanks a lot Best regards Roberto Minarelli Della Valle From boris at codesynthesis.com Tue May 16 09:15:58 2023 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue May 16 09:07:28 2023 Subject: [odb-users] stuck with installation of libodb-oracle-2.5.0-b.23 In-Reply-To: References: Message-ID: roberto minarelli writes: > bpkg create -d libodb-gcc-8 cc \ > config.cxx=g++ \ > config.cc.coptions=-O3 \ > config.install.root=/usr/local \ > config.install.sudo=sudo \ > config.import.liboci=$ORACLE_HOME No, this is not going to work, there is no liboci build2 project in $ORACLE_HOME that you can import. Try this instead: 1. First make sure $ORACLE_HOME expands to the location of liboci. 2. Then check that headers and libraries are in the expected places, respectively (see INSTALL inside libodb-oracle for background): headers: $ORACLE_HOME/rdbms/public libraries: $ORACLE_HOME/lib 3. Finally, try the following: bpkg create -d libodb-gcc-8 cc \ config.cxx=g++ \ config.cc.coptions=-O3 \ config.install.root=/usr/local \ config.install.sudo=sudo \ config.cc.poptions="-I$ORACLE_HOME/rdbms/public" \ config.cc.loptions="-L$ORACLE_HOME/lib" From roberto.minarelli.de at gmail.com Tue May 16 11:20:30 2023 From: roberto.minarelli.de at gmail.com (roberto minarelli) Date: Wed May 17 10:29:55 2023 Subject: [odb-users] stuck with installation of libodb-oracle-2.5.0-b.23 In-Reply-To: References: Message-ID: Thanks a lot! It worked! Best regards Roberto Minarelli Della Valle Il giorno mar 16 mag 2023 alle ore 15:15 Boris Kolpackov < boris@codesynthesis.com> ha scritto: > roberto minarelli writes: > > > bpkg create -d libodb-gcc-8 cc \ > > config.cxx=g++ \ > > config.cc.coptions=-O3 \ > > config.install.root=/usr/local \ > > config.install.sudo=sudo \ > > config.import.liboci=$ORACLE_HOME > > No, this is not going to work, there is no liboci build2 project in > $ORACLE_HOME that you can import. Try this instead: > > 1. First make sure $ORACLE_HOME expands to the location of liboci. > > 2. Then check that headers and libraries are in the expected places, > respectively (see INSTALL inside libodb-oracle for background): > > headers: $ORACLE_HOME/rdbms/public > libraries: $ORACLE_HOME/lib > > 3. Finally, try the following: > > bpkg create -d libodb-gcc-8 cc \ > config.cxx=g++ \ > config.cc.coptions=-O3 \ > config.install.root=/usr/local \ > config.install.sudo=sudo \ > config.cc.poptions="-I$ORACLE_HOME/rdbms/public" \ > config.cc.loptions="-L$ORACLE_HOME/lib" > From roberto.minarelli.de at gmail.com Fri May 19 14:07:54 2023 From: roberto.minarelli.de at gmail.com (roberto minarelli) Date: Mon May 22 10:01:59 2023 Subject: [odb-users] calling oracle procedure with odb Message-ID: Hi odb-users, I am trying to call a very simple procedure that has only one parameter as out param I tried as follows, following something found in the archive #pragma db view query("CALL my_procedure(?)") struct my_procedure { unsigned short myvalue; }; then in the code part I wrote ...... struct get_freetg xtg; using query1=odb::query; transaction t(db->begin()); db->query(&xtg.tg); t.commit(); ..... But this does not works at all I guess I made some mistake, but I cannot figure where Thanks for help Best regards Roberto Minarelli Della Valle From 202121046942 at mail.scut.edu.cn Sun May 21 11:48:27 2023 From: 202121046942 at mail.scut.edu.cn (=?UTF-8?B?6ZmI54SV6ZGr?=) Date: Mon May 22 10:02:00 2023 Subject: [odb-users] Find the bug under odb::lazy_shared_ptr source code Message-ID: <510a93b6.3a0.1883eff7059.Coremail.202121046942@mail.scut.edu.cn> I'm using the odb::lazy_shared_ptr pointer to implement a one-to-one relationship, as shown below #pragmadbobject classemployee { ... #pragmadbidauto unsignedlongid; #pragmadbnot_null odb::lazy_shared_ptr
positions; }; Then I try to load the positions under the driver.cxx file unsignedlongsearch_id = 52; std::shared_ptr emp(db->load(search_id)); emp->positions.load(); // delay load It has an error, and the error message reported is as follows /usr/include/odb/lazy-ptr.ixx:1153:10: error: no match for ?operator=? (operand types are ?std::shared_ptr
? and ?odb::object_traits
::pointer_type? {aka ?Article*?}) 1153 | p_ = i_.template load (true); // Reset id. | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/10/memory:84, from driver.cxx:4: /usr/include/c++/10/bits/shared_ptr.h:358:19: note: candidate: ?std::shared_ptr<_Tp>& std::shared_ptr<_Tp>::operator=(const std::shared_ptr<_Tp>&) [with _Tp = Article]? 358 | shared_ptr& operator=(const shared_ptr&) noexcept = default; | ^~~~~~~~ /usr/include/c++/10/bits/shared_ptr.h:358:29: note: no known conversion for argument 1 from ?odb::object_traits
::pointer_type? {aka ?Article*?} to ?const std::shared_ptr
&? 358 | shared_ptr& operator=(const shared_ptr&) noexcept = default; | ^~~~~~~~~~~~~~~~~ /usr/include/c++/10/bits/shared_ptr.h:362:2: note: candidate: ?template std::shared_ptr<_Tp>::_Assignable&> std::shared_ptr<_Tp>::operator=(const std::shared_ptr<_Yp>&) [with _Yp = _Yp; _Tp = Article]? 362 | operator=(const shared_ptr<_Yp>& __r) noexcept | ^~~~~~~~ ================================== It seems that you cannot assign a rawpointer directly to a shared pointer The problem is with line 1153 of /usr/include/odb/lazy-tr.ixx template inlinestd::shared_ptr lazy_shared_ptr:: load () const { if (!p_ && i_) p_ = i_.template load (true); // Reset id. returnp_; } The problem was solved when I changed the code to the following template inlinestd::shared_ptr lazy_shared_ptr:: load () const { if (!p_ && i_) //p_ = i_.template load (true); // Reset id. p_.reset(i_.templateload (true)); // Reset id. returnp_; } you can use method reset() to transfer a rawpointer directly to a shared pointer. From boris at codesynthesis.com Mon May 22 10:18:05 2023 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon May 22 10:09:29 2023 Subject: [odb-users] calling oracle procedure with odb In-Reply-To: References: Message-ID: roberto minarelli writes: > #pragma db view query("CALL my_procedure(?)") > struct my_procedure > { > unsigned short myvalue; > }; > > then in the code part I wrote > > struct get_freetg xtg; > using query1=odb::query; > transaction t(db->begin()); > db->query(&xtg.tg); > t.commit(); > > But this does not works at all No surprise there: passing a pointer as a query parameter in the hopes that the result will end up there is not how it works in ODB. Take a look at an example of calling stored procedures in the manual and see if you cannot figure it out: https://www.codesynthesis.com/products/odb/doc/manual.xhtml#17.7 From boris at codesynthesis.com Mon May 22 10:23:06 2023 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon May 22 10:14:33 2023 Subject: [odb-users] Find the bug under odb::lazy_shared_ptr source code In-Reply-To: <510a93b6.3a0.1883eff7059.Coremail.202121046942@mail.scut.edu.cn> References: <510a93b6.3a0.1883eff7059.Coremail.202121046942@mail.scut.edu.cn> Message-ID: ??? <202121046942@mail.scut.edu.cn> writes: > /usr/include/odb/lazy-ptr.ixx:1153:10: error: no match for ?operator=? (operand types are ?std::shared_ptr
? and ?odb::object_traits
::pointer_type? {aka ?Article*?}) > 1153 | p_ = i_.template load (true); // Reset id. > > > It seems that you cannot assign a rawpointer directly to a shared pointer No you can't, and it's a good thing. To use an odb::lazy_shared_ptr your object must use std::shared_ptr as an object pointer. For details, see: https://www.codesynthesis.com/products/odb/doc/manual.xhtml#3.3 From roberto.minarelli.de at gmail.com Mon May 22 11:23:42 2023 From: roberto.minarelli.de at gmail.com (roberto minarelli) Date: Wed May 24 06:17:54 2023 Subject: [odb-users] calling oracle procedure with odb In-Reply-To: References: Message-ID: Hi Boris Thanks a lot for you reply. Yes I imagined something like that but I also navigate through the documentation and tried to build a query on the example basis But it never compiles following is the code fragment #include #include #pragma db view query("CALL mp_vrdba.get_freetg((?))") struct get_freetg { unsigned short tg; }; .............. typedef odb::query query; transaction t(db->begin()); get_freetg gf(db->query(query::_val(0))); spdlog::get("daily_logger")->info("got free tg {}", gf.tg); t.commit(); ............ and these are the compilation errors I got /home/minarelli/sdg-root/sdg-rest-api/src/db/DbUtil.cpp: In member function ?TGV DbUtil::getFreeTGV()?: /home/minarelli/sdg-root/sdg-rest-api/src/db/DbUtil.cpp:268:56: error: no matching function for call to ?odb::database::query(odb::oracle::val_bind)? get_freetg gf(db->query(query::_val(0))); ^ In file included from /usr/local/include/odb/oracle/database.hxx:14:0, from /home/minarelli/sdg-root/sdg-rest-api/src/db/../../provaStored-odb.cxx:14, from /home/minarelli/sdg-root/sdg-rest-api/src/db/DbUtil.cpp:8: /usr/local/include/odb/database.hxx:263:5: note: candidate: template odb::result odb::database::query(bool) query (bool cache = true); ^~~~~ /usr/local/include/odb/database.hxx:263:5: note: template argument deduction/substitution failed: /home/minarelli/sdg-root/sdg-rest-api/src/db/DbUtil.cpp:268:53: note: cannot convert ?odb::oracle::query_base::_val(0, 4095, 4095)? (type ?odb::oracle::val_bind?) to type ?bool? get_freetg gf(db->query(query::_val(0))); ~~~~~~~~~~~^~~ In file included from /usr/local/include/odb/oracle/database.hxx:14:0, from /home/minarelli/sdg-root/sdg-rest-api/src/db/../../provaStored-odb.cxx:14, from /home/minarelli/sdg-root/sdg-rest-api/src/db/DbUtil.cpp:8: /usr/local/include/odb/database.hxx:267:5: note: candidate: template odb::result odb::database::query(const char*, bool) query (const char*, bool cache = true); ^~~~~ /usr/local/include/odb/database.hxx:267:5: note: template argument deduction/substitution failed: /home/minarelli/sdg-root/sdg-rest-api/src/db/DbUtil.cpp:268:53: note: cannot convert ?odb::oracle::query_base::_val(0, 4095, 4095)? (type ?odb::oracle::val_bind?) to type ?const char*? get_freetg gf(db->query(query::_val(0))); ~~~~~~~~~~~^~~ In file included from /usr/local/include/odb/oracle/database.hxx:14:0, from /home/minarelli/sdg-root/sdg-rest-api/src/db/../../provaStored-odb.cxx:14, from /home/minarelli/sdg-root/sdg-rest-api/src/db/DbUtil.cpp:8: /usr/local/include/odb/database.hxx:271:5: note: candidate: template odb::result odb::database::query(const string&, bool) query (const std::string&, bool cache = true); ^~~~~ /usr/local/include/odb/database.hxx:271:5: note: template argument deduction/substitution failed: /home/minarelli/sdg-root/sdg-rest-api/src/db/DbUtil.cpp:268:53: note: cannot convert ?odb::oracle::query_base::_val(0, 4095, 4095)? (type ?odb::oracle::val_bind?) to type ?const string& {aka const std::basic_string&}? get_freetg gf(db->query(query::_val(0))); ~~~~~~~~~~~^~~ In file included from /usr/local/include/odb/oracle/database.hxx:14:0, from /home/minarelli/sdg-root/sdg-rest-api/src/db/../../provaStored-odb.cxx:14, from /home/minarelli/sdg-root/sdg-rest-api/src/db/DbUtil.cpp:8: /usr/local/include/odb/database.hxx:275:5: note: candidate: template odb::result odb::database::query(const odb::query&, bool) query (const odb::query&, bool cache = true); ^~~~~ /usr/local/include/odb/database.hxx:275:5: note: template argument deduction/substitution failed: /home/minarelli/sdg-root/sdg-rest-api/src/db/DbUtil.cpp:268:53: note: cannot convert ?odb::oracle::query_base::_val(0, 4095, 4095)? (type ?odb::oracle::val_bind?) to type ?const odb::query&? get_freetg gf(db->query(query::_val(0))); ~~~~~~~~~~~^~~ That I cannot figured how to get rid of If you could help me please I would really appreciate it as I really like using odb Thanks in advance Roberto Minarelli Della Valle Il giorno lun 22 mag 2023 alle ore 16:18 Boris Kolpackov < boris@codesynthesis.com> ha scritto: > roberto minarelli writes: > > > #pragma db view query("CALL my_procedure(?)") > > struct my_procedure > > { > > unsigned short myvalue; > > }; > > > > then in the code part I wrote > > > > struct get_freetg xtg; > > using query1=odb::query; > > transaction t(db->begin()); > > db->query(&xtg.tg); > > t.commit(); > > > > But this does not works at all > > No surprise there: passing a pointer as a query parameter in the hopes > that the result will end up there is not how it works in ODB. > > Take a look at an example of calling stored procedures in the manual > and see if you cannot figure it out: > > https://www.codesynthesis.com/products/odb/doc/manual.xhtml#17.7 >