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] Updated: (DERBY-4566) Make it possible to define variables in ij
Date Thu, 04 Mar 2010 15:08:27 GMT

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

Sylvain Leroux updated DERBY-4566:
----------------------------------

    Attachment: DERBY-4566.sql
                DERBY-4566_0.2.patch

Here is a proposal - and the corresponding demo sql file.

Those are only working draft - not ready for inclusion. Anyway, I made some progress: So this
patch allow to define variables in ij, initialized it either as a literal integer, as a range
(the set of values between two integers - included), or as the result of an EXECUTE statement:
    SET literal AS 1;
    SET range AS 1..100;
    SET result AS EXECUTE 'SELECT * FROM SomeTable';

Currently, the content of a variable can be displayed by using a GET statement:
    GET someVariable;

And the value of a variable is now a valid option for the USING clause of an EXECUTE statement.
For example, the two following statements will insert the values from 1 to 100 in a table:
    SET range AS 1..100;
    EXECUTE 'insert into SomeTbl(x) values(?)' USING ( range );


As you will see in the example file, I reorganized the grammar of ij in order to be able to
use any expression (literal, range, variable or result of some statements like EXECUTE) directly
in the USING clause. So the above example could be condensed as:
    EXECUTE 'insert into SomeTbl(x) values(?)' USING ( 1..100 );


I think this is a good starting point for this issue. The next step now would be to add some
kind of loop in ij.
Something like that would be great:
    FOR i IN 1..100
    BEGIN
        EXECUTE 'insert into SomeTable values(?, 10*?)' USING ( i,i );
    END;


Feel free to comment!
- 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
>         Attachments: DERBY-4566.sql, DERBY-4566_0.2.patch
>
>
> 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