[comp.databases] Comments in SQL scripts -- is there standard

kmeek@cti1.UUCP (Kevin Meek) (07/10/90)

Is there anything in the SQL standards about how comments can
be inserted into an SQL script?  And if so at what level of SQL
compliance is this instituted. 

If there is no standard does anyone using UNIFY 2000 know if/how
you can insert comments into a Unify SQL script.

I have tried C style and Shell style comments but neither seem to work.

Many Thanks 

Kevin Meek
Comprehensive Technologies Int'l Inc.
2121 Crystal Drive   Suite #103
Arlington,  VA  22202
uunet!cit1!kmeek  OR cti1!kmeek@uunet.uu.net

hawkwind@kentvax.kent.edu (Len Jaffe) (07/11/90)

In article <216@cti1.UUCP> kmeek@cti1.UUCP (Kevin Meek) writes:
>Is there anything in the SQL standards about how comments can
>be inserted into an SQL script?  And if so at what level of SQL
>compliance is this instituted. 
>
>If there is no standard does anyone using UNIFY 2000 know if/how
>you can insert comments into a Unify SQL script.
>
>I have tried C style and Shell style comments but neither seem to work.
>
Unify 2000 uses double dashes in clumns 1 and 2.
for example:
-- this script does
-- absolutely nothing usefull
--
-- 
select * from table ;     

I do beleive its in a manual somewhere.

I think unify should standardize their comments or provide all comment
methods in any source file (including data integrity subsystem sources)

Len Jaffe

>Many Thanks 
>
>Kevin Meek
>Comprehensive Technologies Int'l Inc.
>2121 Crystal Drive   Suite #103
>Arlington,  VA  22202
>uunet!cit1!kmeek  OR cti1!kmeek@uunet.uu.net


--
 Leonard A.  Jaffe, Work: 216/591-0240
 CS Dept.        :  hawkwind@math-cs.kent.edu 
 It isn't easy being cheesey - Chester Cheatah

sk@Unify.Com (Sandeep Kundra) (07/11/90)

In article <216@cti1.UUCP> kmeek@cti1.UUCP (Kevin Meek) writes:
>Is there anything in the SQL standards about how comments can
>be inserted into an SQL script?  And if so at what level of SQL
>compliance is this instituted. 
>
>If there is no standard does anyone using UNIFY 2000 know if/how
>you can insert comments into a Unify SQL script.
>
>I have tried C style and Shell style comments but neither seem to work.
>
>Many Thanks 
>
>Kevin Meek
>Comprehensive Technologies Int'l Inc.
>2121 Crystal Drive   Suite #103
>Arlington,  VA  22202
>uunet!cit1!kmeek  OR cti1!kmeek@uunet.uu.net


Comments in Unify 2000 scripts are indicated by "--" at the beginning of the
line.  ie

--     
-- This SQL is run on Thursday's to create the transfer table.
--
   Create table trans......

-- 
Sandeep Kundra, Unify Corporation, Sacramento, CA.
#include <standard.disclaimer>  |  This opinion .....               |
                                |      .... No deposit, No return.  |

jeff@Unify.Com (Jeff Mischkinsky) (07/11/90)

In article <1990Jul11.023801.9596@math-cs.kent.edu> hawkwind@kentvax.kent.edu (Len Jaffe) writes:
>In article <216@cti1.UUCP> kmeek@cti1.UUCP (Kevin Meek) writes:
>>Is there anything in the SQL standards about how comments can
>>be inserted into an SQL script?  And if so at what level of SQL
>>compliance is this instituted. 
>>
>>If there is no standard does anyone using UNIFY 2000 know if/how
>>you can insert comments into a Unify SQL script.
>>
>>I have tried C style and Shell style comments but neither seem to work.
>>
>Unify 2000 uses double dashes in clumns 1 and 2.
>for example:
>-- this script does
>-- absolutely nothing usefull
>--
>-- 
>select * from table ;     
>
>I do beleive its in a manual somewhere.
>
>I think unify should standardize their comments or provide all comment
>methods in any source file (including data integrity subsystem sources)

The -- comment convention is specified in the ANSI SQL standard (X3.135-89).
Anyone who claims to be ANSI compliant should accept this notation.
Anything else is a non-standard vendor extension.

(C-style and shell style comments are idiosyncratic to C and unix.
 I wouldn't expect DB2 or a cobol-style system to understand them.)

>
>Len Jaffe
>
>>Many Thanks 
>>
>>Kevin Meek
>>Comprehensive Technologies Int'l Inc.
>>2121 Crystal Drive   Suite #103
>>Arlington,  VA  22202
>>uunet!cit1!kmeek  OR cti1!kmeek@uunet.uu.net
>
>
>--
> Leonard A.  Jaffe, Work: 216/591-0240
> CS Dept.        :  hawkwind@math-cs.kent.edu 
> It isn't easy being cheesey - Chester Cheatah


-- 
Jeff Mischkinsky		internet: jeff@unify.UUCP
Unify Corporation		          ...!{pyramid,csusac}!unify!jeff
3870 Rosin Court		voice: (916) 920-9092 fax: (916) 921-5340
Sacramento, CA 95834		ICBMS: 38 38 40 N / 120 28 10 W

dag@fciva.FRANKLIN.COM (Daniel A. Graifer) (07/11/90)

In article <216@cti1.UUCP> kmeek@cti1.UUCP (Kevin Meek) writes:
>Is there anything in the SQL standards about how comments can
>be inserted into an SQL script?  [...]
>
>If there is no standard does anyone using UNIFY 2000 know if/how
>you can insert comments into a Unify SQL script.
>[...]
>Kevin Meek
>Comprehensive Technologies Int'l Inc.
>2121 Crystal Drive   Suite #103
>Arlington,  VA  22202
>uunet!cit1!kmeek  OR cti1!kmeek@uunet.uu.net

I'm not sure about Unify 2000, but we are using Unify 4.0, which doesn't 
support comments in SQL.  

	1) Many systems which do support c-like comments also support 
	   #include, #if/#endif, etc. because they invoke the c-preprocessor.
	   The AGEN compiler for Accell does this.  You could certainly do
	   this yourself, especially if:
	2) You put your SQL queries in shell scripts as we do with most of ours.
	   This allows passing parameters to SQL.  Use the bourne shell <<
	   Input document facility:

			#shell script to produce monthly report 
			if [ $# != 2 ]
			then
				echo "Usage: $0 mm yy" >&2
				exit 1
			fi
			MM=$1
			YY=$2
			if [ $MM != 12 ]
			then
				NM=`expr $MM + 1`
				NY=$YY
			else
				NM=1
				NY=`expr $YY + 1`
			fi
			SQL<<EOF
			select ...
				where datefield >= $MM/01/$YY and datefield < $NM/01/$NY
				/
			EOF

	3) If you wanted to insert comments in the SQL part, but didn't want
	   to fool with cpp, (or you don't have the developer's toolkit which
	   I believe is where cpp is delivered) you could just pipe something
	   like the above throught grep -v '#'.

Hope this helps
Dan
-- 
Daniel A. Graifer			Franklin Mortgage Capital Corporation
uunet!dag@fmccva.franklin.com		7900 Westpark Drive, Suite A130
(703)448-3300				McLean, VA  22102

itkin@mrspoc.Transact.COM (Steven M. List) (07/12/90)

hawkwind@kentvax.kent.edu (Len Jaffe) writes:
>In article <216@cti1.UUCP> kmeek@cti1.UUCP (Kevin Meek) writes:
>>If there is no standard does anyone using UNIFY 2000 know if/how
>>you can insert comments into a Unify SQL script.
>>
>>I have tried C style and Shell style comments but neither seem to work.
>>
>Unify 2000 uses double dashes in clumns 1 and 2.
>for example:
>-- this script does
>-- absolutely nothing usefull
>--
>-- 
>select * from table ;     

>I do beleive its in a manual somewhere.

>I think unify should standardize their comments or provide all comment
>methods in any source file (including data integrity subsystem sources)

Does anyone besides Unify permit bang escapes to the operating system?
Granted that it's slower than built in comments, using

	!# comment

in SQL scripts is pretty safe.  I haven't checked all the other vendors,
but expect that they also permit shell escapes.
-- 
 +----------------------------------------------------------------------------+
 :                Steven List @ Transact Software, Inc. :^>~                  :
 :           Chairman, Unify User Group of Northern California                :
 :     {apple,coherent,limbo,mips,pyramid,ubvax}!itkin@guinan.Transact.COM    :

blm@6sceng.UUCP (Brian Matthews) (07/12/90)

In article <1990Jul11.023801.9596@math-cs.kent.edu> hawkwind@kentvax.kent.edu (Len Jaffe) writes:
|In article <216@cti1.UUCP> kmeek@cti1.UUCP (Kevin Meek) writes:
|>Is there anything in the SQL standards about how comments can
|>be inserted into an SQL script?
|Unify 2000 uses double dashes in clumns 1 and 2.
|for example:
|-- this script does
|-- absolutely nothing usefull

I don't have my documents here, but I believe that the standard says
that a comment can occur anywhere, is indicated by a --, and goes to
the end of the line (modulo quoting and such).  Of course standard
SQL is something of an oxymoron yet, so your mileage may vary.
-- 
Brian L. Matthews	blm@6sceng.UUCP

campbell@Thalatta.COM (Bill Campbell) (07/13/90)

I've sort of cheated here.  I pass all my SQL scripts through
gcc-cpp before SQL ever sees it (and RPT too) giving me full
#include file capabilities, macro expansion, C-comments, and
conditional scripts using #ifdef...

The same program is used for SQL and RPT calling the appropriate
program in UNIFY when the final script has been built.

This doesn't work with SQL when run interactively, but does for
all scripts run from shell scripts or UNIFY's SQL by Forms.
-- 
....microsoft--\                    Bill Campbell; Celestial Software
...uw-entropy----!thebes!camco!bill 6641 East Mercer Way
....fluke------/                    Mercer Island, Wa 98040
....hplsla----/                     (206) 232-4164