AWS Redshift Positional Template

I am requesting a Redshift cluster using jdbc. The request has a single parameter:

select * from table_name bc where bc.column_name ~ ? limit 10

I set the parameter with

stmt.setString(1, "expected_value");

The request completes with an error and an exception:

org.postgresql.util.PSQLException: ERROR: The pattern must be a valid UTF-8 literal character expression
  Detail: 
  -----------------------------------------------
  error:  The pattern must be a valid UTF-8 literal character expression
  code:      8001
  context:   
  query:     496280
  location:  cgx_impl.cpp:1902
  process:   padbmaster [pid=4192]
  -----------------------------------------------

Running a query without a parameter works fine:

select * from table_name bc where bc.column_name 'expected_value' ? limit 10

Any ideas that might throw an exception?

+4
source share

All Articles