Change of structure during development

Change of structure during development

Postby Marc Venken » Fri May 26, 2017 9: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.04 with Harbour
User avatar
Marc Venken
 
Posts: 1397
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Change of structure during development

Postby Enrrique Vertiz » Sat May 27, 2017 1: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("ALTER TABLE vcpatpcg MODIFY cdo_cuenta CHAR(14) DEFAULT '' NOT NULL")
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 24.02, MySQL 8.0.X, SQLLIB 1.9m
Enrrique Vertiz
 
Posts: 525
Joined: Fri Oct 07, 2005 2:17 pm
Location: Lima - Peru

Re: Change of structure during development

Postby nageswaragunupudi » Sat May 27, 2017 6:57 am

FWH implementation

Examples:
Adding a numeric column

Code: Select all  Expand view

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: Select all  Expand view

oCn:AlterColumn( "mytable", { "member_name", 'C', 30, 0 }
 


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

Rename a column:
Code: Select all  Expand view

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: Select all  Expand view

oCn:AddAutoInc( "tablename", "columnname" )
 

(b) we want to make one of the existing columns as primary key
Code: Select all  Expand view

oCn:MakePrimaryKey( "tablename", "columnname" )
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10471
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Change of structure during development

Postby Marc Venken » Sat May 27, 2017 11:35 am

Exactly what I needed. Thanks all.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1397
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 50 guests