Informix v12 substitute for query using multiple with statements I am trying to convert some PostgreSQL into Informix and factor out the WITH statements in the query below. 

I have been unable to locate a solution to factoring out multiple with statements.

The user account to do this does not have 'create table' permissions.

WITH bear AS 
(SELECT
lv.vct_id
lsetup.wrk_id,
lobservation.id AS obs_id,
ladoption.factor_1 AS bear_corr,
lsurvey.dataset_series
FROM crs_vector cv
INNER JOIN crs_observation co
ON cv.id = co.vct_id
INNER JOIN crs_setup cs
ON (co.stp_id_local = cs.id AND lobservation.obt_sub_type = 'BEAR')
INNER JOIN crs_work cw
ON (cs.wrk_id = cw.id)
LEFT JOIN crs_adoption ca
ON (co.id = ca.obn_id_new)
LEFT JOIN crs_survey cs ON
ca.sur_wrk_id_orig = cs.wrk_id
WHERE cw.id = 1672933 AND co.obt_sub_type = 'BEAR'),

dist AS 
(SELECT
lv.vct_id
lsetup.wrk_id,
lobservation.id AS obs_id,
ladoption.factor_1 AS bear_corr,
lsurvey.dataset_series
FROM crs_vector cv
INNER JOIN crs_observation co
ON cv.id = co.vct_id
INNER JOIN crs_setup cs
ON (co.stp_id_local = cs.id AND lobservation.obt_sub_type = 'DIST')
INNER JOIN crs_work cw
ON (cs.wrk_id = cw.id)
LEFT JOIN crs_adoption ca
ON (co.id = ca.obn_id_new)
LEFT JOIN crs_survey cs ON
ca.sur_wrk_id_orig = cs.wrk_id
WHERE cw.id = 1672933 AND co.obt_sub_type = 'DIST'),

SELECT 
bear.vct_id
bear.wrk_id,
bear.obs_id,
bear.factor_1 AS bear_corr,
bear.dataset_series
dist.wrk_id,
dist.obs_id,
dist.factor_1 AS bear_corr,
dist.dataset_series
FROM   bear
FULL OUTER JOIN   dist
ON (bear.vct_id =  dist.vct_id AND bear.wrk_id = dist.wrk_id);
I might be wrong but give a shot

SELECT 
bear.wrk_id,
bear.vct_id,
bear.bearing,
bear.bearing_datum, 
dist.dist_equipment_type,
bear.bear_equipment_type,
dist.distance,
bear.surveyed_class AS bear_surveyed_class,
bear.geodetic_class AS bear_geodetic_class,
bear.adopt_bear_wrk_id,
bear.bear_adopt_plan,
dist.surveyed_class AS dist_surveyed_class,
dist.geodetic_class AS dist_geodetic_class,
dist.adopt_dist_wrk_id,
dist.adopt_dist_wrk_id,
bear.cos_id AS cos_id,
bear.ref_datetime,
bear.stp_id_local AS bear_stp_id_local,
bear.stp_id_remote AS bear_stp_id_remote,
dist.stp_id_local AS dist_stp_id_local,
dist.stp_id_remote AS dist_stp_id_remote
(
SELECT
lsetup.wrk_id,
lsetup.equipment_type AS bear_equipment_type,
lobservation.id AS obs_id,
lobservation.obt_sub_type,
lobservation.cos_id,
lobservation.vct_id,
lobservation.ref_datetime,
lobservation.surveyed_class,
lobservation.geodetic_class,
lobservation.value_1 AS bearing,
lobservation.value_2 AS bear1,
lobservation.value_3 AS bear2,
lobservation.value_1 as dd,
lobservation.stp_id_local,
lobservation.stp_id_remote,
ladoption.factor_1 AS bear_corr,
ladoption.sur_wrk_id_orig AS adopt_bear_wrk_id,
lcsystem.name AS bearing_datum,
concat(TRIM( TRAILING ' ' FROM CAST (lsurvey.dataset_series AS TEXT)) , ' ' , lsurvey.dataset_id) AS bear_adopt_plan
FROM crs_observation lobservation 
INNER JOIN crs_setup lsetup
ON (lobservation.stp_id_local = lsetup.id AND lobservation.obt_sub_type = 'BEAR' AND lobservation.surveyed_class &lt;&gt; 'PSED' )
INNER JOIN crs_work lwork
ON (lsetup.wrk_id = lwork.id AND lwork.status &lt;&gt; 'REQU')
LEFT JOIN crs_adoption ladoption
ON (lobservation.id = ladoption.obn_id_new)
LEFT JOIN crs_coordinate_sys lcsystem
ON (lobservation.cos_id = lcsystem.id)
 LEFT JOIN crs_survey lsurvey ON
ladoption.sur_wrk_id_orig = lsurvey.wrk_id
WHERE lwork.id = 1672933 AND lobservation.obt_sub_type = 'BEAR' AND lobservation.surveyed_class &lt;&gt; 'PSED' bear
FULL OUTER JOIN
  (
    SELECT
lwork.id AS wrk_id,
lobservation.id AS obs_id,
lobservation.obt_sub_type,
lobservation.cos_id,
lobservation.vct_id,
lobservation.ref_datetime,
lobservation.surveyed_class,
lobservation.geodetic_class,
lobservation.value_1 AS distance,
lobservation.value_2 AS dist2,
lobservation.value_3 AS dist3,
ladoption.factor_1 AS dist_corr,
ladoption.sur_wrk_id_orig AS adopt_dist_wrk_id,
lobservation.stp_id_local,
lobservation.stp_id_remote,
lsetup.equipment_type AS dist_equipment_type,
concat(TRIM( TRAILING ' ' FROM CAST (lsurvey.dataset_series AS TEXT)) , ' ' , lsurvey.dataset_id) AS dist_adopt_plan
FROM crs_observation lobservation  
INNER JOIN crs_setup lsetup
ON (lobservation.stp_id_local = lsetup.id)
INNER JOIN crs_work lwork
ON (lsetup.wrk_id = lwork.id AND lwork.status &lt;&gt; 'REQU')
LEFT JOIN crs_adoption ladoption
ON (lobservation.id = ladoption.obn_id_new)
LEFT JOIN crs_survey lsurvey ON
ladoption.sur_wrk_id_orig = lsurvey.wrk_id
WHERE  lwork.id = 1672933 AND lobservation.obt_sub_type = 'SLDI'  AND lobservation.surveyed_class &lt;&gt; 'PSED') DIST
ON (bear.vct_id =  dist.vct_id AND bear.wrk_id = dist.wrk_id AND bear.cos_id = dist.cos_id)
)