Netezza: nvl(row_id,0) is null

when we create sp in Netezza, we may be assign value by 'nvl(row_id,0)'.

Eg:

      DECLARE vStart_ro_id bigint;

      BEGIN vStart_ro_id : = (select nvl(row_id,0) + 1 from table where job_name = 'xxx')

 

But when there is no records satisfied this condition, the value of vStart_ro_id is null. However we want to get 1. So we can do like this :

     BEGIN vStart_ro_id : = (select nvl(max(row_id),0) + 1 from table where job_name = 'xxx')

 

Now check the value of vStart_ro_id.  Good Luck ~~微笑

 

你可能感兴趣的:(NVL,SP,Netezza)