You need to sign in or sign up before continuing.
insertDataByRunBack.sim 1.7 KB
Newer Older
P
plum-lihui 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

sql connect

print ================ insert data
$dbNamme  = db
$ctbPrefix = ctb
$ntbPrefix = ntb
$tbNum    = 10
$rowNum   = 10
$tstart   = 1640966400000  # 2022-01-01 00:00:00.000

sql use $dbNamme

$loop_cnt = 0
loop_insert:
print ====> loop insert data, but once check if there is stop insert flag in interaction talbe from main thread
sql select * from interaction
print $data[0][0] $data[0][1] $data[0][2] $data[0][3]
print $data[1][0] $data[1][1] $data[1][2] $data[1][3]
if $rows == 2 then
  if $data[1][1] == stop then 
    goto end_insert
haoranc's avatar
haoranc 已提交
23 24
  elif $data[0][1] == stop then 
    goto end_insert
P
plum-lihui 已提交
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
  endi
endi

$i = 0
while $i < $tbNum
  $ctb = $ctbPrefix . $i
  $ntb = $ntbPrefix . $i
  
  $x = 0
  while $x < $rowNum
    $binary = ' . binary
    $binary = $binary . $i
    $binary = $binary . '

    sql insert into $ctb values ($tstart , $i , $x , $binary )
    sql insert into $ntb values ($tstart , 999 , 999 , 'binary-ntb' )
    $tstart = $tstart + 1
    $x = $x + 1
  endw
  
  $i = $i + 1
  $tstart = 1640966400000
endw

if $loop_cnt == 0 then 
  print ====> notify main to working for insert data
  sql insert into interaction values (now, 'working', 0, 0);
haoranc's avatar
haoranc 已提交
52 53 54
  sql select * from interaction
  print $data[0][0] $data[0][1] $data[0][2] $data[0][3]
  print $data[1][0] $data[1][1] $data[1][2] $data[1][3]
P
plum-lihui 已提交
55 56 57 58 59 60 61 62 63 64 65 66 67 68
endi
$loop_cnt = $loop_cnt + 1
goto loop_insert

end_insert:
print ====> save insert data rows to main thread

$totalRowsOfCtb = $rowNum * $loop_cnt
$totalRowsOfStb = $totalRowsOfCtb * $tbNum
sql insert into interaction values (now, 'end', $totalRowsOfCtb, $totalRowsOfStb );
print ====> totalRowsOfCtb: $totalRowsOfCtb , totalRowsOfStb: $totalRowsOfStb