SQL QUERY: HOW TO IDENTIFY EXPIRED CREDIT CARDS BEFORE IT TRIES TO BILL TO THE CUSTOMERS.

Hello expert,
Wish collinsAsked:
Who is Participating?
 
ste5anConnect With a Mentor Senior DeveloperCommented:
Still only guessing:

CREATE PROCEDURE p_BillCreditCard
(
    @Amoung money,
    @CreditCardNumber nvarchar(255)
)
AS
    SET NOCOUNT ON;
    SET XACT_ABORT ON;

    -- Constants.
    DECLARE @CREDITCARD_EXPIRED int = 1;
    DECLARE @NO_ERROR int = 0;
    DECLARE @GENERIC_ERROR int = 55555;

    BEGIN TRY
        IF EXISTS(  SELECT C.*
                    FROM CreditCards C
                    WHERE C.ExpiresDate <= GETDATE()
                        AND C.CreditCardNumber = '12312321312')
        BEGIN
            RETURN @CREDITCARD_EXPIRED;
        END;

        -- Your billing code.
        RETURN @NO_ERROR;
    END TRY
    BEGIN CATCH
        IF @@trancount > 0
            ROLLBACK TRANSACTION;
        RETURN @GENERIC_ERROR;
    END CATCH;

Open in new window

1
 
ste5anSenior DeveloperCommented:
It's hard to guess without context.. something like

SELECT C.*
FROM CreditCards C
WHERE C.ExpiresDate <= GETDATE();

Open in new window


or a specific one


SELECT C.*
FROM CreditCards C
WHERE C.ExpiresDate <= GETDATE()
AND C.CreditCardNumber = '12312321312';

Open in new window

0
 
Wish collinsAuthor Commented:
Hello, I'm trying to write a stored procedure  to identify expired credit card before it tries to bill to the customers.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
Justin EvansCommented:
Hi Wish,  

Can you paste what stored procedure you have so far?
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
Where do you store the credit card information? It should also have the expiration date stored, right?
0
 
Wish collinsAuthor Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.