DECLARE @PR棜楌No int
DECLARE @彜昳No int
DECLARE @搊榐僗僞僢僼No int
SET @PR棜楌No = 1
SET @彜昳No = 1
SET @搊榐僗僞僢僼No = 1




---- Fill
--SELECT
--	  H09僾儘儌乕僔儑儞梊掕_懳徾彜昳.慻怐No
--	, H09僾儘儌乕僔儑儞梊掕_懳徾彜昳.PR棜楌No
--	, H09僾儘儌乕僔儑儞梊掕_懳徾彜昳.彜昳No
--	, M02彜昳.彜昳ID
--	, M02彜昳.彜昳柤
--	, M02彜昳.彜昳扨壙
--FROM
--	H09僾儘儌乕僔儑儞梊掕_懳徾彜昳 LEFT OUTER JOIN
--	M02彜昳 ON H09僾儘儌乕僔儑儞梊掕_懳徾彜昳.彜昳No = M02彜昳.彜昳No
--WHERE
--	H09僾儘儌乕僔儑儞梊掕_懳徾彜昳.慻怐No = @慻怐No AND
--	H09僾儘儌乕僔儑儞梊掕_懳徾彜昳.PR棜楌No = @PR棜楌No
SELECT
	H09僾儘儌乕僔儑儞梊掕_懳徾彜昳.僾儘儌乕僔儑儞梊掕_懳徾彜昳No, 
	H09僾儘儌乕僔儑儞梊掕_懳徾彜昳.PR棜楌No, 
	H09僾儘儌乕僔儑儞梊掕_懳徾彜昳.彜昳No,
	M02彜昳.彜昳ID,
	M02彜昳.彜昳柤, 
	M02彜昳.彜昳扨壙
FROM
	H09僾儘儌乕僔儑儞梊掕_懳徾彜昳 LEFT OUTER JOIN
	M02彜昳 ON H09僾儘儌乕僔儑儞梊掕_懳徾彜昳.彜昳No = M02彜昳.彜昳No
WHERE
	H09僾儘儌乕僔儑儞梊掕_懳徾彜昳.PR棜楌No = @PR棜楌No


---- DeleteByPR棜楌No
--DELETE FROM
--	H09僾儘儌乕僔儑儞梊掕_懳徾彜昳
--WHERE
--	慻怐No = @慻怐No AND
--	PR棜楌No = @PR棜楌No
DELETE FROM
	H09僾儘儌乕僔儑儞梊掕_懳徾彜昳
WHERE
	PR棜楌No = @PR棜楌No


---- InsertCommand
--INSERT INTO H09僾儘儌乕僔儑儞梊掕_懳徾彜昳
--(
--	 PR棜楌No
--	,彜昳No
--	,搊榐儐乕僓乕No
--	,搊榐擔帪
--	,峏怴儐乕僓乕No
--	,峏怴擔帪
--)VALUES(
--	 @PR棜楌No
--	,@彜昳No
--	,@搊榐儐乕僓乕No
--	,getdate()
--	,@搊榐儐乕僓乕No
--	,getdate()
--)
INSERT INTO H09僾儘儌乕僔儑儞梊掕_懳徾彜昳
(
	 PR棜楌No
	,彜昳No
	,搊榐僗僞僢僼No
	,搊榐擔帪
	,峏怴僗僞僢僼No
	,峏怴擔帪
)VALUES(
	 @PR棜楌No
	,@彜昳No
	,@搊榐僗僞僢僼No
	,getdate()
	,@搊榐僗僞僢僼No
	,getdate()
)


