SQL long field names

45 views
Skip to first unread message

Henry Fidler

unread,
Jul 4, 2021, 5:39:43 AMJul 4
to

I try to connect, via SQL objects, to an external internet host MySQL, and build from it local dbf files.
The external MySQL has file names longer then 10, so DbCreate() truncate them.
Any idea how to solve the problem?

Henry

Wolfgang Riedmann

unread,
Jul 4, 2021, 9:30:04 AMJul 4
to
Hi Henry,
if you are using your own dbServer subclass you could maintain an
internal array of mapped fieldnames.

I would use the first 8 characters of every fieldname and than add a 2
characters numeric suffix, and store that in some external
configuration file.
Then, when opening the DBF, read the aliases from your configuration
file and map that in a subclassed
FieldGet()/FieldPut()/IVarGet()/IVarPut() method.

But there is also something like this already built in: please look at
the DBFieldInfo() function or the DBServer:FieldInfo() method, using
the constant DBS_ALIAS should do what you need (I have not tested that,
so you have to try it yourself).

Wolfgang


--

Henry Fidler

unread,
Jul 12, 2021, 6:52:32 AMJul 12
to
Wolfgang many thanks.

An internal array could be a logical idea, until someone changes the original names of the SQL in the host.
Dbs_Alias gave me little help. After assigning FieldInfo(Dbs_Alias, ...), the next time the file is opened, the alias has back the field name.

I hoped the SQL method will have a built in possibility to solve the problem.

Interesting: dbCreate() truncate the original field´s names, and build a db with few fields which have the same name.

Henry

Wolfgang Riedmann

unread,
Jul 12, 2021, 10:23:40 AMJul 12
to
Hi Henry,

> An internal array could be a logical idea, until someone changes the
> original names of the SQL in the host. Dbs_Alias gave me little
> help. After assigning FieldInfo(Dbs_Alias, ...), the next time the
> file is opened, the alias has back the field name.

of course, this is not a permanent option, so you have to store the
aliases somewhere in a persistent manner

> Interesting: dbCreate() truncate the original field´s names, and
> build a db with few fields which have the same name.

the DBF data structure limits the field names to 10 bytes, so changing
that in the format would break backwards compatibility.
AFAIK FoxPro has done something like this, but they have have an
external file with the supplemental informations.

Wolfgang

--

Reply all
Reply to author
Forward
0 new messages