Home » Developer & Programmer » Forms » problem with invoice number generation
problem with invoice number generation [message #520692] Wed, 24 August 2011 01:38 Go to next message
0204ag
Messages: 11
Registered: August 2011
Location: Bahrain
Junior Member
hi,
i an using this code to generate invoice numbers auntomatically:

declare
po number;
pi number;
begin
select max(inv_no)
into po
from inv_hdr;
if po is null then
pi := 1;
:inv_hdr.minv_no := pi;
else
po := po +1;
:inv_hdr.minv_no := po;
end if;
end;

Problem is it does not increment after 10.
Please help.
Thanks.
Re: problem with invoice number generation [message #520705 is a reply to message #520692] Wed, 24 August 2011 03:14 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
Check the length of your form variable ":inv_hdr.minv_no".
Re: problem with invoice number generation [message #520706 is a reply to message #520705] Wed, 24 August 2011 03:18 Go to previous messageGo to next message
dude4084
Messages: 222
Registered: March 2005
Location: Mux
Senior Member
is the invoice no 9 being saved?


and well what about using following code?

Quote:
Select nvl(max(inv_no),0)+1
into :inv_hdr.minv_no
from inv_hdr;



-Dude
Re: problem with invoice number generation [message #520720 is a reply to message #520706] Wed, 24 August 2011 04:40 Go to previous messageGo to next message
0204ag
Messages: 11
Registered: August 2011
Location: Bahrain
Junior Member
Nope it doesn't work. Doesn't increment after 10.

And length of the column and variable are same - 20
Re: problem with invoice number generation [message #520721 is a reply to message #520720] Wed, 24 August 2011 04:47 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
The variable isn't length 20.

Regardless - there's no obvious reason why your code shouldn't work, so you're going to have to debug it.
Put messages in the code to check what po is being sete to.
Re: problem with invoice number generation [message #520835 is a reply to message #520720] Wed, 24 August 2011 23:30 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
My dear friend, does it showing any error before or after generating the number.
Re: problem with invoice number generation [message #520836 is a reply to message #520835] Thu, 25 August 2011 00:20 Go to previous messageGo to next message
0204ag
Messages: 11
Registered: August 2011
Location: Bahrain
Junior Member
no there are no errors, just that it doesn't increment after 10 it remains 10.
Re: problem with invoice number generation [message #520837 is a reply to message #520836] Thu, 25 August 2011 00:44 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
My dear friend please send me the exact code that you are using for this logic. Please also write on which event you are using this code.

One more thing my friend why are you using two variables "pi" and "po" for incrementing number.

I mean why are you not using one variable.

[Updated on: Thu, 25 August 2011 00:46]

Report message to a moderator

Re: problem with invoice number generation [message #520841 is a reply to message #520837] Thu, 25 August 2011 00:58 Go to previous messageGo to next message
0204ag
Messages: 11
Registered: August 2011
Location: Bahrain
Junior Member
I ahve put the code when i posted this message. U can check there and i am using this in the when-new-form-instance trigger.
Re: problem with invoice number generation [message #520847 is a reply to message #520841] Thu, 25 August 2011 01:41 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
You are using two variables that hold incremented invoice number on conditional bases.

I think you should check your code. After the generation of the invoice number are you taking the right varibale value for new invoice number.
Re: problem with invoice number generation [message #520858 is a reply to message #520847] Thu, 25 August 2011 02:59 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
Why are you using when-new-form-instance?
I'd put this code in pre-insert.
Re: problem with invoice number generation [message #520861 is a reply to message #520858] Thu, 25 August 2011 03:07 Go to previous messageGo to next message
0204ag
Messages: 11
Registered: August 2011
Location: Bahrain
Junior Member
because i wanted the invoice number to be seen when i start the form.
Re: problem with invoice number generation [message #520866 is a reply to message #520861] Thu, 25 August 2011 03:15 Go to previous message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
But that means the invoice number is only generated when the form starts. So to enter another record you first have to exit the form.
Previous Topic: user defined Function key
Next Topic: clearing the form after commit
Goto Forum:
  


Current Time: Wed Aug 21 16:10:44 CDT 2024