MySQL Forums
Forum List  »  InnoDB

My 1st Transaction Took code from a VB project
Posted by: Barry Pranklin
Date: March 01, 2010 12:33AM

Hi,

If someone can help that would be great.

I am trying to generate a case number eg. AAAA0001 then AAAA0002 etc.

This is my code and thanks for any help (Line Marked with <-- ERROR HERE):

BEGIN
DECLARE A1, A2, A3, A4 VARCHAR(1);
DECLARE Numbers INTEGER;
DECLARE CaseNum, NextCaseNum VARCHAR(8);

SET CaseNum = "AAAA0000";

SET CaseNum = UCase(CaseNum);


SET A1 = Mid(CaseNum, 1, 1);
SET A2 = Mid(CaseNum, 2, 1);
SET A3 = Mid(CaseNum, 3, 1);
SET A4 = Mid(CaseNum, 4, 1);

SET Numbers = Mid(CaseNum, 5)

If Numbers = 9999 Then //<--ERROR HERE!!!!!!!!!!!!!!!!!!!!!
SET Numbers = 1;

If Ascii(A4) = 90 Then
SET A4 = "A";

If Asc(A3) = 90 Then
SET A3 = "A";

If Asc(A2) = 90 Then
A2 = "A";

If Asc(A1) = 90 Then
SET A1 = "A";
Else
SET A1 = Char(Asc(A1) + 1);
End If

Else
SET A2 = Char(Asc(A2) + 1);
End If

Else
SET A3 = Char(Asc(A3) + 1);
End If

Else
A4 = Char(Asc(A4) + 1);
End If

Else
Numbers = Numbers + 1;
End If


NextCaseNum = A1 & A2 & A3 & A4 & Right("0000" & Numbers, 4);

END

Options: ReplyQuote


Subject
Views
Written By
Posted
My 1st Transaction Took code from a VB project
2646
March 01, 2010 12:33AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.