Tuomas Toivonen
Tuomas Toivonen

Reputation: 23522

JMeter: database clob in variable

I have JDBC sample which selects oracle clob inside a variable. However, I need to use the content of this variable in the HTTP request, but the variable expansion doesn't evaluate to clob's content, but it's name instead. If I try to cast the clob to_char in the SQL query, I get an error buffer size is too small. How to correctly convert clob to string in jmeter?

Upvotes: 1

Views: 1251

Answers (1)

Dmitri T
Dmitri T

Reputation: 168217

  1. For example you have a table with a CLOB field which looks like:

    SQL> select * from sometable;
    
    SOMEDATA
    --------------------------------------------------------------------------------
    hello
    
  2. Which is returned to JMeter as something non-readable:

    JMeter Oracle Clob

  3. Declare a "Result Variable Name" with a meaningful reference name, i.e. clob

    JMeter Oracle Result Variable

  4. Add JSR223 PostProcessor as a child of the JDBC Request sampler and put the following code into "Script" area:

    def data = vars.getObject('clob').get(0).get('SOMEDATA')?.characterStream?.text
    log.info('Value from CLOB field: ' + data)
    

    The above code will extract the value from the CLOB field and print it into jmeter.log file

    JMeter Oracle CLOB field

The answer is inspired by the Performance Testing BLOB from a MySQL Database with JMeter article.

Upvotes: 3

Related Questions