× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 12/30/2015 12:49 PM, Rob wrote:

insert into "Table" ( "Field1", "Field2" ) values ( "Data1", "Data2" ) ;

I get Column or global variable Data1 not found.

So of course quickly I realize that it is the double quotes in the
values.... and

insert into "Table" ( "Field1", "Field2" ) values ( 'Data1', 'Data2' ) ;

Works just fine. So my thinking here is that DB2 sees anything in
double quotes where there is data as a Global Variable.

It's more subtle than this blanket statement suggests.

The double quotes are the way we tell DB2 to consider the item between
the quotes to be an identifier in mixed case.

Without the double quotes, we'd be telling DB2 to consider the item an
identifier to be folder to upper case.

With single quotes, we are telling DB2 that the item is a literal.

Now, we don't normally think of putting the contents of one column into
another, but this is absolutely legal, and puts the contents of COLUMN5
into COLUMN1:

update TABLE set COLUMN1 = COLUMN5;

If the identifiers (table name, column names) were created in mixed
case, as your example was, I'd use this:

update "Table1" set "Field1" = "Field5";

Of course, your example was an insert, and a list of column names in the
VALUES() is... unusual to say the least but a Global Variable is typical
enough. And because one can create a Global Variable in mixed case
(just like any other DB2 object) we need a way to tell DB2 that we want
to specify the mixed case form of the identifier, so:

insert into "Table" ("Field1", "Field2") values("Global1", "Global2");

More reasonable example names for Global1 and 2 might be TransactionDate
and BatchNumber.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.