ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anderson, Rob (Global Trade)" <Rob.Ander...@nike.com>
Subject RE: Escaping strings in SQL scripts
Date Thu, 27 Apr 2006 17:59:13 GMT
It's been a while since I have used the SQL task to load functions. You
probably want to set keepformat="true", set delimetertype="row" and set
delimeter="/"...

     <sql
         driver="org.postgresql.Driver"
         url="jdbc:postgresql://localhost/..."
         userid= ...
         password= ...
         autocommit="true"
         keepformat="true"
         delimetertype="row"
         delimeter="/" >
         <fileset dir=".">
             <include name="foo.sql"/>
         </fileset>
     </sql>

Then edit foo.sql so that each function is separated by a line
containing a single "/"...

 'DECLARE seq RECORD;
  BEGIN SELECT * INTO seq FROM ...;
  IF FOUND THEN
      UPDATE ...;
  END IF;
  IF NOT FOUND THEN
     RETURN ...;
  END IF;
  RETURN NULL;
  END;'
/

Hope this helps,

-Rob Anderson

> -----Original Message-----
> From: Ray Madigan [mailto:ray@madigans.org] 
> Sent: Thursday, April 27, 2006 8:59 AM
> To: Ant Users List
> Subject: Escaping strings in SQL scripts
> 
> I have a bunch of functions that I need to write to my SQL 
> database.  The functions contain quoted strings that span 
> many lines like
> 
> 'DECLARE seq RECORD;
>  BEGIN SELECT * INTO seq FROM ...;
>  IF FOUND THEN
>      UPDATE ...;
>  END IF;
>  IF NOT FOUND THEN
>     RETURN ...;
>  END IF;
>  RETURN NULL;
>  END;'
> 
> Is there a way to write the script so I don't have to join 
> the function as a single long line?
> 
> The functions are in foo.sql type files and are read with
> 
>     <sql
>         driver="org.postgresql.Driver"
>         url="jdbc:postgresql://localhost/..."
>         userid= ...
>         password= ...
>         autocommit="true" >
>         <fileset dir=".">
>             <include name="foo.sql"/>
>         </fileset>
>     </sql>
> 
> Any help would be greatly appreciated
> 
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message