Comments in Embedded SQL files???
Comments in Embedded SQL files???
(OP)
Hy,
does anybody know how I can insert comments into Embedded SQL files? Is it possible at all?
kind regards boaconstrictor
does anybody know how I can insert comments into Embedded SQL files? Is it possible at all?
kind regards boaconstrictor

RE: Comments in Embedded SQL files???
(example SQL block:)
CREATE SEQUENCE "id" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
-- this is a comment
SELECT * FROM table_1;
-- here are a few comments
-- comment1
-- comment2
SELECT * FROM table_1
-- you can even have comments in the
-- middle of an SQL statement, as long
-- as you put them on their own lines
WHERE id > 12;
Or do you mean the SQL COMMENT syntax, where you can create a comment on a table, view, whatever, to be stored for later use? This should also work just fine in embedded SQL:
http://www.postgresql.org/idocs/index.php?sql-comment.html
-------------------------------------------
Big Brother: "War is Peace" -- Big Business: "Trust is Suspicion"
(http://www.cl.cam.ac.uk/~rja14/tcpa-faq.html)
RE: Comments in Embedded SQL files???
If you are embedding it in the C language, you could also used the '/* */' comments...
e.g.
EXEC SQL SELECT fname,lname /* SELECT .... */
INTO :hv_Fname,:hv_Lname
FROM EMPLOYEE /* EMPLOYEE TABLE */
WHERE idno=:hv_IDNo;
Good Luck!
RE: Comments in Embedded SQL files???
I found out now what was wrong. The token "--" can be used in .pgc-files, but if you precompile this to a c-program, it produces "--" tokens as well in the c-file. But in C this is an unknown token. So if you use this token, you need to swap them into "/*" tokens.
Hence it is strongly recommended to use the standard C token "/*" and "*/" for comments inside the .pgc files.
But there is still a considerable issue:
The new C99 standard supports also the token "//" to make comments for one line. But the ECPG program doesn't recognise it as a comment token! This could be a pitfall!