The GETSTRINGVAL member function returns a document as a string. The function returns a string containing a serialized XML representation, or returns the text itself in case of a text node. If the length of the VARCHAR2 column in the XML document exceeds the maximum size allowed, which is 4,000 characters, an error occurs at runtime.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the 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 whose content is a piece of valid XML text <?xml version="1.0" encoding="ISO-8859-1"?><note><heading>Reminder</heading></note>.
The values of a1 and a2 are generated by using the CREATEXML and XMLTYPE constructors, respectively. a1 and a2 can be converted by using the GETCLOBVAL() or GETSTRINGVAL() function, and their values are assigned to variables of the corresponding types.
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