We help IT Professionals succeed at work.
Get Started

error in my pre-query

164 Views
Last Modified: 2018-02-02
hi am having this error in my pre-query trigger ORA-00918: column ambiguously defined
SELECT CODE,DESCRIPTION,DESCRIPTION2 FROM (select ASS_APPL_CODE CODE,ASS_APPL_CODE CODE,ASS_APPL_DESC DESCRIPTION,ASS_APPL_DESC DESCRIPTION,null DESCRIPTION2 from IM_L_ASSOC_APPL_CODE order by 1)

the trigger code is
declare
	cursor c  is 
	    select column_name, column_id from all_tab_columns where table_name=:control.reftable and column_id<=3 order by column_id;
  r c%rowtype;	    
	
	q varchar2(2000) := '(select ';
	
	type arr is varray(3) of varchar2(50);
  arrv arr := arr('CODE', 'DESCRIPTION', 'DESCRIPTION2');
begin
	:control.column1:=null;
	:control.column2:=null;
	:control.column3:=null;

  open c ;
  loop
  	 fetch c into r;
  exit when c%notfound;	 
      q := q  || r.column_name||' '|| arrv(r.column_id)||',';
      if r.column_id = 1 then
      	:control.column1:=r.column_name;
      end if;
      
      if r.column_id = 2 then
      	:control.column2:=r.column_name;
      end if;
      
      if r.column_id = 3 then
      	:control.column3:=r.column_name;
      end if;
  end loop;

  if r.column_id=2 then
  	q := q  || 'null' ||' '|| arrv(3)||',';
  end if;
  
  q := substr(q,1,length(q)-1) || ' from '||:control.reftable||' order by 1)';

  set_block_property ('LIST',query_data_source_name,q);
  
  if 	:control.column3 is null then
  	  set_item_property ('LIST.DESCRIPTION2',VISIBLE,property_false);
  	  set_item_property ('LIST.DESCRIPTION',width,385);
  else
  	  set_item_property ('LIST.DESCRIPTION2',visible,property_true);
  	  set_item_property ('LIST.DESCRIPTION2',enabled,property_true);
  	  set_item_property ('LIST.DESCRIPTION2',insert_allowed,property_true);
  	  set_item_property ('LIST.DESCRIPTION2',update_allowed,property_true);
  	  set_item_property ('LIST.DESCRIPTION2',navigable,property_true);
  	 
  	  set_item_property ('LIST.DESCRIPTION',width,192);
  end if;	
  close c;
end; 

Open in new window


am in 11g
i think the error is beacause the table column has change its no longer code description am in 11g
Comment
Watch Question
johnsoneSenior Oracle DBA
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 6 Answers and 13 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE