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

Rick Hillegas commented on DERBY-4557:
--------------------------------------

Thanks for thinking more about this issue, Sylvain and Denis.

Concerning the compatibility issue which Sylvain raised...

>However, what about the compatibility with existing ij scripts, if those 
>already embed parameter-like strings?
>ij> INSERT INTO T(user, password) VALUES('john', '$1');
>In the (rather simplistic) example above, the statement will set the password 
>of "fred" to "$1" with some versions of ij, but will set it to the empty 
>string - or whatever the parameter $1 is defined - with other versions.

...I think we can handle this by not assigning a default value to unassigned 
variables. If the user hasn't specified a value for $1 on the command line, 
then ij does not substitute anything.

I think it is good to think about this issue in the broader context of whether 
we want to add support for an ij SET command which creates variables. However, 
I think that enhancement deserves a separate, related issue.

Here are some possible ij command lines which pass in variables. The following 
line would support numbered variables (e.g., $1, $2, ...):

  ij -a fred -a fredpassword scriptFileName

The following would support named variables (e.g., ${user}):

  ij -Dij.arg.user=fred -Dij.arg.password=fredpassword scriptFileName

I am leaning toward the second approach. It's a little more verbose but it 
exploits existing ij capabilities.

Thanks.









> Make it possible to parameterize ij scripts.
> --------------------------------------------
>
>                 Key: DERBY-4557
>                 URL: https://issues.apache.org/jira/browse/DERBY-4557
>             Project: Derby
>          Issue Type: Improvement
>          Components: Tools
>            Reporter: Rick Hillegas
>
> It would be nice to be able to parameterize ij scripts. At a high level, this 
> would be akin to the $N parameters which you pass on the command line to Unix 
> shell scripts. I think it would be easiest to understand if parameter 
> substitution happened before the script was handed to the ij parser.
> It would be nice to write something like the following:
> connect 'jdbc:derby:$1;user=$2;password=$3';
> insert into $4( a ) values ( $5 );
> or something like this:
> connect 'jdbc:derby:${dbname};user=${user};password=${password}';
> insert into ${tableName} values ( ${intValue} );

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