Local use adoconnection and adoquery
Try
{
SQL="select VA LINE_NAME, VB DAY_PLAN, VA., DAY_OUTOPUT_QTY, VA., NOW_WORK_HOURS, VB. DAY_PERSON, VC. NG_NUMS \
The from mes V_LINE_QTY_FOR_LED_XYJ VA, mes. V_LINE_PLAN_FOR_LED_XYJ VB, VC mes. V_LINE_PQC_FOR_LED_XYJ \
Where the VA. LINE_NAME=VB. LINE_NAME and VB. LINE_NAME=VC. LINE_NAME \
And VA. LINE_NAME in (' GTZ02 ', 'GTZ03', 'GTZ04', 'GTZ05', 'GY assembly) order by VA. LINE_NAME \
";
if(! DataModule1 - & gt; Open (SQL, DataModule1 - & gt; Oraclequery))
return;
while (! DataModule1 - & gt; Oraclequery - & gt; Eof)
{
AnsiString linename;
AnsiString planNum=0;
Int finishNum=0;
Int dayperson=0;
Int ngnum=0;
Int hourNum=0;
AnsiString personNum;//
AnsiString ztRate;
AnsiString ttnowworkhours=DataModule1 - & gt; Oraclequery - & gt; FieldByName (" NOW_WORK_HOURS ") - & gt; AsString;
AnsiString SSD=DataModule1 - & gt; Oraclequery - & gt; FieldByName (" NOW_WORK_HOURS ") - & gt; AsString;
Linename=DataModule1 - & gt; Oraclequery - & gt; FieldByName (" LINE_NAME) - & gt; AsString;
PlanNum=DataModule1 - & gt; Oraclequery - & gt; FieldByName (" DAY_PLAN ") - & gt; AsString;
FinishNum=StrToIntDef (DataModule1 - & gt; Oraclequery - & gt; FieldByName (" DAY_OUTOPUT_QTY ") - & gt; AsInteger, 0);
//abs fabs (1.11);
Float nowworkhours=DataModule1 - & gt; Oraclequery - & gt; FieldByName (" NOW_WORK_HOURS ") - & gt; AsFloat;
Dayperson=StrToIntDef (DataModule1 - & gt; Oraclequery - & gt; FieldByName (" DAY_PERSON ") - & gt; AsInteger, 1);
Ngnum=StrToIntDef (DataModule1 - & gt; Oraclequery - & gt; FieldByName (" NG_NUMS ") - & gt; AsInteger, 1);
If (nowworkhours==0 | | finishNum==0)
{
HourNum==0;
}
The else
{
HourNum=(finishNum/nowworkhours);
}
If (nowworkhours==0 | | dayperson==0 | | finishNum==0)
{
PersonNum=0;
}
The else
{
PersonNum=FormatFloat (" 0.00 ", (finishNum/(nowworkhours * dayperson)));
}
If (finishNum==0)
{
ZtRate="0.0%";
}
The else
{
ZtRate=FormatFloat (" 0.0 ", (100 - ngnum * 100.0/finishNum)) + "%".
}
Memo1 - & gt; Lines - & gt; Add (Now (). The FormatString (" mm - DDHH: mm: ss ") + ":" + linename + ":" + AnsiString (planNum) + ":" + AnsiString (finishNum) + ":" + ttnowworkhours + ":" + AnsiString (hourNum) + ":" + AnsiString (personNum) + ":" + AnsiString (ztRate));
SQL="update data set data='" + AnsiString (planNum) +"' where local=(select local from the local where DeviceNo='" + linename + "') ";
if(! DataModule1 - & gt; The exec (SQL, DataModule1 - & gt; ADOQExec))
return;
DataModule1 - & gt; Oraclequery - & gt; The Next ();
}
}
The catch (Exception & amp; The ex)
{
Memo1 - & gt; Lines - & gt; The Clear ();
Memo1 - & gt; Lines - & gt; Add (ex. Message);
}
- the database code -
Bool TDataModule1: : open (AnsiString SQL, TOraQuery * OracleADOQ)
{
Try
{
//ChangeLogicForm - & gt; Label1 - & gt; Caption="";
OracleADOQ - & gt; Close ();
OracleADOQ - & gt; SQL - & gt; The Clear ();
OracleADOQ - & gt; SQL - & gt; Add (SQL);
OracleADOQ - & gt; Prepared;
OracleADOQ - & gt; The Open ();
ChangeLogicForm - & gt; Label2 - & gt; Caption=SQL;
//OracleADOQ - & gt; ExecSQL ();
return true;
}
The catch (Exception & amp; E)
{
Try
{
Oracleconnection - & gt; Disconnect ();
Oracleconnection - & gt; Server=temporacleserver;
Oracleconnection - & gt; The Username=tempname;
Oracleconnection - & gt; Password=temppassword;
Oracleconnection - & gt; The Connect ().
}
The catch (... )
{
return false;
}
return false;
}
}
Bool TDataModule1: : exec (AnsiString SQL, TADOQuery * ADOQ)
{
Try
{
//ChangeLogicForm - & gt; Label3 - & gt; Caption="";
ADOQ - & gt; Close ();
ADOQ - & gt; SQL - & gt; The Clear ();
ADOQ - & gt; SQL - & gt; Add (SQL);
ADOQ - & gt; ExecSQL ();
return true;
}
The catch (Exception & amp; E)
{
Try
{
ChangeLogicForm - & gt; Label3 - & gt; Caption=AnsiString (connetcount++) + ":" + HeadString + TailString;
ADOConnection1 - & gt; Connected=false;
ADOConnection1 - & gt; The ConnectionString=HeadString + TailString;
ADOConnection1 - & gt; Connected=true;
//ChangeLogicForm - & gt; Memo1 - & gt; Lines - & gt; Add (HeadString + TailString);
}
The catch (... )
{
return false;
}
return false;
}
}
CodePudding user response:
Data synchronization advice with tools such as sqlload database itself, it is not necessary to own programming synchronizationCodePudding user response:
Is my query in oracle database data insert large SQLCodePudding user response:
You have a problem of the database code,Try
{
Normal code
}
The catch (... )
{
Abnormal
}
Within the anomalies, you put the closing of the database, there must be some problem, can consider change the catch to finally,
And don't read all of the data at a time, a large quantity of data takes up a lot of memory, when they consider a read 1000 bars,