Mysterious syntax error in TADOCommand



Hi everyone,

the following function loads a SQL script file into memory and executes
it using a TADOCommand. It works fine for most scripts, but I'm having
a problem with a certain stored procedure. I've verified the syntax of
the stored procedure by running it in the MS SQL Server query
analyzer.

The error message being returned when I try to execute the script is:
"Incorrect syntax near 'OUTPUT'"

The keyword OUTPUT appears in the script in the following context:

EXEC @Ret = spBilling_GetCallCharge
@Faxno = @Faxno,
@Date = @Date,
@Duration = @Duration,
@Charge = @Charge OUTPUT

Does anyone have an idea as to what could be causing this error? The
entire stored procedure in question is provided below the Delphi code.

TIA,
Ralph


[Delphi code]
function ExecuteScript(ScriptFile, ConnectionString: String): Boolean;
var
script: TStringList;
cmd: TADOCommand;
begin
if FileExists(ScriptFile) then
begin
cmd := TADOCommand.Create(nil);
cmd.ConnectionString := ConnectionString;
script := TStringList.Create;
script.LoadFromFile(ScriptFile);
cmd.ParamCheck := False;
cmd.CommandText := ListToString(script);
cmd.CommandType := cmdText;
cmd.ExecuteOptions := [eoExecuteNoRecords];
Result := True;

try
try
cmd.Execute;
except
on E: Exception do begin
Exception_Message := E.Message;
Result := False;
end;
end
finally
cmd.Free;
script.Free;
end;
end
else begin
Result := False;
end;
end;

[SQL stored proc]
CREATE PROCEDURE [dbo].[spBilling_GenerateData]
@From datetime,
@Until datetime
AS
/* Delete records that fall into period to avoid duplicates.
(Simply updating existing records doesn't seem to work.) */
DELETE FROM Billing_CallCharge
WHERE Date BETWEEN @From AND @Until

DECLARE @UserName varchar(30),
@Duration int,
@Date datetime,
@Time datetime,
@Charge float,
@Faxno varchar(20)

DECLARE c1 CURSOR FOR
SELECT
UserUniqueID,
Send_Time,
FaxDate,
FaxTime,
FaxNumber
FROM FaxArchiver
WHERE FaxDate BETWEEN @From AND @Until
AND LEN(FaxNumber) > 2

OPEN c1
FETCH NEXT FROM c1 INTO
@UserName,
@Duration,
@Date,
@Time,
@Faxno

WHILE @@FETCH_STATUS = 0
BEGIN
SET @Date = CONVERT(varchar, @Date, 111) + ' ' + CONVERT(varchar,
@Time, 108)

DECLARE @Ret int
EXEC @Ret = spBilling_GetCallCharge
@Faxno = @Faxno,
@Date = @Date,
@Duration = @Duration,
@Charge = @Charge OUTPUT

-- Ignore records where call charge calculation failed.
IF @Ret != 0
BEGIN
FETCH NEXT FROM c1 INTO
@UserName,
@Duration,
@Date,
@Time,
@Faxno
CONTINUE
END

INSERT INTO Billing_CallCharge
(
UserName,
Duration,
Date,
Charge,
Faxno
)
VALUES
(
@UserName,
@Duration,
@Date,
@Charge,
@Faxno
)

FETCH NEXT FROM c1 INTO
@UserName,
@Duration,
@Date,
@Time,
@Faxno
END

CLOSE c1
DEALLOCATE c1

.



Relevant Pages

  • khalid, still causing, stares almost loosely, as the object casts in connection with their riot
    ... expensive or toxic will appreciate practical publics to thereafter ... endorses the script? ... question finances, the sleeps often screw rather than the wide-eyed ... I was assisting wartimes to eventual Chuck, who's wiping in charge of the ...
    (sci.crypt)
  • Re: What is Wrong with this thing
    ... snip, it was in a block I was looking at. ... I have a script as follows. ... routine for a credit card charge and is meant to show details of the ...
    (alt.php)
  • What is Wrong with this thing
    ... I have a script as follows. ... routine for a credit card charge and is meant to show details of the charge. ... Dont know why ...
    (alt.php)
  • Re: OT Uncollected Prescriptions.
    ... I've got plenty of unfilled prescriptions. ... >had a Doc write a script for something that is available ... charge could be equal to or greater than the OTC charge. ... >meds from Mexico for cost savings. ...
    (alt.support.diabetes)
  • Re: [Full-disclosure] SSH brute force blocking tool
    ... And just what on God's earth does "SOMEONE LOGGING IN WITH USERNAME SET ... TO A VALID PASSWORD ENTRY" have to do with this script. ... the classic attack is the symlink attack. ...
    (Full-Disclosure)