17th Nov 2008
Dead x0x
Just finished my full 10-hour work for the day…working on this thing called “CCReconciler”, a web application that checks to see if there is any duplicated charges for any customer’s trasnaction. I spent almost the entire day today and couple hours yesterday (Sunday) just to figure this thing out…it’s a monster, consider that I’ve never been a really good SQL programmer, and I was trying to figure out this rather crazy looking stored procedure. Here is about 50% of it(not posting it all for security reasons, also removed passwords):
CREATE procedure sp_Reconcile_To_FlexLeagues
@start_date as datetime
, @end_date as datetime
, @import_temp_data as bit
AS
IF @import_temp_data = 1
BEGIN
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N’[dbo].[TEMP_FL_TRANSACTIONS]‘) and OBJECTPROPERTY(id, N’IsUserTable’) = 1)
DROP TABLE [dbo].[TEMP_FL_TRANSACTIONS]
SELECT * INTO TEMP_FL_TRANSACTIONS FROM
OPENDATASOURCE(’SQLOLEDB’,'Extended Properties=”DRIVER=SQL Server;SERVER=BURUSTA-DB05;DATABASE=FlexLeagues;UID=CrystalReports;PWD=”‘).FlexLeagues.dbo.FL_CCTransaction
WHERE CreatedDateStamp >= DATEADD(Hour,-1,@start_date) and CreatedDateStamp <= DATEADD(Hour,1,@end_date)
END
IF exists (SELECT * FROM dbo.sysobjects where id = object_id(N’[dbo].[TEMP_FL_CORRECTIVE_ACTION]‘) and OBJECTPROPERTY(id, N’IsUserTable’) = 1)
DROP TABLE [dbo].[TEMP_FL_CORRECTIVE_ACTION]
SELECT * INTO TEMP_FL_CORRECTIVE_ACTION FROM
(
SELECT
‘Corrective_Action’ = CASE
WHEN FL.PaymentID is null THEN ‘Reverse’
ELSE ‘None’
END
, CCP.*
, ISNULL(CCP.datestamp,FL.CreatedDateStamp) FLccp_datestamp
, FL.TransactionResultID, FL.AMSAccountID
, FL.CardHolderName
FROM
AMS_TRANSACTION_LOOKUP as CCP
LEFT JOIN TEMP_FL_TRANSACTIONS as FL
ON
CONVERT(varchar(60), FL.PaymentID) = CCP.invoice_number AND FL.AMSTransactionID = ccp.ams_transaction_id
–left join TEMP_FL_TRANSACTIONS as FL2 ON FL2.PaymentID = CCP.invoice_number –to get the credit card name
WHERE
CCP.application_merchant = ‘USTA FLEXLGS’
AND
( ((FL.CreatedDateStamp > DATEADD(Hour,-1,@start_date) and FL.CreatedDateStamp < DATEADD(Hour,1,@end_date)) and FL.TransactionResultID = 1) — ‘1′ = Approved
OR
((CCP.datestamp > DATEADD(Hour,-1,@start_date) and CCP.datestamp < DATEADD(Hour,1,@end_date)) and CCP.web_auth_result_code in (’AA’))
)
UNION
– BEGIN Flex Leagues Duplicate Charges to Investigate
SELECT
‘Corrective_Action’ = ‘Investigate’
, CCP.*
, isnull(CCP.datestamp,FL.CreatedDateStamp) FLccp_datestamp
, FL.TransactionResultID, FL.AMSAccountID
, FL.CardHolderName
FROM AMS_TRANSACTION_LOOKUP as CCP
RIGHT OUTER JOIN (
–get the full cc records with all columns
SELECT * FROM OPENDATASOURCE(’SQLOLEDB’,'Extended Properties=”DRIVER=SQL Server;SERVER=BURUSTA-DB05;DATABASE=FlexLeagues;UID=CrystalReports;PWD=”‘).FlexLeagues.dbo.FL_CCTransaction
where CCTransactionID IN (
–get list of CCTransationIDs that are associated with the invoice_id that we found
SELECT distinct cc.CCTransactionID FROM OPENDATASOURCE(’SQLOLEDB’,'Extended Properties=”DRIVER=SQL Server;SERVER=BURUSTA-DB05;DATABASE=FlexLeagues;UID=CrystalReports;PWD=”‘).FlexLeagues.dbo.FL_CCTransaction cc
INNER JOIN (
–find dup charges and get the PaymentID
SELECT FLPD.PaymentID, FLPD.PaymentDetailID, FLPD.Amount
FROM OPENDATASOURCE(’SQLOLEDB’,'Extended Properties=”DRIVER=SQL Server;SERVER=BURUSTA-DB05;DATABASE=FlexLeagues;UID=CrystalReports;PWD=”‘).FlexLeagues.dbo.FL_PaymentDetail FLPD
So there you go, 1x hours of work there. 1x hours of my life is gone, and I’m going to head out to replenish my HP before I die.
Just finished my full 10-hour work for the day…working on this thing called “CCReconciler”, a web application that checks to see if there is any duplicated charges for any customer’s trasnaction. I spent almost the entire day today and couple hours yesterday (Sunday) just to figure this thing out…it’s a monster, consider that I’ve never been a really good SQL programmer, and I was trying to figure out this rather crazy looking stored procedure. Here is about 50% of it(not posting it all for security reasons, also removed passwords):
CREATE procedure sp_Reconcile_To_FlexLeagues
@start_date as datetime
, @end_date as datetime
, @import_temp_data as bit
ASIF @import_temp_data = 1
BEGIN
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N’[dbo].[TEMP_FL_TRANSACTIONS]‘) and OBJECTPROPERTY(id, N’IsUserTable’) = 1)
DROP TABLE [dbo].[TEMP_FL_TRANSACTIONS]SELECT * INTO TEMP_FL_TRANSACTIONS FROM
OPENDATASOURCE(’SQLOLEDB’,'Extended Properties=”DRIVER=SQL Server;SERVER=BURUSTA-DB05;DATABASE=FlexLeagues;UID=CrystalReports;PWD=”‘).FlexLeagues.dbo.FL_CCTransaction
WHERE CreatedDateStamp >= DATEADD(Hour,-1,@start_date) and CreatedDateStamp <= DATEADD(Hour,1,@end_date)
ENDIF exists (SELECT * FROM dbo.sysobjects where id = object_id(N’[dbo].[TEMP_FL_CORRECTIVE_ACTION]‘) and OBJECTPROPERTY(id, N’IsUserTable’) = 1)
DROP TABLE [dbo].[TEMP_FL_CORRECTIVE_ACTION]SELECT * INTO TEMP_FL_CORRECTIVE_ACTION FROM
(
SELECT
‘Corrective_Action’ = CASE
WHEN FL.PaymentID is null THEN ‘Reverse’
ELSE ‘None’
END
, CCP.*
, ISNULL(CCP.datestamp,FL.CreatedDateStamp) FLccp_datestamp
, FL.TransactionResultID, FL.AMSAccountID
, FL.CardHolderName
FROM
AMS_TRANSACTION_LOOKUP as CCP
LEFT JOIN TEMP_FL_TRANSACTIONS as FL
ON
CONVERT(varchar(60), FL.PaymentID) = CCP.invoice_number AND FL.AMSTransactionID = ccp.ams_transaction_id
–left join TEMP_FL_TRANSACTIONS as FL2 ON FL2.PaymentID = CCP.invoice_number –to get the credit card name
WHERE
CCP.application_merchant = ‘USTA FLEXLGS’
AND
( ((FL.CreatedDateStamp > DATEADD(Hour,-1,@start_date) and FL.CreatedDateStamp < DATEADD(Hour,1,@end_date)) and FL.TransactionResultID = 1) — ‘1′ = Approved
OR
((CCP.datestamp > DATEADD(Hour,-1,@start_date) and CCP.datestamp < DATEADD(Hour,1,@end_date)) and CCP.web_auth_result_code in (’AA’))
)UNION
– BEGIN Flex Leagues Duplicate Charges to Investigate
SELECT
‘Corrective_Action’ = ‘Investigate’
, CCP.*
, isnull(CCP.datestamp,FL.CreatedDateStamp) FLccp_datestamp
, FL.TransactionResultID, FL.AMSAccountID
, FL.CardHolderName
FROM AMS_TRANSACTION_LOOKUP as CCP
RIGHT OUTER JOIN (
–get the full cc records with all columns
SELECT * FROM OPENDATASOURCE(’SQLOLEDB’,'Extended Properties=”DRIVER=SQL Server;SERVER=BURUSTA-DB05;DATABASE=FlexLeagues;UID=CrystalReports;PWD=”‘).FlexLeagues.dbo.FL_CCTransaction
where CCTransactionID IN (
–get list of CCTransationIDs that are associated with the invoice_id that we found
SELECT distinct cc.CCTransactionID FROM OPENDATASOURCE(’SQLOLEDB’,'Extended Properties=”DRIVER=SQL Server;SERVER=BURUSTA-DB05;DATABASE=FlexLeagues;UID=CrystalReports;PWD=”‘).FlexLeagues.dbo.FL_CCTransaction cc
INNER JOIN (
–find dup charges and get the PaymentID
SELECT FLPD.PaymentID, FLPD.PaymentDetailID, FLPD.Amount
FROM OPENDATASOURCE(’SQLOLEDB’,'Extended Properties=”DRIVER=SQL Server;SERVER=BURUSTA-DB05;DATABASE=FlexLeagues;UID=CrystalReports;PWD=”‘).FlexLeagues.dbo.FL_PaymentDetail FLPD
So there you go, 1x hours of work there. 1x hours of my life is gone, and I’m going to head out to replenish my HP before I die.
Posted in Uncategorized | No Comments » ↑↑ Back to Top ↑↑





















