[Gambas-user] Add field

Werner Staudacher gambas-user at lists.sourceforge.net
Sat Mar 4 15:39:24 CET 2006


R. Stormo schrieb:

>I want to add one more field to a table , on the fly, without using database
>manager. How is this done?
>My thinking was.
>dim r as result
>dim htable as table
>
>try r = $conn.exec("select checkfield from mytable")
>if error.code <>0 then
>    htable= $conn.tables["mytable"]
>    htable.fields.add("checkfield",gb.integer)
>    htable.update()
>end if
>
>This is not working as it should , I get error "Table already exist"
>
>
>  
>
The easy way is DDL (Data Definition Language)
I don't know if mySql can do it, i know only oracle and mssql.
The Syntax is like  "Alter table 'tablename' create 'fieldname' Type not 
null... etc...."

Regards, Staudi





More information about the User mailing list