Access中模块的程序如下,现在想在SQL中实现。主要是不知道这个循环判断逻辑怎么用SQL语言实现。求大神帮忙啊~~~
Private Sub UpdateReSA()
DimTable_SA
Dimcount As Long
Dimi As Long
DimInsured(Num) As String
DimRetain(Num) As Double
DimAvailableRetain(Num) As Double
SetTable_SA = CurrentDb.OpenRecordset("20 SA")
count = Table_SA.RecordCount
Table_SA.MoveFirst
Insured(0) = 0
Retain(0) = 0
AvailableRetain(0) = Table_SA.可用自留额
For i = 1 To count
'Do While Not Table_SA.EOF
Table_SA.Edit
Insured(i) = Table_SA.INSURED_ID
If Insured(i) = Insured(i - 1) Then
Table_SA.可用自留额 = Max(AvailableRetain(i - 1) - Retain(i - 1), 0)
Else
End If
If Table_SA.已分出标记 = 0 And Table_SA.分保类型 = "Auto" Then
Table_SA.自留额 = Min(Table_SA.风险保额 * Table_SA.合同成数, Table_SA.可用自留额)
Else
Table_SA.自留额 = Table_SA.风险保额 * (1 - Table_SA.分出比例)
End If
Table_SA.分出额 = Table_SA.风险保额 - Table_SA.自留额
Retain(i) = Table_SA.自留额
AvailableRetain(i) = Table_SA.可用自留额
Table_SA.Update
Table_SA.MoveNext
'Loop Next Table_SA.Close MsgBox "Finish!" End Sub