Page 1 of 1

Mysql recover values usaing field names

Posted: Mon Nov 18, 2024 6:08 pm
by PAUL SIMM
How can I recover values from a SELECT using the field name and not its position in th array?

oCn :=maria_Connect( cHost,cUser,cDb,cPwd )

IF oCn=NIL
msgwait("Error conectando con eventos en la nube","")
return nil
ENDIF

cQwery:="SELECT * FROM proforma"
oRs := oCn:RowSet( cQwery)
MSGINFO(oRs:FieldGet(5)) //WORKS SHOWS CONTENT OF 1ST FIELD DESCRIP
MSGINFO(oRs:FieldName("DESCRIP")) //DOSE NOT WORK

oCn:Close()

RETURN NIL
****************************************************************************************
/*
CREATE TABLE `proforma` (
`UPDATED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`ID` int(6) NOT NULL AUTO_INCREMENT,
`NO_PEDIDO` int(13) DEFAULT NULL,
`UNIDADES` int(4) DEFAULT NULL,
`DESCRIP` varchar(50) DEFAULT NULL,
`VAL_UNI` float(9,2) DEFAULT NULL,
`VAL_TOT` float(9,2) DEFAULT NULL,
`DIVISA` varchar(3) DEFAULT NULL,
`FECHA` date DEFAULT NULL,
`CATEGORIA` int(6) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=62706502 DEFAULT CHARSET=latin1;
*/

Re: Mysql recover values usaing field names

Posted: Mon Nov 18, 2024 7:01 pm
by nageswaragunupudi

Code: Select all | Expand

? oRs:FieldGet( 5 )  // works
? oRs:DESCRIP  // works. Case not sensitive
? oRs:Fields( "DESCRIP" ):Value // works. Ado syntax compatible
 

Re: Mysql recover values usaing field names

Posted: Thu Nov 21, 2024 9:42 am
by PAUL SIMM
I found oRs:DESCRIP Works

Re: Mysql recover values usaing field names

Posted: Thu Nov 21, 2024 11:35 am
by nageswaragunupudi
for modifying and editing you can use:

Code: Select all | Expand

oRs:descript := cNewValue
oRs:fetcha := date()
// .....
oRs:Save()