Xref: utzoo comp.databases:6654 comp.lang.c++:8726 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!ucbvax!ucdavis!csusac!unify!nico From: nico@Unify.Com (Nico Nierenberg) Newsgroups: comp.databases,comp.lang.c++ Subject: Re: Embedded SQL in C++ Message-ID: Date: 1 Aug 90 19:54:24 GMT References: <897@rm1.UUCP> Organization: Unify Corporation, Sacramento, CA, USA Lines: 58 In article <897@rm1.UUCP> bapat@rm1.UUCP (Bapat) writes: > > >A question for all you C++ programmers out there trying to build >applications that use an embedded RDBMS: > >What's the best way to declare C++ constructs to the Embedded SQL Precompiler >interface? Since C++ is a superset of C, and since the Precompiler >translates Embedded SQL to straight C, it should also work on C++, nyet? > >The problem I'm having is when I declare host-language variables: > >void Myclass::myfunc ( int myarg1, int myarg2) >{ > EXEC SQL BEGIN DECLARE SECTION; > char sql_buffer[1024]; > ... > EXEC SQL END DECLARE SECTION; > > [ Later... ] > > EXEC SQL PREPARE S1 FROM :sql_buffer; > EXEC SQL DECLARE C1 CURSOR FOR S1; > EXEC SQL OPEN C1; > EXEC SQL FETCH C1 INTO > :this->string1, :this->string2; > ^^^^ ^^^^ > [ etc ] >} > >The problem is that SQL Precompiler, which thinks it's precompiling pure C, >doesn't know about the implicit "this" pointer since it is not declared >following the EXEC SQL BEGIN DECLARE SECTION. On the other hand, the real host >language (C++) assumes an implicit meaning for "this", which therefore is >never declared as a variable anywhere. > I believe that standard embedded SQL can't deal with things like structures in any event. The solution is what you proposed unless the particluar SQL has extensions to recognize pointers and structures. >The workaround we're thinking of is to copy the FETCH'ed data into regular temp >variables (which we can declare in the EXEC SQL DECLARE SECTION), and then >subsequently copy them into the appropriate members of "this" outside the >scope of an EXEC SQL. > >Any thoughts, comments, etc are welcome. >-- >Subodh Bapat bapat@rm1.uu.net OR ...uunet!rm1!bapat >MS E-204, PO Box 407044, Racal-Milgo, Ft Lauderdale, FL 33340 (305) 846-6068 > >"Sex is merely sublimated relief for the primitive urge to hack code." -- --------------------------------------------------------------------- Nicolas Nierenberg "No matter where you go, Unify Corp. there you are." nico@unify