Jump to content

Multi-Select Query Error (No union support?)


manshack_one

Recommended Posts

This is my original query at the bottom of 4 cascading input controls.

select unitdesc from UNITS 
where $X{IN,system,HCD-system} 
and $X{IN,divreg,HCD-divreg} 
and $X{IN,district,HCD-district} 
order by unitdesc;

It pulls all the unit descriptions like it's supposed to but now the users are only wanting to get a list of unit descriptions that have actual data.  So now I have to query each table and pull back the list of descriptions from there. Here's what I tried to do but get an Error box (Just says error):

(select CAD.tblUnit from CAD, UNITS
where $X{IN,UNITS.system,HCD-system} 
and $X{IN,UNITS.divreg,HCD-divreg} 
and $X{IN,UNITS.district,HCD-district}
union
(select DIABETES.tblUnit from DIABETES, UNITS
where $X{IN,UNITS.system,HCD-system} 
and $X{IN,UNITS.divreg,HCD-divreg} 
and $X{IN,UNITS.district,HCD-district}
union
(select HEART.tblUnit from HEART, UNITS
where $X{IN,UNITS.system,HCD-system} 
and $X{IN,UNITS.divreg,HCD-divreg} 
and $X{IN,UNITS.district,HCD-district}
union
(select HLD.tblUnit from HLD, UNITS
where  $X{IN,UNITS.system,HCD-system} 
and $X{IN,UNITS.divreg,HCD-divreg} 
and $X{IN,UNITS.district,HCD-district}
union
(select HTN.tblUnit from HTN, UNITS
where $X{IN,UNITS.system,HCD-system} 
and $X{IN,UNITS.divreg,HCD-divreg} 
and $X{IN,UNITS.district,HCD-district}
union
(select RESPIRATORY.tblUnit from RESPIRATORY, UNITS
where $X{IN,UNITS.system,HCD-system} 
and $X{IN,UNITS.divreg,HCD-divreg} 
and $X{IN,UNITS.district,HCD-district}
union
(select SEIZURES.tblUnit from SEIZURES, UNITS
where $X{IN,UNITS.system,HCD-system} 
and $X{IN,UNITS.divreg,HCD-divreg} 
and $X{IN,UNITS.district,HCD-district})
order by tblUnit;

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

 Here's what's in there right now and it gets an Error but the log is describing index out of bounds problem:

(select CAD.tblUnit from CAD, UNITS

where CAD.tblUnit = UNITS.unitdesc

and $X{IN,UNITS.system,HCD-system}

and $X{IN,UNITS.divreg,HCD-divreg} 

and $X{IN,UNITS.district,HCD-district})

union

(select DIABETES.tblUnit from DIABETES, UNITS

where DIABETES.tblUnit = UNITS.unitdesc

and $X{IN,UNITS.system,HCD-system}

and $X{IN,UNITS.divreg,HCD-divreg} 

and $X{IN,UNITS.district,HCD-district})

union

(select HEART.tblUnit from HEART, UNITS

where HEART.tblUnit = UNITS.unitdesc

and $X{IN,UNITS.system,HCD-system}

and $X{IN,UNITS.divreg,HCD-divreg} 

and $X{IN,UNITS.district,HCD-district})

union

(select HLD.tblUnit from HLD, UNITS

where  HLD.tblUnit = UNITS.unitdesc

and $X{IN,UNITS.system,HCD-system}

and $X{IN,UNITS.divreg,HCD-divreg} 

and $X{IN,UNITS.district,HCD-district})

union

(select HTN.tblUnit from HTN, UNITS

where HTN.tblUnit = UNITS.unitdesc

and $X{IN,UNITS.system,HCD-system}

and $X{IN,UNITS.divreg,HCD-divreg} 

and $X{IN,UNITS.district,HCD-district})

union

(select RESPIRATORY.tblUnit from RESPIRATORY, UNITS

where RESPIRATORY.tblUnit = UNITS.unitdesc

and $X{IN,UNITS.system,HCD-system}

and $X{IN,UNITS.divreg,HCD-divreg} 

and $X{IN,UNITS.district,HCD-district})

union

(select SEIZURES.tblUnit from SEIZURES, UNITS

where SEIZURES.tblUnit = UNITS.unitdesc

and $X{IN,UNITS.system,HCD-system}

and $X{IN,UNITS.divreg,HCD-divreg} 

and $X{IN,UNITS.district,HCD-district})

order by tblUnit;

 

 

Link to comment
Share on other sites

 For reference, this is the actual query that returns the right data but without the parameters.  I'm trying to do the same thing but with the parameters HCD-system, HCD-divreg and HCD-district.

(select tblUnit from CAD, UNITS
where CAD.tblUnit = UNITS.unitdesc
and UNITS.system = 'UTMB'
and UNITS.divreg = 'OUTPATIENT'
and UNITS.district = 'SAN ANTONIO')

union

(select tblUnit from DIABETES, UNITS
where DIABETES.tblUnit = UNITS.unitdesc
and UNITS.system = 'UTMB'
and UNITS.divreg = 'OUTPATIENT'
and UNITS.district = 'SAN ANTONIO')

union

(select tblUnit from HEART, UNITS
where HEART.tblUnit = UNITS.unitdesc
and UNITS.system = 'UTMB'
and UNITS.divreg = 'OUTPATIENT'
and UNITS.district = 'SAN ANTONIO')

union

(select tblUnit from HLD, UNITS
where HLD.tblUnit = UNITS.unitdesc
and UNITS.system = 'UTMB'
and UNITS.divreg = 'OUTPATIENT'
and UNITS.district = 'SAN ANTONIO')

union

(select tblUnit from HTN, UNITS
where HTN.tblUnit = UNITS.unitdesc
and UNITS.system = 'UTMB'
and UNITS.divreg = 'OUTPATIENT'
and UNITS.district = 'SAN ANTONIO')

union

(select tblUnit from RESPIRATORY, UNITS
where RESPIRATORY.tblUnit = UNITS.unitdesc
and UNITS.system = 'UTMB'
and UNITS.divreg = 'OUTPATIENT'
and UNITS.district = 'SAN ANTONIO')

union

(select tblUnit from SEIZURES, UNITS

where SEIZURES.tblUnit = UNITS.unitdesc
and UNITS.system = 'UTMB'
and UNITS.divreg = 'OUTPATIENT'
and UNITS.district = 'SAN ANTONIO')

order by tblUnit;

Link to comment
Share on other sites

Your idea seems fine. Arbitrary SQL is allowed (unions work for you in the hard-coded example). And lots of $X clauses should be fine.

Try it with just one $X in clause. Then two. I think it has to be just a little detail somewhere rather than any big problem.

-Matt

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...