[ 
https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Rick Hillegas updated DERBY-3676:
---------------------------------

    Attachment: statementCacheVTI.sql

Thanks for the new patch, Mark.

I agree that

  String sqlText = ps.toString();

is more elegant than

  String sqlText ((DerbyPreparedStatement) ps).getFullSQLText();

However, like Dag, I am reluctant to change the meaning of toString(). 
Technically it's true that we haven't documented anywhere that 
PreparedStatement.toString() matches the SQL_TEXT column of the StatementCache 
vti. Still, PreparedStatement.toString() has had that meaning for more than a 
decade and I have no idea who depends on that fact. (For an example of using 
the StatementCache vti, see the attached ij script, statementCacheVTI.sql.)

I think that it's fine to add a new method which has the desired MySQL-like 
behavior and document that new method in the DerbyPreparedStatement interface. 

Concerning Dag's other comments:

1) Yes, please let us know what getFullSQLText() will return when the parameter 
is a stream or Blob/Clob.

2) We will need you to fill out an ICLA. See 
http://www.apache.org/licenses/#clas

Thanks,
-Rick

> Make the toString() method of Derby PreparedStatements print out SQL text 
> with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: Improvement
>          Components: JDBC
>            Reporter: Rick Hillegas
>         Attachments: humanstringprepared.txt, humanstringprepared.txt, 
> humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt, 
> humanstringprepared.txt, humanstringprepared.txt, ick.txt, ick.txt, 
> statementCacheVTI.sql
>
>
> This topic came up in the following email thread on the user list: 
> http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811
>  Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to