Launch the same item in the current transaction

Dicas do Oracle Forms Builder - Blocos, Itens, LOV, Canvas, Triggers, comandos, PLL, d2kwutil, FMB, Alert, menus, etc
Post Reply
davidcastilholi
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 47
Joined: Thu, 07 Apr 2011 3:54 pm
Location: Jussara PR
David

Good afternoon everyone, my question is: How do I treat the time to launch the items not to let the same item launch in the transaction?

Thanks in advance
davidcastilholi
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 47
Joined: Thu, 07 Apr 2011 3:54 pm
Location: Jussara PR
David

nobody ?
gfkauer
Rank: DBA Sênior
Rank: DBA Sênior
Posts: 389
Joined: Tue, 27 Jul 2010 1:34 pm
Location: Sapiranga - RS
Contact:
Quem falou que programar era fácil??

Quanto mais dificil for a implementação mais valorizado seu trabalho será!

Acessem: www.gfkauer.com.br

Could it be a bit more specific?

For if you refer to inserting a record twice, this can control of no ways, the simplest is with the creation of PKs. But I do not think I understood your needs correctly. Try detailing a little more than I try to help you.
davidcastilholi
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 47
Joined: Thu, 07 Apr 2011 3:54 pm
Location: Jussara PR
David

I want to deal with the following way, the guy will make a sale and launches item 1, then if he tries to release item 1 again, I want a message that the item has already been released, forcing it to enter another item.

I know that I can treat the primary keys, but I want to handle this at the output of the field.

Thanks.
gfkauer
Rank: DBA Sênior
Rank: DBA Sênior
Posts: 389
Joined: Tue, 27 Jul 2010 1:34 pm
Location: Sapiranga - RS
Contact:
Quem falou que programar era fácil??

Quanto mais dificil for a implementação mais valorizado seu trabalho será!

Acessem: www.gfkauer.com.br

Question, why do not you automate the item's numeration? Or the user can type

Select all

Item 1 
Item 2 
Item 7 
Item 10 
Item 23451
davidcastilholi
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 47
Joined: Thu, 07 Apr 2011 3:54 pm
Location: Jussara PR
David

The user will enter the item number that is nothing more than the code. of the product being inserted into the sale.

I have the following entities:

Entity - TB_Product
Field - CD_Product PK

Entity - TB_ItemVenda
Field - CD_Product PFK
Field - CD_VENDA PFK

Entity - TB_VENDA
Field - CD_VENDA PK

I have to treat so that the user does not bid the same item on the same sale, he can even launch Dai would have to update the quantities.

I have 2 ideas: Show msg to the user saying that the item has already been released, or updating the amount of sale

How would you do this?
gfkauer
Rank: DBA Sênior
Rank: DBA Sênior
Posts: 389
Joined: Tue, 27 Jul 2010 1:34 pm
Location: Sapiranga - RS
Contact:
Quem falou que programar era fácil??

Quanto mais dificil for a implementação mais valorizado seu trabalho será!

Acessem: www.gfkauer.com.br

Well, if you have not yet saved the records you would have to sweep all the other lines already entered, but this is not always possible, since you can have other various information to be informed obligations.

What would I do?
Create a GTT (Global Temporary Table) with only one column that would receive the product / item number. For this, inside the Trigger When-validate-code field of the code I would make a SELECT in the global table validating if this code already exists, if it does not exist to make an insert in the global table.

When you insert a second time the same item, my select validation would already see this record in the GTT, then yes you can issue a message to the user.
Complicated, perhaps, but it is the first solution that comes in mind.
davidcastilholi
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 47
Joined: Thu, 07 Apr 2011 3:54 pm
Location: Jussara PR
David

Thank you, man, I'll do it and test ...
davidcastilholi
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 47
Joined: Thu, 07 Apr 2011 3:54 pm
Location: Jussara PR
David

Hello everyone, I found a way to validate the user not to launch the same item in the transaction, and would like to share with all ...

I did the following Select:

Select all

DECLARE 
	V_REG NUMBER(10); 
BEGIN 
  	SELECT COUNT(*) 
  	       INTO V_REG 
           FROM TB_ITEMPRODUTO 
                WHERE CD_TRANSACAO = :TB_ITEMPRODUTO.CD_TRANSACAO 
                  AND CD_PRODUTO   = :TB_ITEMPRODUTO.CD_PRODUTO; 
	 IF V_REG > 0 THEN 
   	    MESSAGE('Item já lançado na transação'); 
   	    :TB_ITEMPRODUTO.CD_BARRA :=NULL; 
   	    :TB_ITEMPRODUTO.DS_PRODUTO :=NULL; 
   	    :TB_ITEMPRODUTO.TP_ESPECIE :=NULL; 
   	    :TB_ITEMPRODUTO.VL_UNITARIO :=NULL; 
   	    RAISE FORM_TRIGGER_FAILURE; 
END IF; 
END;
and Trigger When-New-Record-Instance of the TB_ItemProduct block, I made the command to make inserts and updates in the bank of changes made in forms, but does not give the Commit .

worked right.

and thank you "gfkauer" for help ... [/b]
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 12 guests