You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Steve Garcia <SG...@qrs.com> on 2003/11/17 22:58:20 UTC
Resolving Properties/Invoking Methods
I'm completely stumped, and the documentation / mailing-lists haven't helped
me get through the entire problem. I would appreciate any help!
I'm making some custom SQL scripts (and borrowing some of Torque's) and I
have a .vm file that looks like
#if ($table.ColumnsToModify.size() > 0)
ALTER TABLE $table.TableName MODIFY (
$generator.parse("${basepath}/columns.vm", "", "table",
$table.ColumnsToModify)
);
#end
#if ($table.ColumnsToAdd.size() > 0)
ALTER TABLE $table.TableName ADD (
$generator.parse("${basepath}/columns.vm", "", "table",
$table.ColumnsToAdd)
);
#end
When the script executes only the first if-end conditional produces output -
which above would be the MODIFY SQL statement. I do not see the ADD SQL
statement (but there is data to be generated.) When I swap the MODIFY and
ADD blocks in the .vm file, then only the ADD SQL statement gets output. I
can only generate the first block of text, which ever it may be. Both
should be output at the same time, but I can't get it to work that way. I
believe I have eliminated any Java errors with the objects I'm adding to the
Context. My velocity.log file only has one interesting line...
Mon Nov 17 13:51:26 PST 2003 [error] Left side ($table.ColumnsToAdd.size())
of '>' operation has null value. Operation not possible.
sql/alter/oracle/table.vm [line 28, column 34]
I don't know why this is happening and I would appreciate any advice!
I'm using Velocity 1.3.1.
Regards, Steve Garcia
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Resolving Properties/Invoking Methods
Posted by Nathan Bubna <na...@esha.com>.
Steve Garcia said:
...
> #if ($table.ColumnsToModify.size() > 0)
> ALTER TABLE $table.TableName MODIFY (
> $generator.parse("${basepath}/columns.vm", "", "table",
> $table.ColumnsToModify)
> );
> #end
>
> #if ($table.ColumnsToAdd.size() > 0)
> ALTER TABLE $table.TableName ADD (
> $generator.parse("${basepath}/columns.vm", "", "table",
> $table.ColumnsToAdd)
> );
> #end
>
> When the script executes only the first if-end conditional produces output -
> which above would be the MODIFY SQL statement.
> I do not see the ADD SQL statement (but there is data to be generated.)
...
> Mon Nov 17 13:51:26 PST 2003 [error] Left side ($table.ColumnsToAdd.size())
> of '>' operation has null value. Operation not possible.
> sql/alter/oracle/table.vm [line 28, column 34]
>
> I don't know why this is happening and I would appreciate any advice!
i'm inclined to believe velocity when it says that $table.ColumnsToAdd.size()
has a null value. it doesn't usually lie about these things and that would
explain why the content of that #if block isn't rendered.
try doing some debugging stuff in the template like:
$table.class
$table.ColumnsToModify.class
$table.ColumnsToAdd.class
$table.ColumnsToModify.size()
$table.ColumnsToAdd.size()
#foreach( $column in $table.ColumnsToModify )$column#end
#foreach( $column in $table.ColumnsToAdd )$column#end
or stuff like that. just to confirm to yourself (and us) that these calls are
doing what you think they're doing.
Nathan Bubna
nathan@esha.com
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org