Java Mailing List Archive

http://www.ant-tasks.com/

Home » Ant Users List »

ant sql call stored procedure

Chaohua Wang

2008-03-13

Replies:

Author LoginPost Reply

Hi folks,


I am using ant sql to call a stored procedure of Ms Sql server

<sql
  driver="${jdbcdriver}"
  url="${dburl}/BillPay"
  userid="${userid}"
  password="${password}"
 src=" uspSelectCount.sql "
 classpathref="webtest.path.id"
>
 </sql>  


I can execute stored procedure in Ms Sql server. My stored procedure name is uspSelectCount. But when I am using ant sql to call the file uspSelectCount.sql that is located with the build file.

I always got this exception:

test:
   [sql] Executing file: C:\workspace\Canoo\billPay\tests\uspSelectCount.sql
   [sql] Failed to execute:  ■U S E  [ B i l l P a y ] G O / * * * * * *  O b j e c t :   S t o r e d P r o c e d u r e  [ d b o ] . [ u s p S e l e c t C o u n t ]      S c r i p t  D
a t e :  0 3 / 1 3 / 2 0 0 8  1 5 : 5 1 : 1 3  * * * * * *
   [sql] java.sql.SQLException: Incorrect syntax near 'E'.
   [sql] Failed to execute:  S E T  A N S I _ N U L L S  O N G O S E T  Q U O T E D _ I D E N T I F I E R  O N G O - -  = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
= = = = = = = = = = = - -  A u t h o r :         < A u t h o r , , N a m e > - -  C r e a t e  d a t e :  < C r e a t e  D a t e , , > - -  D e s c r i p t i o n :     < D e s c r i p
t i o n , , > - -  = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = C R E A T E  P R O C E D U R E  [ d b o ] . [ u s p S e l e c t C o u n t ]   A S B
E G I N - -  S E T  N O C O U N T  O N  a d d e d  t o  p r e v e n t  e x t r a  r e s u l t  s e t s  f r o m - -  i n t e r f e r i n g  w i t h  S E L E C T  s t a t e m e n t s .
S E T  N O C O U N T  O N ;   S e l e c t   c o u n t ( * ) f r o m  d b o . P a y m e n t s _ S t a g i n g   E n d
  [sql] java.sql.SQLException: Incorrect syntax near 'T'.


'E' is the third character of USE. 'T' is the third character of SET. I am not sure the reason why? Please help.

I can execute uspSelectCount.sql in the SQLunit. <stmt>{call uspSelectCount()}</stmt>

cwang



This is uspSelectCount.sql file
--------------------------------------------
USE [BillPay]
GO
/****** Object: StoredProcedure [dbo].[uspSelectCount]   Script Date: 03/13/2008 15:51:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:    <Author,,Name>
-- Create date: <Create Date,,>
-- Description:  <Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[uspSelectCount]

AS
BEGIN
 -- SET NOCOUNT ON added to prevent extra result sets from
 -- interfering with SELECT statements.
 SET NOCOUNT ON;

Select count(*)
from dbo.Payments_Staging

End


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.