sql脚本:
begin
declare ierrCount smallint ;
szXH char(6) ;
szPH char(10) ;
FirstPH char(10) ;
iCount smallint ;
TempExp Exception ;
begin
begin
select 0 into ierrCount from dual;
select 0 into iCount from dual;
select max(right(xh,6)) into szXH from data1 where rq='200607';
if szXH is null then
select '0' into szXH from dual ;
end if ;
select to_char(to_number(szXH)+1) into szXH from dual ;
while Length(RTrim(szXH))<6 Loop
select ' ' || RTrim(szXH) into szXH from dual ;
end Loop ;
select '记账'||szXH into szPH from dual ;
select iCount +1 into iCount from dual ;
select szPH into FirstPH from dual ;
Insert Into data1(t1,t2) values('aaa', '200607',szPH) ;
commit;
Exception
when others then
RollBack;
select '0' into FirstPH from dual;
select '0' into szPH from dual;
select 0 into iCount from dual;
end ;
Open
RecCur for select FirstPH BPZH,szPH EPZH,iCount NUM from dual;
end;
end ;
中间层delphi代码:
执行:
ADOQuery1.Close ;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add(Input);
ADOQuery1.SQL.SaveToFile('D:/QBF1.TXT') ;
if ADOQuery1.Parameters.Count>0 then
begin
for i:=0 to ADOQuery1.Parameters.Count-1do
begin
if UpperCase(ADOQuery1.Parameters.Items
.Name)='PRECCUR' then
begin
ADOQuery1.Parameters.Items.DataType:=ftCursor ;
//ftVariant
ADOQuery1.Parameters.Items.Direction:= pdOutput ;
end;
end;
end;
try
ADOQuery1.Open;
except
ShowMessage('ssssssssssssssssssssssssssssssssssssssssss');
end ;
请高手帮忙!