--oracle
DECLARE
CNT PLS_INTEGER;
BEGIN
SELECT COUNT (*) FCOUNT
INTO CNT
FROM (SELECT 1
FROM LT_HS_AccountOpenCloseExt
WHERE (FACCTSYSID = 1 AND FSTOCKORGNO = 1) AND ROWNUM <= 1);
IF CNT = 0
THEN
EXECUTE IMMEDIATE
'INSERT INTO LT_HS_AccountOpenCloseExt VALUES (1, 1, 1,''2015-06-28 02:03:0'', ''1'')';
ELSE
EXECUTE IMMEDIATE
'UPDATE LT_HS_AccountOpenCloseExt SET FUSER = 2, FOPERATESTART =''2015-06-28 02:03:0'', FOPERATEEND =''1'' WHERE (FACCTSYSID = 1 AND FSTOCKORGNO = 1)';
END IF;
END;
--sql server
IF NOT EXISTS (SELECT 1 FROM LT_HS_AccountOpenCloseExt WHERE (FACCTSYSID = 1 AND FSTOCKORGNO = 1))
BEGIN
INSERT INTO LT_HS_AccountOpenCloseExt VALUES (1, 1, 1, '1', '1')
END
ELSE
BEGIN
UPDATE LT_HS_AccountOpenCloseExt SET FUSER = 1, FOPERATESTART = '1', FOPERATEEND = '1' WHERE (FACCTSYSID = 1 AND FSTOCKORGNO = 1)
END;