db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sylvain Leroux (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-4566) Make it possible to define variables in ij
Date Wed, 24 Feb 2010 19:17:28 GMT

    [ https://issues.apache.org/jira/browse/DERBY-4566?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12837957#action_12837957
] 

Sylvain Leroux commented on DERBY-4566:
---------------------------------------

>From the user point of view, this would require a new SET statement defining/setting a
variable to the result of an other ij statement:

  SET position AS GETCURRENTROWNUMBER my_cursor;
  SET table_list AS SHOW TABLE;
  SET stmt_result AS EXECUTE my_prepared_statement;

The variable could then later be used in any place where an ij statement accept some value:
  ABSOLUTE position my_cursor;
  EXECUTE 'INSERT INTO Audit VALUES(?,?,?)' USING table_list;

As a further improvement, variable could be indexed in order to access to individual columns:
  EXECUTE 'INSERT INTO Audit(tbl) VALUES(?)' USING table_list[2];
or even
  EXECUTE 'INSERT INTO Audit(tbl) VALUES(?)' USING table_list["TABLE_NAME"];

----

Now, for the insights. As a starting point, every statement in ij returns an ijResult instance.
But this is a fat-interface that requires the client code to be able to handle several different
data types. 
In  order to work uniformly with any statement result, an interface with a simple and unique
contract would be definitivly easier to work with. I'm not quite sure what should be the best:
a rewrite of ijResult (and ijResultImpl) or introducing a new interface for that purpose.

Yet, here are methods of ijResult allowing to discriminate between the different data types:
	boolean isConnection();
	boolean isStatement();
	boolean isResultSet() throws SQLException;
	boolean isUpdateCount() throws SQLException;
	boolean isNextRowOfResultSet();
	boolean isVector();
	boolean isMulti();
	boolean isException();
	boolean isMultipleResultSetResult();
It worth to notice that these methods are only used by org.apache.derby.impl.tools.ij.utilMain.displayResult(LocalizedOutput,
ijResult, Connection) and the values end up in the several org.apache.derby.tools.JDBCDisplayUtil.display_XXXX
methods. Moreover this interface is package private. For these reasons, I feel like changing
the ijResult interface seems to be a reasonable option to start with.


All comments and ideas are welcome!
Sylvain.

> Make it possible to define variables in ij
> ------------------------------------------
>
>                 Key: DERBY-4566
>                 URL: https://issues.apache.org/jira/browse/DERBY-4566
>             Project: Derby
>          Issue Type: Improvement
>          Components: Tools
>            Reporter: Sylvain Leroux
>            Assignee: Sylvain Leroux
>
> It would be nice to have a way in ij to store statement results in variables for later
re-use.
> Notably, It would allow to use (meta)data obtained by some statements (such as SHOW ....)
beyond the simple display of the result. Moreover, it could be a first step toward extending
the scripting capabilities of ij.
> See http://old.nabble.com/IJ-scripting-(variables-in-IJ-)-td27290712.html
> Related to DERBY-4557

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


Mime
View raw message