Precompiler doesn't like C++ style comments & C++ string concats
================================================================

The Precompiler appears to not like the common c++ style comments between
the   EXEC SQL BEGIN / END DECLARE SECTION; statements, even if one
compile with the -cplus option set.

A //c++ comment at the end of a line like

  char    nickname[65];  // test comment

causes the error(s)

SAP AG SAP DB C-PreComp Version   7.3.0    Build 029-000-087-746 PROGNAME:
SAPDBTest
   159         *** PRECOM-ERROR NO :    -837   Data definition not allowed
   159         *** PRECOM-ERROR NO :    -837   Data definition not allowed
   159         *** PRECOM-ERROR NO :    -837   Data definition not allowed
   159         *** PRECOM-ERROR NO :    -837   Data definition not allowed
   159         *** PRECOM-ERROR NO :    -837   Data definition not allowed
   161         *** PRECOM-ERROR NO :    -847   Invalid type definition
   161         *** PRECOM-ERROR NO :    -881   Unknown type name
   161         *** PRECOM-ERROR NO :    -849   Invalid variable definition
   179         *** PRECOM-ERROR NO :    -877   Unknown parameter name
   179              VARIABLE-NAME  :    0: hTheUserPM


A //c++ comment on a single line alone causes this error:

*** PRECOM-ERROR NO :    -846   Invalid statement in section

It appears to me, that the -cplus option only instructs the cpc to create
a file with the CPP-file-extension instead of the C-file-extension. Is
this correct ?

The Precompiler Manual Page 2-2 says:
An SQL statement can be interrupted by comments in C format (designated by
/* and */). Within an SQL statement, comments can also be placed at the
end of a line. They must be preceded by the characters "--".

Well, .. ok .., but is an DECLARE SECTION an SQL statement ?


Another thing that comes to my mind is string concatenation.
Normally one uses the \ (backslash) to extend a string literal in the
source to the next line, i.e.

  EXEC SQL 1 PREPARE dbGetObjOAR_Simple FROM
    "SELECT DISTINCT rtERG (OID) \
     FROM   DUMMY_OAR, rtSVEC \
     WHERE  DUMMY_OAR.AID IN (rtSVEC.AID)";

and MUCH longer statements are likely being written.

However, if you are indenting your source, you will get a bunch of 
blanks in front of your next lines, causing blanks to blow up your total
sql-statement length (wich is limited of course). 

It's possible in c++, that you can just close the string with an ending
quotation mark and begin your next line with a starting quotation mark -
and there's your concat'd string.

Just try this:
  std::string stringconcattest = "this is the first line "
    "and this is the second line";

and you get:
  "this is the first line and this is the second line"
  
Since I just tested it casualy yet, it looks like the cpc tears the parts
apart and the app just throws -5015 Missing Keyword at runtime with a
statement like this:

  EXEC SQL 1 PREPARE dbGetObjOAR_Simple FROM
    "SELECT DISTINCT rtERG (OID) "
    "FROM   DUMMY_OAR, rtSVEC "
    "WHERE  DUMMY_OAR.AID IN (rtSVEC.AID)";


Well ok, i know that the cpc isn't a "full" compiler (just some kind of 
preprocessor), but are there way's around these limits ? 
Are you planning to overcome these limits ?

anyway, thanks in advance

btw: it might not sound like this, but i LIKE your DB.

keep up the good work


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to