Home » Developer & Programmer » Forms » HOW GENERATE ITEM CODE CONCATENATE WITH MAIN ITEM AND SUB ITEM (merged 2) (ORACLE, DEV6i, XP)
icon4.gif  HOW GENERATE ITEM CODE CONCATENATE WITH MAIN ITEM AND SUB ITEM (merged 2) [message #538452] Fri, 06 January 2012 02:21 Go to next message
ranafsd
Messages: 4
Registered: January 2012
Location: Pakistan
Junior Member

I AM TRYING TO GENERATE ITEM CODE CONCATENATE WITH MAIN ITEM AND SUB ITEM, I GOT SUCCESS TO CONCATENATE BUT I M NOT GETTING THE ITEM CODE SEQUENCE.

declare
v_item varchar2(10);

begin
select nvl(max(itemcode),0)+1 into v_item from R_item where mccode=:mccode and sccode=:sccode;
:ITEMCODE:=:MCCODE||'-'||:SCCODE||'-'||v_item;
end;

ITEMCODE = ITEM
MCCODE = MAINITEM
SCCODE = SUBITEM
  • Attachment: ITEM.JPG
    (Size: 56.29KB, Downloaded 710 times)
Re: HOW GENERATE ITEM CODE CONCATENATE WITH MAIN ITEM AND SUB ITEM [message #538454 is a reply to message #538452] Fri, 06 January 2012 02:27 Go to previous messageGo to next message
John Watson
Messages: 8944
Registered: January 2010
Location: Global Village
Senior Member
Welcome to the forum - I hope you will both learn and contribute (as I try to do). Please read our OraFAQ Forum Guide and How to use [code] tags and make your code easier to read And lastly, please do not post in upper case, this is painful to read and considered rude on professional forums.
icon4.gif  Concatenation of Master Item,Sub Item and Generate Item Code [message #538466 is a reply to message #538452] Fri, 06 January 2012 06:02 Go to previous messageGo to next message
ranafsd
Messages: 4
Registered: January 2012
Location: Pakistan
Junior Member

how to generate item code concate with master item and sub item? i succeed to concate but item sequence not generating see the code below!

declare
	v_item varchar2(10);
	
	begin
             select nvl(max(itemcode),0)+1
        into v_item
        from R_item
        where mccode=:mccode and sccode=:sccode;
        :ITEMCODE:=:MCCODE||'-'||:SCCODE||'-'||v_item;
   end;


Best Regards,
/forum/fa/9697/0/


  • Attachment: ITEM.JPG
    (Size: 56.29KB, Downloaded 1244 times)
Re: Concatenation of Master Item,Sub Item and Generate Item Code [message #538467 is a reply to message #538466] Fri, 06 January 2012 06:07 Go to previous messageGo to next message
Michel Cadot
Messages: 68675
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Please take care to post in the correct forum.

If your question is related to Forms then post in the Forms forum.

Regards
Michel
Re: Concatenation of Master Item,Sub Item and Generate Item Code [message #538477 is a reply to message #538467] Fri, 06 January 2012 07:36 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
Unless you tell forms to apply each record to the DB as it is entered using either post or commit it won't work.
Those records are only in the form until one of those commands is issued. So a query against the DB will give the same result each time.

But I suggest you use an actual DB sequence instead, that's what they're there for, and if you don't sooner or later two users will generate the same item code at the same time.
Re: Concatenation of Master Item,Sub Item and Generate Item Code [message #538554 is a reply to message #538477] Fri, 06 January 2012 23:44 Go to previous messageGo to next message
ranafsd
Messages: 4
Registered: January 2012
Location: Pakistan
Junior Member

Thanks for reply!
but dear i want to correct the misstake in form level code im new in oracle please help me in this code!

best regards,
Re: Concatenation of Master Item,Sub Item and Generate Item Code [message #538560 is a reply to message #538554] Sat, 07 January 2012 01:43 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
I've told you the mistake. You're running a select to query records the form hasn't applied to the DB.
Forms only applies records to the DB if you issue a post or commit command.
Re: Concatenation of Master Item,Sub Item and Generate Item Code [message #538566 is a reply to message #538560] Sat, 07 January 2012 03:44 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Regarding the screenshot, it appears that ITEMCODE = '1-1-1'. This is not a number, this is a string. It means that code you used (in vain, as you've already being told - it will fail in multiuser environment, sooner or later) won't work at all:
SQL> with test as
  2    (select '1-1-1' col from dual)
  3  select nvl(max(col) ,0) + 1
  4  from test;
select nvl(max(col) ,0) + 1
       *
ERROR at line 3:
ORA-01722: invalid number
Re: Concatenation of Master Item,Sub Item and Generate Item Code [message #538574 is a reply to message #538566] Sat, 07 January 2012 04:58 Go to previous message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
Good point. You should store the last digit of itemcode in the DB and display the concatenated version in the form in a non-database item.
Previous Topic: label change
Next Topic: How to avoid FRM-40401 message?
Goto Forum:
  


Current Time: Sun Sep 08 07:27:34 CDT 2024