I'm using Nhibernate version v2.0.50727.
I'm trying generate ID by trigger in ORACLE 10g.
Below my code of Trigger:
create or replace
TRIGGER LAB_TRIGGER_PEDIDOEXAME
BEFORE INSERT ON LAB_PEDIDO
FOR EACH ROW
DECLARE
number_pedido varchar(20);
BEGIN
SELECT MAX(NUMERO_PEDIDO) into number_pedido FROM LAB_PEDIDO WHERE
NUMERO_PEDIDO LIKE (''||(to_char(SYSDATE, 'YYYYMMDD') || '%'));
if number_pedido is null then -- Case not have a number for date, this
first
number_pedido := (to_char(SYSDATE, 'YYYYMMDD') || '0001');
else
number_pedido := number_pedido + 1;
end if;
:new.NUMERO_PEDIDO := number_pedido;
END LAB_TRIGGER_PEDIDOEXAME;
In the mapping .hbm.xml I do not know for Save(), because the version i
using does not support <generator class="select">, much less <generator
class="trigger-identity">.
Can anyone help me with this problem.
Thank you!