FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Change of structure during development
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Change of structure during development
Posted: Fri May 26, 2017 09:37 PM

Hey,

Every couple of day, while my program grows, I have to change (add) more fields into the online database

Now I go into my phpMyadmin and change the structure and continue.
I've seen that there are functions to change it from FWH.

What approach do you mostly take ?

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 582
Joined: Fri Oct 07, 2005 02:17 PM
Re: Change of structure during development
Posted: Sat May 27, 2017 01:49 AM

Hi Marc

Sorry for my bad english, i use this code for add columns

if fieldpos("c_emdirec") < 1
gci_sqlexe("ALTER TABLE gci_empresas ADD c_emdirec CHAR(60) DEFAULT '' NOT NULL AFTER c_emname2")
gci_sqlexe("ALTER TABLE vcnewbos ADD tas_detrac NUMERIC(5,2) DEFAULT '0.00' NOT NULL AFTER des_newbos")
end if

if you need change colums this code :

        if len(cdo_cuenta) == 12
           gci_sqlexe(&quot;ALTER TABLE vcpatpcg MODIFY cdo_cuenta CHAR(14) DEFAULT '' NOT NULL&quot;)
        end if

gci_sqlexe is my function to invoke mysql in ADO or TDolphin maybe have other names

Enrrique Vertiz Pitta

Lima-Peru

xHb 1.23.1026X, Fwh 25.01, BCC74, MySQL 8.0.X, SQLLIB 1.9m
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Change of structure during development
Posted: Sat May 27, 2017 06:57 AM
FWH implementation

Examples:
Adding a numeric column

Code (fw): Select all Collapse
oCn:AddColumn( "mytale", { "columnname", 'N', 10, 2 } ) --> lSuccess


Altering a column. Assuming we have a column with name "member_name" with width 20. We want to alter the width as 30
Code (fw): Select all Collapse
oCn:AlterColumn( "mytable", { "member_name", 'C', 30, 0 }


Second parameter is like the column specification in our familiar DBF structure.

Rename a column:
Code (fw): Select all Collapse
oCn:RenameColumn( "mytable", "oldcolumnname", "newcolumnname" ) --> lSucess


If we have a table without primary key and
(a) we want to add an auto-increment field as primary key
Code (fw): Select all Collapse
oCn:AddAutoInc( "tablename", "columnname" )

(b) we want to make one of the existing columns as primary key
Code (fw): Select all Collapse
oCn:MakePrimaryKey( "tablename", "columnname" )
Regards



G. N. Rao.

Hyderabad, India
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Change of structure during development
Posted: Sat May 27, 2017 11:35 AM

Exactly what I needed. Thanks all.

Marc Venken

Using: FWH 23.08 with Harbour

Continue the discussion