oracle根据数据分线程,多线程对oracle数据库操作,内存居高不下(100分)

unit Umanger_thread;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, ExtCtrls, DB, Grids, DBGrids,StrUtils, ActiveX,

ComCtrls, OoMisc, AdPort,Registry,Buttons,DBCtrls,ImgList, Mask, CRGrid,MsgExch,

Ora, Tel_DM,

OraSmart, MemDS, DBAccess,IdUDPServer,Ubwfy_tread,OraProvider,DBClient,Provider;

type

Tmanger_thread = class(TThread)

private

{ Private declarations }

my_memo1:tmemo;

local_OraSession: TOraSession;

cur_bw_dataset:TOraQuery;

protected

procedure resolve_data;

procedure create_orasession;

procedure Execute;

override;

public

constructor create(memo1:tmemo);

destructor Destroy;

override;

end;

var

manger_thread_session: Tmanger_thread;

implementation

{ Important: Methods and properties of objects in visual components can only be

used in a method called using Synchronize, for example,

Synchronize(UpdateCaption);

and UpdateCaption could look like,

procedure Tmanger_thread.UpdateCaption;

begin

Form1.Caption := 'Updated in a thread';

end;

}

{ Tmanger_thread }

constructor Tmanger_thread.create(memo1: tmemo);

begin

my_memo1:= memo1;

create_orasession;

freeonterminate:=true;

inherited Create(False);

end;

procedure Tmanger_thread.create_orasession;

begin

CoInitialize(nil);

local_OraSession:=TOraSession.Create(nil);

local_OraSession.ConnectString:='bwxx/bwxx@127.0.0.1:1521:bwxx';

local_OraSession.Options.Net:=true;

local_OraSession.ConnectPrompt:=false;

local_OraSession.AutoCommit:=true;

local_OraSession.Connected := false;

cur_bw_dataset:=TOraQuery.Create(nil);

cur_bw_dataset.Session:=local_OraSession;

end;

destructor Tmanger_thread.Destroy;

begin

try

freeandnil(cur_bw_dataset);

local_OraSession.Connected:=false;

freeandnil(local_OraSession);

CoUnInitialize;

inherited;

except

end;

end;

procedure Tmanger_thread.Execute;

var

str1,xh,m_ysbw:string;

mysql:string;

begin

try

while truedo

begin

if (cur_bw_dataset.Eof) then

begin

cur_bw_dataset.Close;

cur_bw_dataset.SQL.Clear;

mysql:='select myid,mybwxx from bwxx where rownum<30 order by myid';

cur_bw_dataset.SQL.Add(mysql) ;

cur_bw_dataset.Open;

end ;

cur_bw_dataset.First;

while not cur_bw_dataset.Eofdo

begin

m_ysbw:= cur_bw_dataset.fieldbyname('mybwxx').AsString;

xh:= cur_bw_dataset.fieldbyname('myid').AsString;

if (cur_tread_num

begin

if manager_list.IndexOf(xh)<0 then

begin

bwfy_session:=TBWFY_TREAD.create(m_ysbw,my_memo1,xh);

end;

cur_bw_dataset.Next;

end;

sleep(1);

application.ProcessMessages;

end;

sleep(1000);

application.ProcessMessages;

end;

except

end;

end;

end.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值