How to set a complex variable to NULL?

Martin B

Member²
I am tyring to set a complex bind variable of type Object (TXMLType) to null.

I have a string from which I build an XMLType. Sometimes that string is empty ''.

The TXMLType.Create function always requires a valid XML string. Using a string of '' in the create function -- TXMLType.Create(session,'') -- is invalid and raises an exception.

So I suspect the solution is not create an XMLtype instance, but rather set the value of the bind variable to NULL.

I was hoping to use something like: SetComplexVariable('myXML',NULL);

However, SetComplexVariable does not allow the specification of the NULL variant -- inconsistent datatypes variant and OBJECT -- nor does SetComplexVariable allow the specification of a null pointer (nil) for the OBJECT.

How can I specify NULL for a complex varaible or create an XMLType with a NULL value?

Any ideas? / Thanks much.
 
Nevermind I think I have a solution...

Creating an XMLType with a dummy string value, and then clearing the XMLType object makes it autonomically NULL.

e.g.

var
MyXML: TXMLType
begin
MyXML := TXMLType.Create(Session,'')
MyXML.Clear; // OBJECT Type is now autonomically NULL
 
Back
Top