On Sat, Jun 9, 2012 at 9:02 AM, Sahananda (Jon) Wolfers
<[email protected]> wrote:
> small hint for sample programs, sql ignores lineends as white-space within
> queries so for example:
>
>> sql = "CREATE TABLE contacts (" || .endOfLine || -
>> " id integer primary key," || .endOfLine || -
>> " fName text not null default ''," || .endOfLine || -
>> " lName text not null default ''," || .endOfLine || -
>> " mName text not null default ''," || .endOfLine || -
>> " nickName text not null default ''," || .endOfLine || -
>> " title text not null default 'Ms.'" || .endOfLine || -
>> ");"
>
>
> could read
>
>> sql = "CREATE TABLE contacts ( " -
>> " id integer primary key, " -
>> " fName text not null default '', " -
>> " lName text not null default '', " -
>> " mName text not null default '', " -
>> " nickName text not null default ''," -
>> " title text not null default 'Ms.' " -
>> "); "
Jon,
I removed all the .endOfLine stuff and it turned out the I wanted the
.endOfLine.
Here's why. In the ooSQLite package there is a command line shell
program, ooSQLite3.exe on Windows and oosqlite3 for the unixes.
I use ooSQLite3.exe a lot and it has a command: .schema that displays
the schema of the opened database. I'm used to seeing the schema
display something like:
sqlite> .schema
CREATE TABLE addr_type (
id INTEGER PRIMARY KEY,
type TEXT NOT NULL DEFAULT 'Home'
);
CREATE TABLE contacts (
id INTEGER PRIMARY KEY,
lName TEXT NOT NULL,
fName TEXT NOT NULL DEFAULT '',
mName TEXT NOT NULL DEFAULT '',
nickName TEXT NOT NULL DEFAULT '',
title TEXT NOT NULL DEFAULT 'Ms.'
);
but I thought that the command line shell was formatting the table
definition. It turns out that it is not. So when I removed the
.endOfLine I got this:
Enter SQL statements terminated with a ";"
sqlite> .schema
CREATE TABLE addr_type ( id INTEGER PRIMARY KEY, type TEXT NOT
NULL DEFAULT 'Home' );
CREATE TABLE contacts ( id INTEGER PRIMARY KEY, lName TEXT NOT
NULL, fName TEXT NOT NULL DEFAULT '', mNa
me TEXT NOT NULL DEFAULT '', nickName TEXT NOT NULL DEFAULT '',
title TEXT NOT NULL DEFAULT 'Ms.' );
CREATE TABLE inet_addr ( inet_id INTEGER PRIMARY KEY, inet_addr
TEXT NOT NULL, contact_id INTEGER NOT NULL
, type_id INTEGER NOT NULL, FOREIGN KEY(contact_id) REFERENCES
contacts(id) ON UPDATE CASCADE ON DELETE RE
STRICT, FOREIGN KEY(type_id) REFERENCES addr_type(id) ON UPDATE
CASCADE ON DELETE RESTRICT );
CREATE TABLE phone_addr ( phone_id INTEGER PRIMARY KEY, number
TEXT NOT NULL, area_code TEXT NOT NULL DEFA
ULT '', extension TEXT NOT NULL DEFAULT '', contact_id INTEGER NOT
NULL, type_id INTEGER NOT NULL, FOREI
GN KEY(contact_id) REFERENCES contacts(id) ON UPDATE CASCADE ON
DELETE RESTRICT, FOREIGN KEY(type_id) REFERE
NCES addr_type(id) ON UPDATE CASCADE ON DELETE RESTRICT );
CREATE TABLE street_addr ( street_id INTEGER PRIMARY KEY, street1
TEXT NOT NULL, street2 TEXT NOT NULL DEF
AULT '', city TEXT NOT NULL DEFAULT '', state TEXT NOT NULL
DEFAULT '', zip TEXT NOT NULL DEFAULT '', co
ntact_id INTEGER NOT NULL, type_id INTEGER NOT NULL, FOREIGN
KEY(contact_id) REFERENCES contacts(id) ON UP
DATE CASCADE ON DELETE RESTRICT, FOREIGN KEY(type_id) REFERENCES
addr_type(id) ON UPDATE CASCADE ON DELETE R
ESTRICT );
sqlite> .e
So, I put the .endOfLine back in and added a comment on why I had it that way.
--
Mark Miesfeld
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel