TheNewbie81
Technical User
Hi i have a SP below.
which does the following,
it takes a triplet of values (msisdn,imei, imsi) and based on the timestamp with the triplet either inserts into table A or Updates the Triplet Timestamp in table A if exists, while also writing to Table B.
A = ACTIVE_HANDSETS
B = ACTIVE_HANDSETS_NEW.
C = ACTIVE_HANDSETS_ONCE
I need this to change as follows... but im not sure about the best way of doing this with the SP i have below.
new triplet comes in
If New, does not exist write to A
Write to B and write to C
another triplet comes in, if triplet exists
update timestamp on A for triplet
based on MSISDN see if there is already an entry in B and if the IMEI and IMSI are different. delete existing triplet if this is true and insert new triplet then send this triplet to C.
any advice or tips are welcome.
which does the following,
it takes a triplet of values (msisdn,imei, imsi) and based on the timestamp with the triplet either inserts into table A or Updates the Triplet Timestamp in table A if exists, while also writing to Table B.
A = ACTIVE_HANDSETS
B = ACTIVE_HANDSETS_NEW.
C = ACTIVE_HANDSETS_ONCE
I need this to change as follows... but im not sure about the best way of doing this with the SP i have below.
new triplet comes in
If New, does not exist write to A
Write to B and write to C
another triplet comes in, if triplet exists
update timestamp on A for triplet
based on MSISDN see if there is already an entry in B and if the IMEI and IMSI are different. delete existing triplet if this is true and insert new triplet then send this triplet to C.
Code:
CREATE OR REPLACE PROCEDURE UPDATE_INSERT_LAST_CALL(
val_msisdn IN VARCHAR2,
val_imei IN VARCHAR2,
val_imsi IN VARCHAR2,
val_call_date IN VARCHAR2)
AS
val_count NUMBER;
BEGIN
SELECT count(*) INTO val_count
FROM ACTIVE_HANDSETS
WHERE MSISDN = val_msisdn
AND IMEI = val_imei
AND IMSI = val_imsi;
IF(val_count > 0)
THEN
UPDATE ACTIVE_HANDSETS
SET MOST_RECENT_CDR_DATE = TO_DATE(val_call_date, 'YYYY-MM-DD HH24:MI:SS')
WHERE MSISDN = val_msisdn
AND IMEI = val_imei
AND IMSI = val_imsi;
ELSE
INSERT INTO ACTIVE_HANDSETS
VALUES(val_msisdn, val_imei, val_imsi, TO_DATE(val_call_date, 'YYYY-MM-DD HH24:MI:SS'),
TO_DATE(val_call_date, 'YYYY-MM-DD HH24:MI:SS'));
INSERT INTO ACTIVE_HANDSETS_NEW
VALUES(val_msisdn, val_imei, val_imsi, 0);
END IF;
END;
/
any advice or tips are welcome.