You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Sylvain Leroux (JIRA)" <ji...@apache.org> on 2010/03/04 16:08:27 UTC

[jira] Updated: (DERBY-4566) Make it possible to define variables in ij

     [ 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.