GRIMS Update names

From ICISWiki

Jump to: navigation, search

Update NAMES Table

The procedure is executed whenever a change is made on name values.

Name types affected:

  • 6 - cultivar name
  • 8 - species name
  • 9 - collector's number
  • 10 - donor code / foreign accession number

CREATE OR REPLACE PROCEDURE upd_names(xOval varchar2, xNval varchar2, xgid number, xntype int,xLoc number, xuserid int) IS

		xNid number;
begin

	 /******************************
	 update the names table
	 *******************************/


	 xnid:=get_nid(xGid,xntype);
	 
	 if xnid is not null then begin
	 	if xnval is not null then begin  
					update names
					set nval=xnval
					where gid=xgid and ntype=xntype;
			end;			
		else begin
			 	  	update names
					set nstat=9
					where nid=xNID;
			end;
		end if;
		 
		insert into changes 
		 	select 
				   changes_seq.nextval,
				   'NAMES',
				   'NVAL',				   
				   xNID,
				   xNID,
				   xNID,
				   to_number(to_char(sysdate,'YYYYMMDD')),
				   0,
				   null,
				   xuserid,				   
				   0,
				   0,
				   'Trigger update'
		   from dual;
			   
		end;
	else begin
		 insert into names
		 	  select  
		 		names_seq.nextval,
				xgid,
				xntype,
				decode(xntype,6,1,0),
				xuserid,
				xnval,
				xLoc,
				to_number(to_char(sysdate,'YYYYMMDD')),
				0,
				1
			  from dual;		
		 
		 end;
	end if;

end;
/
Personal tools