Making a StoredProc via QueryComp
Hi,
I am making some tables, generators, triggers and stored procedures using a
TQuery component, as so:
query.SQL.Add('CREATE TRIGGER ..........');
query.ExecSQL;
Everything works except when I try and make a stored procedure. It keeps
giving me a general SQL error. I have examined the string 1000 times and I
don't see anything wrong with it. I then take the same string, cut it, and
paste it to ISQL and it works fine (all the code before this procedure
create everything (tables, etc) that the stored procedure uses. Here is the
code:
function CreateStoredProc(username:string);
var
s:string;
begin
s:='CREATE PROCEDURE COUNT_' + username + ' (year integer, month
integer) returns (result integer) as ';
s:=s+'begin select count (*) from stat_' + username + ' where ((year =
:year) and (month = :month)) INTO :result ';
s:=s+'EXIT; ';
s:=s+'END;';
result:=s;
end;
I then pass this to:
query.SQL.Clear;
query.SQL.Add(string);
query.ExecSQL;
(same way I do all other things). What is wrong with this? ISQL accepts the
string. Is it that I can't create stored procedures?
Thanks.