Home » Developer & Programmer » Forms » Error in view
Error in view [message #467998] Wed, 28 July 2010 08:51 Go to next message
Amar_bu
Messages: 32
Registered: July 2010
Location: riyadh
Member
I have an erorr and i could not discover it. any help ????


create view Employee_other as
(select tel_employee.Badage As badge,tel_employee.emp_office_id as office,tel_offices.office_name_en as office_name
,tel_offices.city_code as city_code,tel_offices.country_code as country_code,tel_offices.office_tel as office_tel
,tel_employee.first_name ||tel_employee.family_name as name ,tel_employee.remarks as remarks,
tel_employee_info.Info_text_en,tel_info_types.info_type_desc_en
from tel_employee ,tel_employee_info, tel_info_types, tel_offices
where tel_employee.emp_id=tel_employee_info.emp_id and tel_employee_info.info_type_id=tel_info_types.info_type_id
and tel_employee.emp_office_id=tel_offices.office_id
Union ALL
select null as badge , null as Office, null as office_name , tel_other.city_code as city_code,
tel_other.country_code as country_code ,null as office_tel, tel_other.other_name_en as name , tel_other.remarks as remarks,
tel_other_info.Info_text_en,tel_info_types.info_type_desc_en
from tel_other ,tel_other_info, tel_info_types
where tel_other.other_id=tel_other_info.other_id and tel_other_info.info_type_id=tel_info_types.info_type_id ) ;
Re: Error in view [message #468000 is a reply to message #467998] Wed, 28 July 2010 08:58 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
Are we supposed to guess what the error message is?
Re: Error in view [message #468002 is a reply to message #468000] Wed, 28 July 2010 09:22 Go to previous messageGo to next message
ranamirfan
Messages: 535
Registered: January 2006
Location: Pakistan / Saudi Arabia
Senior Member

When UNION operator is used to combine the result-set of two or more SELECT statements.
then each SELECT statement within the UNION must have the same number of columns. The columns must also have similar data types. Also, the columns in each SELECT statement must be in the same order.



Re: Error in view [message #468020 is a reply to message #467998] Wed, 28 July 2010 11:14 Go to previous messageGo to next message
Amar_bu
Messages: 32
Registered: July 2010
Location: riyadh
Member
I have two different tables what they have required from me to join them in one view and to make form on it which allow the user to search...when i told them that this can not be done becuase the field are different they told me that i can put where no same fiel select null..Is this is correct
for example
if i want to combine the value of two table employee and other
if i use the following statment
select emp_id as "id", emp_office_id as "office from employee
union all
select other_id as "id" , null as "office" from other ;
Is this is right?
becuase it is give me error corresponding object must have same datatype is there any solution/?
Re: Error in view [message #468023 is a reply to message #468020] Wed, 28 July 2010 11:19 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
Is emp_office_id a number?
null defaults to varchar2
try:
select emp_id as "id", emp_office_id as "office" from employee 
union all 
select other_id as "id" , to_number(null) as "office" from other ;


And can you have a read of the orafaq forum guide and follow what it says about formatting posts in future please.
Re: Error in view [message #468024 is a reply to message #468023] Wed, 28 July 2010 11:21 Go to previous messageGo to next message
Amar_bu
Messages: 32
Registered: July 2010
Location: riyadh
Member
It is number...so if i use to_char(emp_office_id)it will work right?
Re: Error in view [message #468026 is a reply to message #468024] Wed, 28 July 2010 11:25 Go to previous messageGo to next message
Amar_bu
Messages: 32
Registered: July 2010
Location: riyadh
Member
Thanks it works
Re: Error in view [message #468027 is a reply to message #468026] Wed, 28 July 2010 11:28 Go to previous message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
I'd use to_number like I suggested over to_char.
Previous Topic: Ora-01403 error
Next Topic: Form Closes While Compiling
Goto Forum:
  


Current Time: Fri Sep 20 03:43:44 CDT 2024