CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 executing query depending on parameter passed

Print topic Send  topic

Author Message
lulazz

Posts: 29
Posted: 03/10/2008, 8:16 AM

Hi,
I need to build a report based on date period and 1 parameter.
if this paremeter is 0 the data I need to filter is on 1 table
if the parameter is 1 the data is on another table.
Is there a way of telling CCS to execute query0 if parameter is 0 or query1 if parameter is 1?



eg.
this is the select if type=0
  
SELECT    distinct                                  
pazienti.cartella ,  
a_pazienti.nominativo as paziente ,  
proroghe.scadenza,  
pazienti.reparto  
FROM       
s_pazienti ,  
a_pazienti ,  
pazienti,  
proroghe  
WHERE  
( proroghe.paziente = pazienti.seriale ) and  
( pazienti.seriale = s_pazienti.codice ) and  
( a_pazienti.seriale = pazienti.codice ) and  
(proroghe.scadenza between '[data1]' and '[data2]' and  
pazienti.tipo ='[type]'  
and this one if type=1
  
SELECT    distinct                                  
pazienti.cartella ,  
a_pazienti.nominativo as paziente ,  
piani_cura.fine,  
pazienti.reparto  
FROM       
s_pazienti ,  
a_pazienti ,  
pazienti,  
piani_cura  
WHERE  
( proroghe.paziente = pazienti.seriale ) and  
( pazienti.seriale = s_pazienti.codice ) and  
( a_pazienti.seriale = pazienti.codice ) and  
(piani_curaa.fine between '[data1]' and '[data2]' and  
pazienti.tipo ='[type]'  
where [data1][data2] and [type] are the parameters

the 2 tables that hold the data I need to filter are proroghe and piani_cura

Thanks
Lulazz

View profile  Send private message
DonP
Posted: 03/10/2008, 8:25 AM

Using a Before Build Select event, you can make a query on 0 but the
query value will probably need to be in quotes. Otherwise it will also
find NULL values which might not be what you want.

Don (DonP)

lulazz wrote:
> Hi,
> I need to build a report based on date period and 1 parameter.
> if this paremeter is 0 the data I need to filter is on 1 table
> if the parameter is 1 the data is on another table.
> Is there a way of telling CCS to execute query0 if parameter is 0 or query1 if
> parameter is 1?
>
>
>
> eg.
> this is the select if type=0
>
  
> SELECT    distinct                                  
> pazienti.cartella ,  
> a_pazienti.nominativo as paziente ,  
> proroghe.scadenza,  
> pazienti.reparto  
> FROM       
> s_pazienti ,  
> a_pazienti ,  
> pazienti,  
> proroghe  
> WHERE  
> ( proroghe.paziente = pazienti.seriale ) and  
> ( pazienti.seriale = s_pazienti.codice ) and  
> ( a_pazienti.seriale = pazienti.codice ) and  
> (proroghe.scadenza between '[data1]' and '[data2]' and  
> pazienti.tipo ='[type]'  
> 
> and this one if type=1
>
  
> SELECT    distinct                                  
> pazienti.cartella ,  
> a_pazienti.nominativo as paziente ,  
> piani_cura.fine,  
> pazienti.reparto  
> FROM       
> s_pazienti ,  
> a_pazienti ,  
> pazienti,  
> piani_cura  
> WHERE  
> ( proroghe.paziente = pazienti.seriale ) and  
> ( pazienti.seriale = s_pazienti.codice ) and  
> ( a_pazienti.seriale = pazienti.codice ) and  
> (piani_curaa.fine between '[data1]' and '[data2]' and  
> pazienti.tipo ='[type]'  
> 
> where [data1][data2] and [type] are the parameters
>
> the 2 tables that hold the data I need to filter are proroghe and piani_cura
>
> Thanks
> Lulazz
>
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.