You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Chandu <ch...@translogicsys.com> on 2004/04/09 14:00:55 UTC

Commenting sql statments - required support from Ant

Hi all,

I am executing an sql file as follows:

<sql userid="${USERNAME}" password="${PASSWORD}" url="${CONNECTSTRING}" driver="${DRIVER}" 
autocommit="true" src="mysql-dump.sql">
</sql>

With the above snippet of code I tried to execute a mysql dump file. It gave an sql fail error. Ant ignores 
lines starting with -- or // or REM words. But mysql dump file contains # as comments. Now I wanted to
tell the ant that "ignore the lines starting with this particular character or word". Is there any way to do?

- Chandu.

Re: Commenting sql statments - required support from Ant

Posted by "Jack J. Woehr" <ja...@purematrix.com>.
Chandu wrote:

> With the above snippet of code I tried to execute a mysql dump file. It gave
> an sql fail error. Ant ignores
> lines starting with -- or // or REM words. But mysql dump file contains # as
> comments. Now I wanted to
> tell the ant that "ignore the lines starting with this particular character
> or word". Is there any way to do?

Not currently. A commentstring="#" attribute might be nice for the SQL task.
But you could simply add that to the SQLExec class and rebuild Ant!!! Here's
a diff that would do that. This diff is against the current source tree:

Index: src/main/org/apache/tools/ant/taskdefs/SQLExec.java
===================================================================
RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/SQLExec.java,v
retrieving revision 1.67
diff -u -r1.67 SQLExec.java
--- src/main/org/apache/tools/ant/taskdefs/SQLExec.java 23 Feb 2004 19:28:23 -0000      1.67
+++ src/main/org/apache/tools/ant/taskdefs/SQLExec.java 14 Apr 2004 08:14:41 -0000
@@ -457,6 +457,9 @@
                 if (line.startsWith("--")) {
                     continue;
                 }
+                if (line.startsWith("#")) {
+                    continue;
+                }
                 StringTokenizer st = new StringTokenizer(line);
                 if (st.hasMoreTokens()) {
                     String token = st.nextToken();


--
Jack J. Woehr      # We have gone from the horse and buggy
Senior Consultant  # to the moon rocket in one lifetime, but
Purematrix, Inc.   # there has not been a corresponding moral
www.purematrix.com # growth in mankind. - Dwight D. Eisenhower




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


Re: Commenting sql statments - required support from Ant

Posted by Ivan Ivanov <ra...@yahoo.com>.
--- Matt Benson <gu...@yahoo.com> wrote:
> Seems like a quick solution would be to add
> <filterchain> support into <sql>, by adding either a
> 'filterchainref' attribute on <sql>, nested
> <filterchain>s to <transaction>, or both...
> 
> -Matt

+1 for me
Ivan


	
		
__________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th
http://taxes.yahoo.com/filing.html

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


Re: Commenting sql statments - required support from Ant

Posted by Matt Benson <gu...@yahoo.com>.
Seems like a quick solution would be to add
<filterchain> support into <sql>, by adding either a
'filterchainref' attribute on <sql>, nested
<filterchain>s to <transaction>, or both...

-Matt

--- Ivan Ivanov <ra...@yahoo.com> wrote:
> 
> --- Chandu <ch...@translogicsys.com> wrote:
> > Ivan,
> > 
> > Thanks!!! It worked.
> > But one doubt. We are pre-processing the scripts
> to
> > remove the comments, and
> > doing SQLExec task's
> > built in functionality(stripping comments). But it
> > is nice if Ant allows to
> > have the configurability of comment string
> > in the sql scripts.
> > 
> > Anyway, it worked fine for me. Thanks again.
> > 
> 
> Chandu
> 
> When I encountered this, I claimed it as a bug, but
> SQL specifications say the "official" comment is --.
> I
> think only MySQL supports comments with #. So this
> is
> not ant's fault
> 
> Ivan
> 
> 
> 	
> 		
> __________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - File online by April 15th
> http://taxes.yahoo.com/filing.html
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 



	
		
__________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th
http://taxes.yahoo.com/filing.html

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


Re: Commenting sql statments - required support from Ant

Posted by Ivan Ivanov <ra...@yahoo.com>.
--- Chandu <ch...@translogicsys.com> wrote:
> Ivan,
> 
> Thanks!!! It worked.
> But one doubt. We are pre-processing the scripts to
> remove the comments, and
> doing SQLExec task's
> built in functionality(stripping comments). But it
> is nice if Ant allows to
> have the configurability of comment string
> in the sql scripts.
> 
> Anyway, it worked fine for me. Thanks again.
> 

Chandu

When I encountered this, I claimed it as a bug, but
SQL specifications say the "official" comment is --. I
think only MySQL supports comments with #. So this is
not ant's fault

Ivan


	
		
__________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th
http://taxes.yahoo.com/filing.html

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


Re: Commenting sql statments - required support from Ant

Posted by Chandu <ch...@translogicsys.com>.
Ivan,

Thanks!!! It worked.
But one doubt. We are pre-processing the scripts to remove the comments, and
doing SQLExec task's
built in functionality(stripping comments). But it is nice if Ant allows to
have the configurability of comment string
in the sql scripts.

Anyway, it worked fine for me. Thanks again.

----- Original Message ----- 
From: "Ivan Ivanov" <ra...@yahoo.com>
To: "Ant Users List" <us...@ant.apache.org>
Sent: Wednesday, April 14, 2004 1:53 PM
Subject: Re: Commenting sql statments - required support from Ant


>
> > Hi all,
> >
> > I am executing an sql file as follows:
> >
> > <sql userid="${USERNAME}" password="${PASSWORD}"
> > url="${CONNECTSTRING}"
> > driver="${DRIVER}"
> > autocommit="true" src="mysql-dump.sql">
> > </sql>
> >
> > With the above snippet of code I tried to execute a
> > mysql dump file. It gave
> > an sql fail error. Ant ignores
> > lines starting with -- or // or REM words. But mysql
> > dump file contains # as
> > comments. Now I wanted to
> > tell the ant that "ignore the lines starting with
> > this particular character
> > or word". Is there any way to do?
>
> Yes there is. Here is the snippet:
>
>         <copy todir="${project.dist.dir}/sql">
>             <fileset dir="${basedir}/sql">
>                 <include name="create.sql"/>
>                 <include name="insert.sql"/>
>             </fileset>
>             <filterchain>
>                 <striplinecomments>
>                     <comment value="#"/>
>                 </striplinecomments>
>             </filterchain>
>         </copy>
>
> The important work is done with the nested filterchain
> in the copy task [2]: The Copy task supports nested
> FilterChains (from [1]).
>
> Hope this helps
> Ivan
>
> [1]http://ant.apache.org/manual/CoreTasks/copy.html
> [2]http://ant.apache.org/manual/CoreTypes/filterchain.html
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - File online by April 15th
> http://taxes.yahoo.com/filing.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org


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


Re: Commenting sql statments - required support from Ant

Posted by Ivan Ivanov <ra...@yahoo.com>.
> Hi all,
> 
> I am executing an sql file as follows:
> 
> <sql userid="${USERNAME}" password="${PASSWORD}"
> url="${CONNECTSTRING}"
> driver="${DRIVER}"
> autocommit="true" src="mysql-dump.sql">
> </sql>
> 
> With the above snippet of code I tried to execute a
> mysql dump file. It gave
> an sql fail error. Ant ignores
> lines starting with -- or // or REM words. But mysql
> dump file contains # as
> comments. Now I wanted to
> tell the ant that "ignore the lines starting with
> this particular character
> or word". Is there any way to do?

Yes there is. Here is the snippet:

        <copy todir="${project.dist.dir}/sql">
            <fileset dir="${basedir}/sql">
                <include name="create.sql"/>
                <include name="insert.sql"/>
            </fileset>
            <filterchain>
                <striplinecomments>
                    <comment value="#"/>
                </striplinecomments>
            </filterchain>
        </copy>

The important work is done with the nested filterchain
in the copy task [2]: The Copy task supports nested
FilterChains (from [1]).

Hope this helps
Ivan

[1]http://ant.apache.org/manual/CoreTasks/copy.html
[2]http://ant.apache.org/manual/CoreTypes/filterchain.html


	
		
__________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th
http://taxes.yahoo.com/filing.html

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


Re: Commenting sql statments - required support from Ant

Posted by Chandu <ch...@translogicsys.com>.
It seems nobody has the answer!!! right?

----- Original Message ----- 
From: "Chandu" <ch...@translogicsys.com>
To: "'Ant Users List'" <us...@ant.apache.org>
Sent: Friday, April 09, 2004 5:30 PM
Subject: Commenting sql statments - required support from Ant


Hi all,

I am executing an sql file as follows:

<sql userid="${USERNAME}" password="${PASSWORD}" url="${CONNECTSTRING}"
driver="${DRIVER}"
autocommit="true" src="mysql-dump.sql">
</sql>

With the above snippet of code I tried to execute a mysql dump file. It gave
an sql fail error. Ant ignores
lines starting with -- or // or REM words. But mysql dump file contains # as
comments. Now I wanted to
tell the ant that "ignore the lines starting with this particular character
or word". Is there any way to do?

- Chandu.


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