[Gambas-user] RE: Database Field Names

ron ronstk at ...239...
Wed Apr 19 15:36:40 CEST 2006


On Wednesday 19 April 2006 11:36, GuruLounge - MailLists wrote:
> If you're stuck with lowercase in field names you could always get a
> little bit creative and try to store the field names in an optional
> field the keeps the case.  Maybe even create a separate table just for
> field names and create unique field names based on that.
> 
> Might be a b*tch for search and the like but it could be a work-around.
> 
> HTH,
> Jeff

Yes it is creative with extra field to keep the orginal name but you miss the point
The orginal field is on a db and case sensitive or the creator want it that way.
Gambas should then use the extra field to get the fake lowercase name for
a field with mixed case, stupid a simple locase("FieldName") does it.

Think about SET FieldName1,FieldName2 IN MyTable Value(1,2)
and for FieldName1 SELECT mixname FROM lookuptable WHERE locase='fieldname1'
and same for FieldName2.

That must be done in the above SQL line with the SET 
Gambas can do the lookup but can't use it because gambas convert that name 
again to lower case and can't access the mixed case field.

When I do a select query and type 'FieldName' and the database has 'fieldname'
but accept it then it is fine.
If the DB engine does not accept it I have to enter as 'fieldname'
The same when I type 'fieldname' and the DB has 'FieldName'

For the topic starter it happens during the creation of the table.
Then nothing should change the case he, you or I decide to use.
Some people use as accented as 'field_name' other' FieldName' and that is 
the decision of the creator/programmer and not of the software he use for it.

Maybe a Connection option to use lowercase to DB handler for fieldnames
so the programmer can use mixed case on his wish but lower to DB.
But consider the Column caption will be lowercase that way to on read.

In MS Access you could enter the fieldname in mixed case and so the caption
on display is also mixed.
For extreem short names as 'adr' or 'fld_addres' or those with prefix as 
'phpbb2_postal_address' you could enter a separate caption to use in the 
table designer for the tableview and field labels on the forms.
No that is not the same as SELECT 'phpbb2_postal_address' AS Address FROM table

It is the programmer that should use the correct case if the DB engine is case
sensitive. The alias with _mixcase AS MixCase_ can help.


Ron




More information about the User mailing list