Put Hash data into a dbf

Put Hash data into a dbf

Postby Marc Venken » Mon May 24, 2021 10:06 pm

I was able to get a Hash, but not yet able to save the items to a dbf, since a hash is complex for me.

I tried to use todbf from xbrowser, but as far as I have been reading that is not supported yet.

It would be perfect is all elements from the hash can be converted to a dbf field. That I can use this for further use.

A Hashtodf functions is not in FW right ?
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1426
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Put Hash data into a dbf

Postby nageswaragunupudi » Tue May 25, 2021 8:20 am

FW_RecToHash()
FW_HashToRec( hHash )
Regards

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

Re: Put Hash data into a dbf

Postby hmpaquito » Tue May 25, 2021 8:30 am

cJSON := hb_jsonEncode( xValue [, lHuman] )

After save cJSON string in memo field

To Restore:

nLengthDecoded := hb_jsonDecode( cJSON, @xValue )


From https://www.kresin.ru/en/hrbfaq_3.html
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: Put Hash data into a dbf

Postby nageswaragunupudi » Tue May 25, 2021 9:20 am

For storing a hash value in a memo field, you suggested converting to Json and save and then read the Json and convert back the Json value to hash.
Nice, but in this process, all values of the hash are converted to character values.

For example, consider this hash.
{ "Name" => "John", "Age" => 30, "DOB" => {^ 1991/02/02 } }
When we conver this hash to json and back, dob is converted to character type.

I suggest:

Storing:
Code: Select all  Expand view

FIELD->MEMOFIELD := FW_ValToExp( hHash )
 


Reading back to hash:
Code: Select all  Expand view

hHash := &( FIELD->MEMOFIELD )
 

In the resulting hash, dob's valtype is "D".
Regards

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

Re: Put Hash data into a dbf

Postby hmpaquito » Tue May 25, 2021 2:22 pm

Thks
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: Put Hash data into a dbf

Postby Marc Venken » Wed May 26, 2021 3:35 pm

For some hashes, the more easy once, i have no problem to write to dbf or edit them en write them.
Mostly a name and a data

for the complex one that I retrieve from a API it's a other thing. On the Spanisch forum there was recently (Jan 2021) a topic to have a hash to a sql database, and that that function would go into FWH

I want this hashdata to go into a dbf, but the hash is complex... (just 2 items from a shop)

I want all items insite a dbf for reasons of compare the my dbf, but inside the hash there are extra array's enz...

like

"image_alt":["","","","","","","","","","","",""]

"images":["bcwu03w.jpg","bcwu03w_black-pure.jpg","bcwu03w_candy-pink.jpg","bcwu03w_desert.jpg","bcwu03w_elephant-grey.jpg","bcwu03w_forest-green.jpg","bcwu03w_grey-fog.jpg","bcwu03w_hawaiian-blue.jpg","bcwu03w_heather-asphalt.jpg","bcwu03w_heather-dark-green.jpg","bcwu03w_heather-grey.jpg","bcwu03w_heather-mid-grey.jpg"]

Maybe there is already a function for the more complex hashes (i didn't find it) or could not use it.

Hash/

{"numRows":1182,"numPages":591,"pageNumber":0,"startIndex":0,"endIndex":2,"totalValue":"10819097.2000","totalPurchaseValue":"0.0000","totalMargin":"10819097.2000","totalQuantity":306361,"totalPhysicalQuantity":54,"totalMinimumQuantity":0,"lowestPrice":"0.0000","highestPrice":"365.0300","data":[{"uprid":"543","productId":543,"stockId":-1,"referenceId":0,"isBundle":0,"bundledProducts":[],"status":1,"quantity":"400","maximumQuantity":null,"ean":"","sku":"","model":"BCWU03W","hsCode":null,"name":"#Hoodie","price":"13.4280","taxClassId":"3","taxRate":"21.0000","isPhysical":"1","isDigital":"0","isQuotation":"1","url":"promotiekleding\/sweaters\/sweaters-met-kap\/hoodie","urlAbs":"https:\/\/www.maveco-webshop.be\/promotiekleding\/sweaters\/sweaters-met-kap\/hoodie","attributesString":"","backOrder":0,"onHome":0,"layover":1,"configurationAllowCheckout":1,"configurationStockCheck":0,"attributes":[],"description":"Uniseks <br> French Terry <br> Lange mouwen <br> Hooded <br> Regular fit <br> Voorgekrompen ringgesponnen katoen <br> Zijnaden <br> Gemakkelijke branding: geen B&C label <br> Binnenkant Single Jersey halfmoon in rug <br> Ongeborstelde stof <br> Sterke stof <br> Zacht handgevoel <br> Glad en gelijkmatig oppervlak <br> In zijnaad: Zacht satijnlabel","addonInstagramEnabled":"0","addonInstagram":"0","addonOcsEnabled":"0","dateAdded":"0000-00-00 00:00:00","lastModified":"2020-09-11 16:41:37","descriptions":{"description":"Uniseks <br> French Terry <br> Lange mouwen <br> Hooded <br> Regular fit <br> Voorgekrompen ringgesponnen katoen <br> Zijnaden <br> Gemakkelijke branding: geen B&C label <br> Binnenkant Single Jersey halfmoon in rug <br> Ongeborstelde stof <br> Sterke stof <br> Zacht handgevoel <br> Glad en gelijkmatig oppervlak <br> In zijnaad: Zacht satijnlabel","extra":"","intro":" 280 g\/m"},"images":["bcwu03w.jpg","bcwu03w_black-pure.jpg","bcwu03w_candy-pink.jpg","bcwu03w_desert.jpg","bcwu03w_elephant-grey.jpg","bcwu03w_forest-green.jpg","bcwu03w_grey-fog.jpg","bcwu03w_hawaiian-blue.jpg","bcwu03w_heather-asphalt.jpg","bcwu03w_heather-dark-green.jpg","bcwu03w_heather-grey.jpg","bcwu03w_heather-mid-grey.jpg"],"image_alt":["","","","","","","","","","","",""],"discounts":{"name":"0","groupDiscount":"0.00","groupDiscountCategory":"0.00","groupDiscountProduct":"0.00"},"category":{"id":"888963","name":"Sweaters met kap","categoryIds":"888963","cPath":"73_888904_888963"},"quantities":{"quantity":"400","physicalQuantity":"0","minimumQuantity":"0","maximumQuantity":null,"externalQuantity":"0","quantityStep":"1","trackQuantity":"1"},"prices":{"basePrice":"14.9200","normalPrice":"14.9200","price":"13.4280","specialPrice":"13.4280","purchasePrice":"0.0000"},"manufacturer":{"id":46,"name":"B&amp;C","image":"bc.jpg-preview72.jpg"},"dimensions":{"type":"0","width":0,"height":0,"area":0,"weight":0},"reviews":{"count":0,"avg":0},"resources":[],"addons":{"multicatalog":{"enabled":false},"layover":{"enabled":true}}},{"uprid":"561","productId":561,"stockId":-1,"referenceId":0,"isBundle":0,"bundledProducts":[],"status":1,"quantity":"400","maximumQuantity":null,"ean":"","sku":"","model":"BCWW04W","hsCode":null,"name":"#Hoodie Sweat \/Women","price":"13.4280","taxClassId":"3","taxRate":"21.0000","isPhysical":"1","isDigital":"0","isQuotation":"1","url":"promotiekleding\/dames\/dames-sweaters--fleece\/hoodie-sweat-women","urlAbs":"https:\/\/www.maveco-webshop.be\/promotiekleding\/dames\/dames-sweaters--fleece\/hoodie-sweat-women","attributesString":"","backOrder":0,"onHome":0,"layover":1,"configurationAllowCheckout":1,"configurationStockCheck":0,"attributes":[],"description":"French Terry <br> Lange mouwen <br> Hooded <br> Regular fit <br> Voorgekrompen ringgesponnen katoen <br> Zijnaden <br> Gemakkelijke branding: geen B&C label <br> Binnenkant Single Jersey halfmoon in rug <br> Ongeborstelde stof <br> Sterke stof <br> Zacht handgevoel <br> Glad en gelijkmatig oppervlak <br> In zijnaad: Zacht satijnlabel","addonInstagramEnabled":"0","addonInstagram":"0","addonOcsEnabled":"0","dateAdded":"2020-09-11 16:41:47","lastModified":"2020-09-11 16:41:47","descriptions":{"description":"French Terry <br> Lange mouwen <br> Hooded <br> Regular fit <br> Voorgekrompen ringgesponnen katoen <br> Zijnaden <br> Gemakkelijke branding: geen B&C label <br> Binnenkant Single Jersey halfmoon in rug <br> Ongeborstelde stof <br> Sterke stof <br> Zacht handgevoel <br> Glad en gelijkmatig oppervlak <br> In zijnaad: Zacht satijnlabel","extra":"","intro":" 280 g\/m"},"images":["bcww04w.jpg","bcww04w_black-pure.jpg","bcww04w_candy-pink.jpg","bcww04w_desert.jpg","bcww04w_elephant-grey.jpg","bcww04w_forest-green.jpg","bcww04w_grey-fog.jpg","bcww04w_hawaiian-blue.jpg","bcww04w_heather-asphalt.jpg","bcww04w_heather-dark-green.jpg","bcww04w_heather-grey.jpg","bcww04w_heather-mid-grey.jpg"],"image_alt":["","","","","","","","","","","",""],"discounts":{"name":"0","groupDiscount":"0.00","groupDiscountCategory":"0.00","groupDiscountProduct":"0.00"},"category":{"id":"888955","name":"Dames Sweaters & Fleece","categoryIds":"888955","cPath":"73_888940_888955"},"quantities":{"quantity":"400","physicalQuantity":"0","minimumQuantity":"0","maximumQuantity":null,"externalQuantity":"0","quantityStep":"1","trackQuantity":"1"},"prices":{"basePrice":"14.9200","normalPrice":"14.9200","price":"13.4280","specialPrice":"13.4280","purchasePrice":"0.0000"},"manufacturer":{"id":46,"name":"B&amp;C","image":"bc.jpg-preview72.jpg"},"dimensions":{"type":"0","width":0,"height":0,"area":0,"weight":0},"reviews":{"count":0,"avg":0},"resources":[],"addons":{"multicatalog":{"enabled":false},"layover":{"enabled":true}}}]}
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1426
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Put Hash data into a dbf

Postby hmpaquito » Wed May 26, 2021 3:48 pm

Perhaps viewtopic.php?f=17&t=37597#p224751 from Cristobal Navarro master using HashToXml() .and. XmlToHash() methods
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: Put Hash data into a dbf

Postby nageswaragunupudi » Thu May 27, 2021 12:35 am

Very simple.

{"numRows":1182,"numPages":591,"pageNumber":0,"startIndex":0,"endIndex":2,"totalValue":"10819097.2000","totalPurchaseValue":"0.0000","totalMargin":"10819097.2000","totalQuantity":306361,"totalPhysicalQuantity":54,"totalMinimumQuantity":0,"lowestPrice":"0.0000","highestPrice":"365.0300","data":[{"uprid":"543","productId":543,"stockId":-1,"referenceId":0,"isBundle":0,"bundledProducts":[],"status":1,"quantity":"400","maximumQuantity":null,"ean":"","sku":"","model":"BCWU03W","hsCode":null,"name":"#Hoodie","price":"13.4280","taxClassId":"3","taxRate":"21.0000","isPhysical":"1","isDigital":"0","isQuotation":"1","url":"promotiekleding\/sweaters\/sweaters-met-kap\/hoodie","urlAbs":"https:\/\/www.maveco-webshop.be\/promotiekleding\/sweaters\/sweaters-met-kap\/hoodie","attributesString":"","backOrder":0,"onHome":0,"layover":1,"configurationAllowCheckout":1,"configurationStockCheck":0,"attributes":[],"description":"Uniseks <br> French Terry <br> Lange mouwen <br> Hooded <br> Regular fit <br> Voorgekrompen ringgesponnen katoen <br> Zijnaden <br> Gemakkelijke branding: geen B&C label <br> Binnenkant Single Jersey halfmoon in rug <br> Ongeborstelde stof <br> Sterke stof <br> Zacht handgevoel <br> Glad en gelijkmatig oppervlak <br> In zijnaad: Zacht satijnlabel","addonInstagramEnabled":"0","addonInstagram":"0","addonOcsEnabled":"0","dateAdded":"0000-00-00 00:00:00","lastModified":"2020-09-11 16:41:37","descriptions":{"description":"Uniseks <br> French Terry <br> Lange mouwen <br> Hooded <br> Regular fit <br> Voorgekrompen ringgesponnen katoen <br> Zijnaden <br> Gemakkelijke branding: geen B&C label <br> Binnenkant Single Jersey halfmoon in rug <br> Ongeborstelde stof <br> Sterke stof <br> Zacht handgevoel <br> Glad en gelijkmatig oppervlak <br> In zijnaad: Zacht satijnlabel","extra":"","intro":" 280 g\/m"},"images":["bcwu03w.jpg","bcwu03w_black-pure.jpg","bcwu03w_candy-pink.jpg","bcwu03w_desert.jpg","bcwu03w_elephant-grey.jpg","bcwu03w_forest-green.jpg","bcwu03w_grey-fog.jpg","bcwu03w_hawaiian-blue.jpg","bcwu03w_heather-asphalt.jpg","bcwu03w_heather-dark-green.jpg","bcwu03w_heather-grey.jpg","bcwu03w_heather-mid-grey.jpg"],"image_alt":["","","","","","","","","","","",""],"discounts":{"name":"0","groupDiscount":"0.00","groupDiscountCategory":"0.00","groupDiscountProduct":"0.00"},"category":{"id":"888963","name":"Sweaters met kap","categoryIds":"888963","cPath":"73_888904_888963"},"quantities":{"quantity":"400","physicalQuantity":"0","minimumQuantity":"0","maximumQuantity":null,"externalQuantity":"0","quantityStep":"1","trackQuantity":"1"},"prices":{"basePrice":"14.9200","normalPrice":"14.9200","price":"13.4280","specialPrice":"13.4280","purchasePrice":"0.0000"},"manufacturer":{"id":46,"name":"B&amp;C","image":"bc.jpg-preview72.jpg"},"dimensions":{"type":"0","width":0,"height":0,"area":0,"weight":0},"reviews":{"count":0,"avg":0},"resources":[],"addons":{"multicatalog":{"enabled":false},"layover":{"enabled":true}}},{"uprid":"561","productId":561,"stockId":-1,"referenceId":0,"isBundle":0,"bundledProducts":[],"status":1,"quantity":"400","maximumQuantity":null,"ean":"","sku":"","model":"BCWW04W","hsCode":null,"name":"#Hoodie Sweat \/Women","price":"13.4280","taxClassId":"3","taxRate":"21.0000","isPhysical":"1","isDigital":"0","isQuotation":"1","url":"promotiekleding\/dames\/dames-sweaters--fleece\/hoodie-sweat-women","urlAbs":"https:\/\/www.maveco-webshop.be\/promotiekleding\/dames\/dames-sweaters--fleece\/hoodie-sweat-women","attributesString":"","backOrder":0,"onHome":0,"layover":1,"configurationAllowCheckout":1,"configurationStockCheck":0,"attributes":[],"description":"French Terry <br> Lange mouwen <br> Hooded <br> Regular fit <br> Voorgekrompen ringgesponnen katoen <br> Zijnaden <br> Gemakkelijke branding: geen B&C label <br> Binnenkant Single Jersey halfmoon in rug <br> Ongeborstelde stof <br> Sterke stof <br> Zacht handgevoel <br> Glad en gelijkmatig oppervlak <br> In zijnaad: Zacht satijnlabel","addonInstagramEnabled":"0","addonInstagram":"0","addonOcsEnabled":"0","dateAdded":"2020-09-11 16:41:47","lastModified":"2020-09-11 16:41:47","descriptions":{"description":"French Terry <br> Lange mouwen <br> Hooded <br> Regular fit <br> Voorgekrompen ringgesponnen katoen <br> Zijnaden <br> Gemakkelijke branding: geen B&C label <br> Binnenkant Single Jersey halfmoon in rug <br> Ongeborstelde stof <br> Sterke stof <br> Zacht handgevoel <br> Glad en gelijkmatig oppervlak <br> In zijnaad: Zacht satijnlabel","extra":"","intro":" 280 g\/m"},"images":["bcww04w.jpg","bcww04w_black-pure.jpg","bcww04w_candy-pink.jpg","bcww04w_desert.jpg","bcww04w_elephant-grey.jpg","bcww04w_forest-green.jpg","bcww04w_grey-fog.jpg","bcww04w_hawaiian-blue.jpg","bcww04w_heather-asphalt.jpg","bcww04w_heather-dark-green.jpg","bcww04w_heather-grey.jpg","bcww04w_heather-mid-grey.jpg"],"image_alt":["","","","","","","","","","","",""],"discounts":{"name":"0","groupDiscount":"0.00","groupDiscountCategory":"0.00","groupDiscountProduct":"0.00"},"category":{"id":"888955","name":"Dames Sweaters & Fleece","categoryIds":"888955","cPath":"73_888940_888955"},"quantities":{"quantity":"400","physicalQuantity":"0","minimumQuantity":"0","maximumQuantity":null,"externalQuantity":"0","quantityStep":"1","trackQuantity":"1"},"prices":{"basePrice":"14.9200","normalPrice":"14.9200","price":"13.4280","specialPrice":"13.4280","purchasePrice":"0.0000"},"manufacturer":{"id":46,"name":"B&amp;C","image":"bc.jpg-preview72.jpg"},"dimensions":{"type":"0","width":0,"height":0,"area":0,"weight":0},"reviews":{"count":0,"avg":0},"resources":[],"addons":{"multicatalog":{"enabled":false},"layover":{"enabled":true}}}]}


This is not Hash. This is Json.
Save the entire value to a memo-field.
When you want, read as cJson and convert to hash if and when you want.

Code: Select all  Expand view

FIELD->MEMOFIELD := cJsonValue
// when required
cJson := FIELD->MEMOFIELD
HB_JsonDecode( cJson, @hHash )
// use hHash
 


Do not worry about its complexity.
This works.
Regards

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

Re: Put Hash data into a dbf

Postby Marc Venken » Thu May 27, 2021 7:58 am

If there a function to retrieve this info ?


Manufacturor name : B&W -> manufacturer":{"id":46,"name":"B&amp;C"

c_model = BCWU03W -> model":"BCWU03W" // this is more easy
c_CatID = 888963 -> "category":{"id":"888963","name":"Sweaters met kap","categoryIds":"888963"
c_Catname = Sweater met kap -> "category":{"id":"888963","name":"Sweaters met kap","categoryIds":"888963"

Or do I write to a memVar and use the functions to extract data from it

then I save to a dbf with the fields I need.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1426
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 118 guests