Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XMLTOCURSOR doesn't restore Memo fields to memo field 1

Status
Not open for further replies.

Walid

Programmer
May 18, 2000
382
US
May be I am brain dead tonight,

I am trying to restore a cursor with a memo field from XML string like this

CREATE CURSOR Walid (n N(1),M m)
INSERT into walid values(1,'This is my first memo')
INSERT into walid values(2,'This is my second memo')
CursorToXML('Walid','cXMLString',1,8)

USE

XMLTOCURSOR(cXMLString, 'Walid')

The type of the field M is not m (Memo) anymore, it is Character!!.
Am I missing some thing here?


Walid Magd
Engwam@Hotmail.com
 
Walid,

How are you determining what the data-type of 'M' is? You do realize that if you are using the VARTYPE() function it will return 'C' for both character and memo fields, right? I suspect the at data-type of your cursor field is in fact memo, afterall you are specifying 'M' as the datatype.


-Kevin
 
Walid,

Remove the USE statement. In its place, delete all the records from the cursor. Then, when you call XMLTOCURSOR(), pass 8192 as the third param. In other words:

CREATE CURSOR Walid (n N(1),M m)
INSERT into walid values(1,'This is my first memo')
INSERT into walid values(2,'This is my second memo')
CursorToXML('Walid','cXMLString',1,8)

SELECT Walid
DELETE ALL

XMLTOCURSOR(cXMLString, 'Walid',8192)

The reason for the behaviour you were seeing is that XMLTOCURSOR() was creating an entirely new cursor (with the same name as the existing). The only way it knew what data types you wanted was to inspect the actual strings in the XML. There is nothing to tell it that 'This is my first memo' is anything other than an ordinary char string. (If it has been longer than 254 chars, you would have got a memo.)

With the modified code, the 8192 param tells it to re-use the existing cursor, which solves the problem.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Thanks a lot Mike

Walid Magd
Engwam@Hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top