Xref: utzoo comp.databases:6634 comp.lang.c++:8684 Path: utzoo!attcan!uunet!cs.utexas.edu!samsung!rex!uflorida!novavax!rm1!bapat From: bapat@rm1.UUCP (Bapat) Newsgroups: comp.databases,comp.lang.c++ Subject: Embedded SQL in C++ Message-ID: <897@rm1.UUCP> Date: 30 Jul 90 18:41:53 GMT Organization: the boundary between UNIX and sanity Lines: 46 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. 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."