pQuery.setCharacterStream¶
Signature: pQuery.setCharacterStream(parameterName, reader)
Returns: ParameterizedQuery pQuery - this ParameterizedQuery object. To see what methods can be used on a ParameterizedQuery, refer to the 'Parameterized Query' functions.
Sets the parameterName to the given reader object.
Note
When a very large UNICODE value is input to a LONGVARCHAR database field, it may be more practical to send it via a java.io.Reader object. The data will be read from the stream as needed until end-of-file is reached. The JDBC driver will do any necessary conversion from UNICODE to the database char format.
Note
The parameterName may include the parameter prefix character (colon ':' or at sign '@') but is not required. For example: ':fieldValue' and 'fieldValue' will reference the same named parameter.
Parameters¶
| Type | Name | Description | Default |
|---|---|---|---|
| String | parameterName | the name of the parameter | |
| Reader | reader | the value to use for parameterName |
Example¶
// Create the pQuery object with the SQL to be called
var pQuery = qie.getParameterizedQuery(
"update patient set name = :payload where name = :messageId"
);
// Example large XML payload (text / Unicode data)
var xmlPayload =
"<Patient>" +
"<ID>123456</ID>" +
"<Name>John Doe</Name>" +
"<DOB>1980-01-01</DOB>" +
"</Patient>";
// Wrap the text in a Reader for streaming into the database
var reader = new java.io.StringReader(xmlPayload);
// Set the values for the input parameters
pQuery.setString("messageId", "MSG-001");
pQuery.setCharacterStream("payload", reader);
// Execute the query
var queryResult = pQuery.doQuery("EMR Database");