I am running a script that does MANY things but I am trying to get a Pervasive statement to work in my php that works in the DB that I am querying. I have tried all my tricks, but have had no success with getting this to work in the table that this is supposed to be displayed in.
$pom = $dbx->getOne('SELECT (SELECT SUM(wrt_sls) FROM wrt
WHERE wrt_cat = \'POM\'
AND wrt_cng_dat_4 >= '.$start.'
AND wrt_cng_dat_4 <= '.$end.'
AND wrt_pft_ctr in '.$pcs.') +
(SELECT SUM(wrt_sls) FROM wrt
WHERE wrt_cat in (\'BED\',\'MP\')
AND wrt_vend_id = \'PROTECTABED\'
AND wrt_cng_dat_4 >= '.$start.'
AND wrt_cng_dat_4 <= '.$end.'
AND wrt_pft_ctr in '.$pcs);
Again, I get the right result in Pervasive but am getting nothing in the actual application. Any tips?
The first thing I would check is the values of $start, $end, and $pcs. For example, the way you are using them they appear to be INT values. However, if the columns in the table are not of type INT, then they are not quoted correctly in your query. I also do not see the ending ) that will be required in your query to work correctly. You may need to rewrite your query like:
$pom = $dbx->getOne("SELECT (SELECT SUM(wrt_sls) FROM wrt
WHERE wrt_cat = 'POM'
AND wrt_cng_dat_4 >= '" . $start . "'
AND wrt_cng_dat_4 <= '" . $end . "'
AND wrt_pft_ctr in '" . $pcs . "') +
(SELECT SUM(wrt_sls) FROM wrt
WHERE wrt_cat in ('BED','MP')
AND wrt_vend_id = 'PROTECTABED'
AND wrt_cng_dat_4 >= '" . $start . "'
AND wrt_cng_dat_4 <= '" . $end . "'
AND wrt_pft_ctr in '" . $pcs ."')");
Nope that doesn't seem to work either, but I took different approach and this is what ended up working ...
$pom = $dbx->getOne('
SELECT SUM(wrt_sls) FROM wrt
WHERE wrt_cat = \'POM\'
AND wrt_cng_dat_4 >= '.$start.'
AND wrt_cng_dat_4 <= '.$end.'
AND wrt_pft_ctr in '.$pcs);
$pab = $dbx->getOne('
SELECT SUM(wrt_sls) FROM wrt
WHERE wrt_cat = \'BED\'
AND wrt_vend_id = \'PROTECTABED\'
AND wrt_cng_dat_4 >= '.$start.'
AND wrt_cng_dat_4 <= '.$end.'
AND wrt_pft_ctr in '.$pcs);
$protect = $pom + $pab;
$tpom += $protect;
Thanks a lot for the reply.