Re: How to specify column header titles in a SQL CREATE TABLE statement?

From: Knut Stolze <stolze_at_de.ibm.com>
Date: Mon, 18 Oct 2004 11:58:17 +0200
Message-ID: <cl043p$2ka$1_at_fsuj29.rz.uni-jena.de>


Rhino wrote:

> However, I don't get quite the same results that you did from your two
> queries. I am running DB2 V7.2.7 on Windows XP.
>
> Given:
> db2 "select lastname as ""Lastname"" from employee where lastname like
> 'L%'"
>
> I get the following when I execute it on the DB2 command line:
> SQL0100N The string constant beginning with ""Lastname from employee where
> lastname like 'L%'" does not have an ending string delimiter.
> SQLSTATE=42603
>
> I can eliminate this error by putting *three* consecutive quotes after the
> alias, i.e.
> db2 "select lastname as ""Lastname""" from employee where lastname like
> 'L%'"
>
> This results in:
> Lastname
> -----------
> LUCCHESSI
> LUTZ
> LEE
>
> as you predicted.
>
> However, when I execute (on the DB2 command line):
> db2 "select lastname as \"Lastname\" from employee where lastname like
> 'L%'"
>
> I get:
> Lastname
> -----------
> LUCCHESSI
> LUTZ
> LEE
>
> just as you described.
>
> In any case, the original poster probably knows more now about column
> headings that he really wanted to know ;-)

You might want to look at the documentation for the DOS command prompt (or whatever you use) to figure out what it does with the quotes. A Unix shell, given

  "abc \" def"

will pass the following string to the application

   abc " def

The DOS command prompt works on the parameters as well somehow, and you have to counter that to get the " to DB2.

-- 
Knut Stolze
Information Integration
IBM Germany / University of Jena
Received on Mon Oct 18 2004 - 11:58:17 CEST

Original text of this message