You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by AcO6 <al...@de.pwc.com> on 2009/05/07 11:34:09 UTC

Re: Ant sql task fails while executing insert statement containg string description with "--"

Hi Pradeep,


Pradeep.C wrote:
> 
> Hi There,
> I am trying to execute *.sql file containing insert statements using ant
> <sql> task onto the DB2 database. The build is failing for me as one of
> the insert statement in *.sql has a string description with "--" charters
> init.
> 
> My insert statement looks something like this:
> 
> INSERT INTO TableItem (TABLENAME, CODE, DESCRIPTION, ANNOTATION,
> ISENABLED, SORTORDER, LOCALEIDENTIFIER, LASTWRITTEN, VERSIONNO) VALUES
> ('TestTable', 'TT1', 'Common -- Test', '', '1', 0, 'en', CURRENT
> TIMESTAMP, 1);
> 
> But if I execute this insert statement from the DB2 command prompt, it is
> getting executed successfully.
> 
> Can you please help me in finding the reason for this please?
> 
> Cheers,
> Pradeep
> 

I had the same problem:

INSERT INTO TBU (PERIODID,BUID,NAME,ARCHIVE) VALUES (0,'---','---',0);

failed, because of the "--" in the statement.

Looking at the target source:
org.apache.tools.ant.taskdefs.SQLExec.runStatements() - Line 527
the solution is quite simple:



> // SQL defines "--" as a comment to EOL
> // and in Oracle it may contain a hint
> // so we cannot just remove it, instead we must end it
> if (!keepformat && line.indexOf("--") >= 0) {
>     sql.append("\n");
> }
> 

I used keepformat="true" and removed all comments from the SQL-Script.
Work's fine :)

Regards,
AcO6
-- 
View this message in context: http://www.nabble.com/Ant-sql-task-fails-while-executing-insert-statement-containg-string-description-with-%22--%22-tp22969153p23423228.html
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org