Subject Re: [IB-Conversions] problem with sql2gdb
Author Marcelo
Helen Borrie wrote:

> At 12:51 AM 19-11-00 +0000, you wrote:
> >I tryed to convert my .mdb to interbase's .sql with sql2gdb but all
> >the INSERT's I got are as abobe:
> >
> >INSERT INTO "mytable" (
> > "field1",
> > "field2",
> > "field3",
> >) VALUES (
> > :"field1",
> > :"field2",
> > :"field3",
> >)
> >;
> >
> >That ist, I don't get the values but only the names preceding of ':'.
>

The sql2gdb wizard uses this script as a "template" to move records later on.
The quotes can be turned on or off from the Customizations step (but the
wizard will use other mangling methods). The colon before the field name
means that it is a placeholder. For example, if you want not to move a field,
you can modify the script to look like:

insert into mytable (
"field1",
"field3'
) values (
:"field1",
:"field3"
)

The record insertion will then use the DEFAULT expression defined for the
field, NULL, or raise an exception, which gets reported later on.

>
> Unless you want your column names to be case-sensitive, or you want to use
> reserved words as column names, avoid the quotes when you define the
> columns in your metadata.
>
> In IB 6, double-quotes are not legal syntax for delimiting values.

True, true, true; use simple quotes for delimiting values. However, the
quotes are kept because they are simple placeholders; if you remove the
quotes around the field names, you should remove them from the value
placeholders, too:

insert into mytable (
field1
) values (
:field1
)

>
> If you have made your column names case-sensitive, then you are stuck with
> putting them around the field list to avoid having InterBase store them as
> uppercase.

Yes, and case-sensitivity is, in my opinion, a pain, at least for data
modeling (what's the different between product and Product?).

However, the option is *on* by default, because it's the easiest way to
handle spaces; sql2gdb was written with the idea of producing as little
confusion as possible to MS SQL and MS Access users, where it's legal (and
painfully common) to use spaces in identifier names, and then put them
between brackets. Queries simply need to be rewritten like so:

select [emp name]
from [employees]

translates to

select "emp name"
from "employees"

If you're used to plain, good ol' EMP_NAME and EMPLOYEES, using quotes is a
pain; if you come from Access and MSSQL, it keeps things more consistent.

Marcelo