The GETSTRINGVAL member function returns the document as a string. It returns a string containing the serialized XML representation, or the text itself if it is a text node. If the XML document exceeds the maximum size of VARCHAR2 (4000), an error is raised at runtime.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only MySQL mode.
Syntax
MEMBER FUNCTION getStringVal()
RETURN VARCHAR2;
Examples
In the following example, a1 and a2 are XMLType variables, c1 is a CLOB variable, c2 is a VARCHAR2 variable, and b is a VARCHAR2 variable containing a valid XML text <?xml version="1.0" encoding="ISO-8859-1"?><note><heading>Reminder</heading></note>.
a1 and a2 are generated using the CREATEXML and XMLTYPE constructors, respectively. a1 and a2 can be converted using the GETCLOBVAL() or GETSTRINGVAL() functions and assigned to variables of the corresponding type.
obclient> DECLARE
a1 XMLType;
a2 XMLType;
b VARCHAR2(200):='<?xml version="1.0" encoding="ISO-8859-1"?><note><heading>Reminder</heading></note>';
c1 CLOB;
c2 VARCHAR2(200);
BEGIN
a1:=XMLType.CREATEXML(b);
a2:=XMLType(b);
c1:=a1.GETCLOBVAL();
c2:=a2.GETSTRINGVAL();
DBMS_OUTPUT.PUT_LINE('c1: ' || c1);
DBMS_OUTPUT.PUT_LINE('c2: ' || c2);
END;
/
Query OK, 0 rows affected