-- PT. PANEN LESTARI INTERNUSA (1991.1210.0) ke PT. SWALAYAN SUKSES ABADI (2014.0071.0). 
-- tambahkan juga pada kolom catatan klaim di setiap no klaim di isi dengan kata-kata “mutasi klaim dari PT. Panen Lestari Internusa ke PT. Swalayan Sukses Abadi per tgl 26/03/2015”.
-- 
-- dari ke
--          2014.0888 (PT. SWALAYAN SUKSES ABADI [2014.0071.0])
-- 
--
-- klaim no proposal yg lama = status:merah, semua angka 0, ditambah catatan
-- klaim no proposal yg baru = status:merah, ana nomilal, ditambah catatan (tgl proses hari ini)


DECLARE @list_klaim TABLE ( no_klaim VARCHAR(11))

INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.088703')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.088622')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089235')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077261')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.033108')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.074842')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.036046')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022274')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.021221')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.021223')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.023049')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077248')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.088707')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061133')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061134')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022293')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022303')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.076143')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.033046')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022307')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063128')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.036067')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.036063')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.088715')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.032838')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.047930')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.062827')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077536')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077542')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077556')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.021270')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.033485')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.023011')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.023014')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077077')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.046738')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022302')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022958')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.062999')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063015')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.034909')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061395')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.033051')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.046696')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.046699')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.046685')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.023063')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077561')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.084235')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048684')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.033049')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.076149')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048639')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.033480')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.023020')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.023017')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089265')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089267')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022267')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.034924')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.090000')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.036068')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.088697')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.036071')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048644')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077531')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.088618')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.033047')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077249')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.074856')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.074836')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.074835')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.070267')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061190')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061191')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.021230')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061188')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022289')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063048')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063051')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063054')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063055')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.062940')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.021239')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.021234')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.090010')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048267')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.023099')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048649')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.023064')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.046682')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.062832')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022306')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.088685')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063131')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.047940')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022379')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.034920')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022285')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.036049')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.046739')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.034861')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.062991')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.088625')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048693')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077548')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048682')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048686')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048689')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022241')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022299')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022325')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.021226')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022136')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077051')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048606')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.074499')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.034892')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.033475')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.033477')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.034901')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.088581')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061194')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061196')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.088693')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061126')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.088689')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077074')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.047954')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.047953')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063045')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.062974')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.033110')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.074529')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.075815')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089274')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022305')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063073')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063069')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.046674')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.047774')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061398')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.062970')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048690')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022297')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089268')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077255')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077359')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077257')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048694')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.033493')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.033492')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.030886')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.047951')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.062831')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022425')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.036039')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.062976')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.062978')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063090')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063093')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089261')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089249')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089250')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089252')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.085893')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089226')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.023051')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089230')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089234')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089229')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089228')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.033105')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.033106')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077251')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077144')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022309')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022321')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063076')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063080')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063082')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089253')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.046681')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.036351')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.046669')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.059323')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.059328')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.059331')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022960')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048641')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.021217')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.088577')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077068')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048637')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063023')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063018')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.090004')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.032759')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.076146')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048695')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.036053')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.021242')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.034850')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048640')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.023087')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.034915')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063042')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.090018')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.090014')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063037')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.029119')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048307')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.034864')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.076137')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.021253')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.021248')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.074525')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.021255')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.021259')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048352')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.046688')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.062824')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.062812')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.062816')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.062819')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.062821')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.032828')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.032835')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048613')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.088571')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.021246')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.046735')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.034933')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.090026')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077175')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048604')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.034890')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.046744')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.034866')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089271')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.046741')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.034844')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061208')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.033487')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077116')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063064')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063066')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.032752')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.046742')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061214')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.023046')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089246')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089243')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089237')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089239')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.096417')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.033479')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.023027')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.023025')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022429')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077168')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063100')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063101')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.034911')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022283')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063084')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.059333')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.059336')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.046720')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.034865')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089273')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063059')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063046')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.074848')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.074851')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.046740')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061409')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.036075')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.032757')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.032749')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.062945')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.007419')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.034832')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061387')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.074853')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.032671')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061201')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.021211')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077552')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.023060')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061391')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.047762')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.047763')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061389')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063067')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048652')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.032750')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063034')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022966')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022963')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063031')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063123')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063126')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022968')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048303')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077146')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063096')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048596')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.032753')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.032756')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.074656')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048611')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.023067')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.046694')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061213')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077147')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.023095')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.023098')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.023096')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048305')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.032665')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.077040')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048653')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.033112')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063113')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063116')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.034930')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022286')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.090021')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022381')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022247')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.020600')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.036069')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.036070')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.047759')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061400')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061403')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.047755')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.034937')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089275')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.048697')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.076139')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.046678')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.047955')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089260')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.088585')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061205')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.074516')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.021262')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061197')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063006')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.034928')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063008')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.063002')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.061912')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.089954')
INSERT INTO @list_klaim ( no_klaim ) VALUES ('2015.022427')


DECLARE @hasil TABLE ( 
                  no_klaim_lama VARCHAR(11),
                  no_proposal_lama VARCHAR(9),
                  no_peserta_lama VARCHAR(12),
                  no_klaim_baru VARCHAR(11),
                  no_proposal_baru VARCHAR(9),
                  no_peserta_baru VARCHAR(12),
                  nama VARCHAR(30),
                  tgl_lahir DATE
               )

DECLARE @no_klaim VARCHAR(11)

DECLARE list_cursor CURSOR FOR  
SELECT no_klaim
FROM @list_klaim 

OPEN list_cursor  
FETCH NEXT FROM list_cursor INTO @no_klaim  

WHILE @@FETCH_STATUS = 0  
BEGIN 
  
  DECLARE
    @no_peserta_lama VARCHAR(12),
    @no_peserta_baru VARCHAR(12),
    @no_proposal_baru VARCHAR(9),
    @no_proposal_lama VARCHAR(9),
    @nama VARCHAR(30),
    @tgl_lahir DATE,
    @id_produk_lama VARCHAR(10),
    --@id_produk_baru VARCHAR(10),
    @sub_kelompok_lama VARCHAR(6)

  SET @no_proposal_baru = '2014.0888'
   
  SELECT
    @no_peserta_lama = No_Peserta,
    @no_proposal_lama = No_Proposal,
    @id_produk_lama = Id_Produk,
    @sub_kelompok_lama = Sub_Kelompok
  FROM
    dbo.Klaim_Peserta
  WHERE 
    No_Klaim = @no_klaim
    --AND Status = 'I'  -- hanya yg inforce
    AND Jenis_Pembayaran = 'R'  -- yg reimburst dulu
    
  IF (@@RowCount = 0) -- jika klaim tidak ditemukan
    PRINT 'No Klaim: ' + @no_klaim + ' tidak ditemukan.'
  ELSE  -- jika klaim ditemukan
    BEGIN

      -- cek & ambil data dari tabel mapping
      SELECT DISTINCT
        @no_peserta_baru = no_peserta_baru,
        @nama = nama
      FROM
        dbo.tmp_prib_pindah_klaim
      WHERE
        no_peserta_lama = @no_peserta_lama
      IF (@@RowCount = 1) -- jika ditemukan dan hanya ada 1, berarti oke
        BEGIN

          BEGIN TRAN -- start transaction
        
          -- get Id_Produk
          DECLARE @id_produk_baru VARCHAR(10)
          SELECT
	          @id_produk_baru = Id_Produk
          FROM
	          dbo.Peserta_Produk AS pp
          WHERE
            No_Proposal = @no_proposal_baru
            AND No_Peserta = @no_peserta_baru
            AND Sub_Kelompok = @sub_kelompok_lama
          IF (@@ERROR <> 0) OR (@@RowCount = 0)
		        BEGIN
		          PRINT 'Id_Produk kosong. No klaim: '+@no_klaim
              ROLLBACK TRAN
	            --RETURN -1
	          END
        
        
          -- generate no_klaim baru
          DECLARE	@no_klaim_baru VARCHAR(20)
          DECLARE @tgl_sekarang DATETIME = GETDATE()
          EXEC [dbo].[gproc_GetNo]
              @NoMin = NULL,
              @Tgl = @tgl_sekarang,
              @sField = 'No_Klaim',
              @CurrNo = @no_klaim_baru OUTPUT
          IF (@@ERROR <> 0) OR (LEN(@no_klaim_baru)=0)
            BEGIN
		          PRINT 'no_klaim_baru error'
              ROLLBACK TRAN
	            --RETURN -1
	          END

          
          -- copy klaim
          INSERT INTO dbo.Klaim_Peserta
                  (No_Klaim,
                   No_Proposal,
                   No_Peserta,
                   No_Santunan,
                   Id_Produk,
                   Sub_Kelompok,
                   Kode_Diagnosa,
                   Kode_Provider,
                   Tgl_Klaim,
                   No_Bukti,
                   Notes,
                   Jenis_Pembayaran,
                   Jml_Diajukan,
                   Jml_Deductible,
                   Jml_Dibayar,
                   Jml_Ditolak,
                   Jml_Dispensasi,
                   Uang_Muka,
                   Diskon_Rs,
                   Flag,
                   Jml_Dibayar_Old,
                   Jenis,
                   Jumlah,
                   Tolakan,
                   No_Pasien,
                   Kode_Equity,
                   Kode_ICD,
                   Claim_Ref,
                   Tgl_Kwitansi,
                   AdMedika_Ya,
                   Jml_Tunai,
                   Tgl_Masuk,
                   Tgl_Keluar,
                   Status,
                   Create_By,
                   Create_Date,
                   Change_By,
                   Change_Date,
                   Id_RegKlaim)
          SELECT
              @no_klaim_baru,             -- No_Klaim - varchar(11)
              @no_proposal_baru,          -- No_Proposal - varchar(9)
              @no_peserta_baru,           -- No_Peserta - varchar(12)
              LEFT(@no_peserta_baru,11) + RIGHT(@no_peserta_lama,1),  -- No_Santunan - varchar(12)
              @id_produk_baru,            -- Id_Produk - varchar(10)
              Sub_Kelompok,               -- Sub_Kelompok - varchar(6)
              Kode_Diagnosa,              -- Kode_Diagnosa - varchar(6)
              Kode_Provider,              -- Kode_Provider - varchar(6)
              Tgl_Klaim,                  -- Tgl_Klaim - datetime
              No_Bukti,                   -- No_Bukti - varchar(18)
              'mutasi klaim dari PT. Panen Lestari Internusa ke PT. Swalayan Sukses Abadi per tgl 30/03/2015',  -- Notes - varchar(150)
              Jenis_Pembayaran,           -- Jenis_Pembayaran - varchar(1)
              Jml_Diajukan,               -- Jml_Diajukan - float
              Jml_Deductible,             -- Jml_Deductible - float
              Jml_Dibayar,                -- Jml_Dibayar - float
              Jml_Ditolak,                -- Jml_Ditolak - float
              Jml_Dispensasi,             -- Jml_Dispensasi - float
              Uang_Muka,                  -- Uang_Muka - float
              Diskon_Rs,                  -- Diskon_Rs - float
              Flag,                       -- Flag - smallint
              Jml_Dibayar_Old,            -- Jml_Dibayar_Old - float
              Jenis,                      -- Jenis - smallint
              Jumlah,                     -- Jumlah - float
              Tolakan,                    -- Tolakan - varchar(200)
              No_Pasien,                  -- No_Pasien - varchar(10)
              Kode_Equity,                -- Kode_Equity - varchar(6)
              Kode_ICD,                   -- Kode_ICD - varchar(6)
              Claim_Ref,                  -- Claim_Ref - varchar(15)
              Tgl_Kwitansi,               -- Tgl_Kwitansi - datetime
              AdMedika_Ya,                -- AdMedika_Ya - bit
              Jml_Tunai,                  -- Jml_Tunai - float
              Tgl_Masuk,                  -- Tgl_Masuk - datetime
              Tgl_Keluar,                 -- Tgl_Keluar - datetime
              'G',                     -- Status - varchar(2)
              Create_By,                  -- Create_By - varchar(4)
              Create_Date,                -- Create_Date - datetime
              Change_By,                  -- Change_By - varchar(4)
              Change_Date,                -- Change_Date - datetime
              Id_RegKlaim                 -- Id_RegKlaim - varchar(12)
          FROM
            dbo.Klaim_Peserta AS kp
          WHERE
            No_Klaim = @no_klaim
            AND No_Proposal = @no_proposal_lama
          IF (@@ERROR <> 0) OR (@@RowCount = 0)
		        BEGIN
		          PRINT 'Insert ke Klaim_Peserta error. No klaim: '+@no_klaim
              ROLLBACK TRAN
	            --RETURN -1
	          END
	        ELSE  -- jika sukses
	          BEGIN  -- lanjut insert klaim_detail
	            
	            INSERT INTO dbo.Klaim_Detail
	                    (No_Klaim,
	                     Kode_Santunan,
	                     Tabel_Prosen,
	                     Amount,
	                     Tgl_Kwitansi,
	                     Jml_Diajukan,
	                     Jml_Klaim,
	                     Jml_Deductible,
	                     Jml_Benefit,
	                     Jml_Dibayar,
	                     Jml_Ditolak,
	                     Kode_Tolakan,
	                     Jml_Adm,
	                     Keterangan,
	                     Jml_Dispensasi,
	                     Jml_Dibayar_Old,
	                     Status,
	                     Change_By,
	                     Change_Date,
	                     Create_By,
	                     Create_Date)
	            SELECT
	            	  @no_klaim_baru,        -- No_Klaim - varchar(11)
	            	  kd.Kode_Santunan,   -- Kode_Santunan - varchar(10)
	            	  kd.Tabel_Prosen,     -- Tabel_Prosen - float
	            	  kd.Amount,           -- Amount - float
	            	  kd.Tgl_Kwitansi,    -- Tgl_Kwitansi - datetime
	            	  kd.Jml_Diajukan,     -- Jml_Diajukan - float
	            	  kd.Jml_Klaim,        -- Jml_Klaim - float
	            	  kd.Jml_Deductible,   -- Jml_Deductible - float
	            	  kd.Jml_Benefit,      -- Jml_Benefit - float
	            	  kd.Jml_Dibayar,      -- Jml_Dibayar - float
	            	  kd.Jml_Ditolak,      -- Jml_Ditolak - float
	            	  kd.Kode_Tolakan,    -- Kode_Tolakan - varchar(5)
	            	  kd.Jml_Adm,          -- Jml_Adm - float
	            	  kd.Keterangan,      -- Keterangan - varchar(150)
	            	  kd.Jml_Dispensasi,   -- Jml_Dispensasi - float
	            	  kd.Jml_Dibayar_Old,  -- Jml_Dibayar_Old - float
	            	  kd.Status,          -- Status - varchar(1)
	            	  kd.Change_By,       -- Change_By - varchar(4)
	            	  kd.Change_Date,     -- Change_Date - datetime
	            	  kd.Create_By,       -- Create_By - varchar(4)
	            	  kd.Create_Date      -- Create_Date - datetime
	            FROM
	            	dbo.Klaim_Detail AS kd
	            WHERE
	              kd.No_Klaim = @no_klaim
              IF (@@ERROR <> 0) OR (@@RowCount = 0)
		            BEGIN
		              PRINT 'Insert ke Klaim_Detail error. No klaim: '+@no_klaim
                  ROLLBACK TRAN
	                --RETURN -1
	              END
	            ELSE -- jika sukses
	              BEGIN
	            
                  -- update klaim yg lama
                  UPDATE
                    dbo.Klaim_Peserta
                  SET
                    Notes = 'mutasi klaim dari PT. Panen Lestari Internusa ke PT. Swalayan Sukses Abadi per tgl 30/03/2015',
                    Jml_Diajukan = 0,
                    Jml_Deductible = 0,
                    Jml_Dibayar = 0,
                    Jml_Ditolak = 0,
                    Jml_Dispensasi = 0,
                    Uang_Muka = 0,
                    Diskon_Rs = 0--,
                    --Status = 'G'
                  WHERE
                    No_Klaim = @no_klaim
                    AND No_Proposal = @no_proposal_lama
                  IF (@@Error = 0) AND (@@RowCount <> 0)  -- jika tidak ada error pada saat update, dan ada row
                    BEGIN
                    
                      -- update klaim_detail yg lama
                      UPDATE
                        dbo.Klaim_Detail
                      SET
                        Amount = 0,
                        Jml_Diajukan = 0,
                        Jml_Klaim = 0,
                        Jml_Deductible = 0,
                        --Jml_Benefit = 0,
                        Jml_Dibayar = 0,
                        Jml_Ditolak = 0,
                        Jml_Adm = 0,
                        Jml_Dispensasi = 0,
                        Jml_Dibayar_Old = 0
                      WHERE
                        No_Klaim = @no_klaim
                      IF (@@Error = 0) AND (@@RowCount <> 0)  -- jika tidak ada error pada saat update, dan ada row
                        BEGIN
                    
                          -- insert ke tabel hasil
                          INSERT INTO @hasil
                                  (no_klaim_lama,
                                   no_proposal_lama,
                                   no_peserta_lama,
                                   no_klaim_baru,
                                   no_proposal_baru,
                                   no_peserta_baru,
                                   nama,
                                   tgl_lahir)
                          VALUES
                                  (@no_klaim, -- no_klaim - varchar(11)
                                   @no_proposal_lama, -- no_proposal_lama - varchar(9)
                                   @no_peserta_lama, -- no_peserta_lama - varchar(12)
                                   @no_klaim_baru, -- no_klaim_baru - varchar(11)
                                   @no_proposal_baru, -- no_proposal_baru - varchar(9)
                                   @no_peserta_baru, -- no_peserta_baru - varchar(12)
                                   @nama, -- nama - varchar(30)
                                   @tgl_lahir  -- tgl_lahir - date
                                   )
                                   
                          COMMIT TRAN
                          --RETURN 0
                        END
                      ELSE
                        BEGIN
                          PRINT 'Update Klaim_Detail gagal. No klaim: ' + @no_klaim
                          ROLLBACK TRAN
	                        --RETURN -1
                        END
                    END
                  ELSE  -- jika ada error
                    BEGIN
                      PRINT 'Update Klaim_Peserta gagal. No klaim: ' + @no_klaim
                      ROLLBACK TRAN
	                    --RETURN -1
                    END

	              END
            END
        END
      ELSE  -- jika di tabel mapping tidak ditemukan peserta tsb atau ditemukan lebih dari 1 no_peserta yg baru
        PRINT 'Error peserta. No Klaim: ' + @no_klaim    
    END
  
  FETCH NEXT FROM list_cursor INTO @no_klaim  
END  

CLOSE list_cursor  
DEALLOCATE list_cursor 


SELECT
  *
FROM
  @hasil


SELECT
  *
INTO
  dbo.tmp_prib_pindah_klaim_hasil
FROM
  @hasil

