[Gambas-user] indexes in database

Benoit Minisini gambas at ...1...
Wed Jun 14 23:15:44 CEST 2006


On Wednesday 14 June 2006 15:42, javier romero wrote:
> I need to create a table named "Tabla010" in this table i need to indexed
> by name, I have this in my proyect:
>
>
> WITH Mdb
>        .HCliente=.MysqlDB.Tables.Add(nombre)
>        .HCliente.Fields.Add("010ruc", gb.String, 11,0)
>        .HCliente.Fields.Add("010nom", gb.String, 45)
>        .Hcliente.Fields.Add("010dir", gb.String, 45)
>        .Hcliente.Fields.Add("010loc", gb.String, 20)
>        .Hcliente.Fields.Add("010te1", gb.String, 7, 0)
>        .Hcliente.Fields.Add("010te2", gb.String, 7, 0)
>        .Hcliente.Fields.Add("010cor", gb.String, 30)
>        .Hcliente.Fields.Add("010www", gb.String, 30)
>        .Hcliente.Fields.Add("010fac", gb.String, 1)
>        .Hcliente.Fields.Add("010rhp", gb.string, 1)
>        .Hcliente.Fields.Add("010con", gb.String, 45)
>        .Hcliente.Fields.Add("010car", gb.String, 45)
>        .Hcliente.Fields.Add("010tce", gb.String, 1, 0)
>        .Hcliente.Fields.Add("010cel", gb.String, 8, 0)
>        .Hcliente.Fields.Add("010nex", gb.String, 8, 0)
>        .Hcliente.Fields.Add("010cop", gb.String, 30)
>        .Hcliente.Fields.Add("010pdt", gb.String, 14)
>        .Hcliente.Fields.Add("010usu", gb.String, 8)
>        .Hcliente.Fields.Add("010cla", gb.String, 9)
>        .Hcliente.PrimaryKey=["010ruc"]
>        .Hcliente.Indexes.Add("Alt010_1", "010nom", FALSE)
>        .HCliente.Update
>   END WITH
>
> When run an error sent me and says "Index already exist: Tabla010.Alt010_1"
> Why if its a new Table?, when i comment the line
> ".Hcliente.Indexes.Add("Alt010_1", "010nom", FALSE)" the Table is created
> ok.
>
> Thanks
> Javier

There is a bug in the mysql driver that returns that an index exists if the 
underlying table does not exist. So the error message is false.

You must create your index after having created the table, i.e. after having 
called Mdb.HCLiente.Update.

Regards,

-- 
Benoit Minisini




More information about the User mailing list