0

Hi Im trying to execute a the following query, but its throwing me an error

select 
apex_item.checkbox(1,"EQUIPMENT_ID") Tick,
 ef.equipment_type as "Device Type",
 e.equipment_name as "Device Name",
 ef.equipment_id,
 ef.Customer_Name as "Customer Name",
 ef.Site_Name as "Site Name",
 ef.Managed_Ip as "IP Address",
 dst.discovery_state_name as "Discover State",
 d.Error_Code as "Error Code" ,
 d.Last_Discovery_Time as "Last Discovery Time"
  
  
  from EUIPMENT_FEATURES_MVIEW ef 

  join equipments e
    on e.equipment_id=ef.equipment_id
  join equipment_types et
    on e.equipment_type_id=et.equipment_type_id
  join discovery d
    on d.equipment_id=e.equipment_id
  join discovery_state_lookup dst
    on dst.discovery_state_id=d.discovery_status_id
  
  group by et.equipment_type,
          e.equipment_name,
          ef.equipment_id,
          d.Error_Code ,
          dst.discovery_state_name,
          d.Last_Discovery_Time,
          d.Discovery_Status_Id

where ((:P0_SITE = EUIPMENT_FEATURES_MVIEW.SITE_ID) AND (:P0_CLIENT = EUIPMENT_FEATURES_MVIEW.customer_id))

ef, EUIPMENT_FEATURES_MVIEWis a materialised view which is created as follows

select equipments.equipment_id, 
    
max(case when name='Equipment_Role' then value end) as Equipment_Role,
max(case when name='Equipment_Version' then value end) as Equipment_Version,
max(case when name='SNMP_PORT' then value end) as SNMP_port,
max(case when name='RO_Community_String' then value end) as read_comm_string,
max(case when name='RW_Community_String' then value end) as write_comm_string,
max(case when name='Commisioned_State' then value end) as Commisioned_State,
max(case when name='Customer_Id' then value end) as Customer_Id,
max(case when name='Site_Id' then value end) as Site_Id,
max(case when name='Device_FNN' then value end) as Device_FNN,
max(case when name='IP_Address_Customer' then value end) as IP_Address_Customer,
max(case when name='IP_Address_Managed' then value end) as IP_Address_Managed,
max(case when name='DNS_Name_IP_Managed' then value end) as DNS_Name_IP_Managed,
max(case when name='Equipment_Alias' then value end) as Equipment_Alias,
max(case when name='User_Name' then value end) as User_Name,
max(case when name='Context_Name' then value end) as Context_Name,
max(case when name='Auth_Protocol' then value end) as Auth_Ptotocol,
max(case when name='Auth_Password' then value end) as Auth_Password,
max(case when name='Priv_Password' then value end) as Priv_Password,
max(case when name='Equipment_Model' then value end) as Equipment_Model,
max(case when name='IsManaged' then value end) as IsManaged,
max(case when name='Last_Modified_By' then value end) as Last_Modified_By,
max(case when name='Last_Modified_On' then value end) as Last_Modified_On,
max(case when name='OS_Name' then value end) as OS_Name,
max(case when name='Software_Version' then value end) as Software_Version,
max(case when name='Software_Vendor' then value end) as Software_Vendor,
max(case when name='Registered_CCM' then value end) as Registered_CCM,
max(case when name='Associated_Service' then value end) as Associated_Service,
max(case when name='Capability' then value end) as Capability,
max(case when name='Unified_Msg_App_Type' then value end) as Unified_Msg_App_Type,
max(case when name='Call_Manager_App_Type' then value end) as Call_Manager_App_Type,
max(case when name='Gatekeeper_Type' then value end) as Gatekeeper_Type,
max(case when name='SRST_Type' then value end) as SRST_Type,

from equipments join equipment_feature on equipments.equipment_id = equipment_feature.equipment_id group by equipments.equipment_id

The error Im getting is
Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the ''generic columns'' checkbox below the region source to proceed without parsing. ORA-00933: SQL command not properly ended

Any help would be really appreciated.

2
Contributors
8
Replies
9
Views
8 Years
Discussion Span
Last Post by navarannan
0

I think your group by and where are in the wrong order.

Do you mean I have to put the groupby clause before where clause?

0

I have modified the SQL as follows but its throwing me the same error

select 
apex_item.checkbox(1,"EQUIPMENT_ID") Tick,
 ef.equipment_type as "Device Type",
 e.equipment_name as "Device Name",
 ef.Customer_Name as "Customer Name",
 ef.Site_Name as "Site Name",
 ef.Managed_Ip as "IP Address",
 dst.discovery_state_name as "Discover State",
 d.Error_Code as "Error Code" ,
 d.Last_Discovery_Time as "Last Discovery Time"
 ef.equipment_id,

  
  from EUIPMENT_FEATURES_MVIEW ef 

  join equipments e
    on e.equipment_id=ef.equipment_id
  join equipment_types et
    on e.equipment_type_id=et.equipment_type_id
  join discovery d
    on d.equipment_id=e.equipment_id
  join discovery_state_lookup dst
    on dst.discovery_state_id=d.discovery_status_id

 where ((:P0_SITE = EUIPMENT_FEATURES_MVIEW.SITE_ID) AND (:P0_CLIENT = EUIPMENT_FEATURES_MVIEW.customer_id))

  group by ef.equipment_type,
          e.equipment_name,
          dst.discovery_state_name,
          d.Error_Code ,
          d.Last_Discovery_Time,
          ef.equipment_id
0

Hi Thanks, the change in order did have effect. Now its throwing another error.

select 
apex_item.checkbox(1,"EQUIPMENT_ID") Tick,
 ef.equipment_type as "Device Type",
 e.equipment_name as "Device Name",
 ef.Customer_Name as "Customer Name",
 ef.Site_Name as "Site Name",
 ef.Managed_Ip as "IP Address",
 dst.discovery_state_name as "Discover State",
 d.Error_Code as "Error Code" ,
 d.Last_Discovery_Time as "Last Discovery Time",
 ef.equipment_id

  
  from EUIPMENT_FEATURES_MVIEW ef 

  join equipments e
    on e.equipment_id=ef.equipment_id
  join equipment_types et
    on e.equipment_type_id=et.equipment_type_id
  join discovery d
    on d.equipment_id=e.equipment_id
  join discovery_state_lookup dst
    on dst.discovery_state_id=d.discovery_status_id

 where ((:P0_SITE = EUIPMENT_FEATURES_MVIEW.SITE_ID) AND (:P0_CLIENT = EUIPMENT_FEATURES_MVIEW.CUSTOMER_ID))

  group by et.equipment_type,
          e.equipment_name,
          dst.discovery_state_name,
          d.Error_Code ,
          d.Last_Discovery_Time,
          ef.equipment_id

Error is

Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the ''generic columns'' checkbox below the region source to proceed without parsing. ORA-00904: "EUIPMENT_FEATURES_MVIEW"."CUSTOMER_ID": invalid identifier

There is a field named "CUSTOMER_ID" under the view EUIPMENT_FEATURES. :-(

0

EUIPMENT_FEATURES_MVIEW

shouldnt that be

EQUIPMENT_FEATURES_MVIEW

ha ha, thanks for that.

But my Mview is also named as EUIPMENT_FEATURES_MVIEW

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.