Delphi and Kylix

Moderators: pritaeas
Number of threads: 7264
Number of posts: 19073

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Stored Procedures Posted by progr on 26 Sept 2006 at 5:30 AM
Hi All,
my problem is that I'm trying to execute a script for creating a Stored Procedure in Delphi. Everything was fine till the moment I put a parameter like :Name(Field), everything passes fine(without exceptions) , but the procedure is not created. Please help me, give some opinions, I'm desperate. Thank u and here is the source of the procedure


procedure TForm1.FormCreate(Sender: TObject);
begin
try
with TIBQuery.Create(nil) do
try
Database := GetDB;
SQl.Text := ' CREATE PROCEDURE PROC_DONEOBSRV ' +
' RETURNS (' +
' STAFFNAME VARCHAR(100),' +
' STAFFUIN VARCHAR(10),' +
' MDDNO INTEGER,' +
' DATEPRINT DATE,' +
' PATINAME VARCHAR(100),' +
' PATIEGN VARCHAR(10),' +
' OBSRVCOUNT_ALL INTEGER,' +
' OBSRVCOUNT_DONE INTEGER,' +
' TOTAL DOUBLE PRECISION)' +
' AS ' +
' begin ' +#13#10+
' FOR ' +
' select ls.FDOER_NAME, ' +
' ls.FDOER_UIN, ' +
' j.FMDDNO, ' +
' j.FDATEPRINT, ' +
' j.FPATIFULLNAME, ' +
' j.FPATIEGN, ' +
' count(lo.FID) as cnt_all ' +


' from TLABOJOURNAL j ' +
' join TLABO_DOERSSTAFF ls on (j.FSTAFFID = ls.FID) ' +
' join TLABOOBSRV lo on (lo.FJOURNALID = j.FID) ' +

' where j.FSTATUS = 0 and ' +
' ls.FACTIVE = 0 ' +

' GROUP BY ls.FDOER_NAME, ' +
' j.FMDDNO, ' +
' j.FPATIFULLNAME, ' +
' j.FPATIEGN, ' +
' ls.FDOER_UIN, ' +
' j.FDATEPRINT ' +

' into StaffName, StaffUIN, MDDNo,DatePrint,PatiName, PatiEGN, ObsrvCount_All ' +//this is one row

' DO ' +
' begin ' +
' select count(lo.FID), ' +
' sum(lo.FCODEPRICE) ' +
' from TLABOJOURNAL j ' +
' join TLABOOBSRV lo on lo.FJOURNALID = j.FID ' +
' where j.FMDDNO = :MDDNo and ' +//the parameter ??
' j.FSTATUS = 0 and ' +
' lo.FSTATUS = 0 ' +
' into ObsrvCount_done, Total; ' +
' suspend; ' +
' end ' +
' end ' ;
ExecSQL;
finally
Free;
end;
except ShowMessage('Unable to create Procedure'); Exit end;
ShowMessage('Procedure Created');
end;
Report
Re: Stored Procedures Posted by sziszi81 on 26 Sept 2006 at 9:56 PM
You did not COMMIT the transaction.
Report
Re: Stored Procedures Posted by progr on 29 Sept 2006 at 1:23 AM
: You did not COMMIT the transaction.
: I think that;s notthe problem, because even if I put the Commit statement in the source, it doesn't want to Run because of the ':', infront of my variable. It says: "Token unknown" for the ":".
Report
Re: Stored Procedures Posted by progr on 1 Oct 2006 at 11:58 PM
Guys I found the decision. It is about the parameters. The paramCheck property has to be False, because otherwise the parameters of the SQL statement are considered as parameters of the Query, not as parameters of the procedure.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.