Usualy, in these cases, I don't use the query inside the class.
I construct the query using COS.

I check if there is a parameter and then construct it depending what i want:

You can check it using "if if '$Data(parameter) or like i do...
Passing a request

if (%request.Get("CUSTOMERID") '= "") {
Set WC = " WHERE Cliente="_%request.Get("CUSTOMERID")_" "
}
set rs=##class(%ResultSet).%New()
Set SQL="SELECT Id, Referencia, ReferenciaCliente, Cliente->Nome AS Cli, Cliente->ID as Cliente, DataInicio, DataFim, Duracao, Valor, Activo, RenAuto,PreAviso, DataPreAviso FROM ECOM.Contrato "_WC_" ORDER BY DataFim, Cli, ReferenciaCliente"


Do rs.Prepare(SQL)
...

Dipl.-Ing. Werner Riegler wrote:
Hi there,

who can tell me if and how

I can omit paramter of a class query ?

 Query ObjectList(ObjectType As %Integer, ReferencedObject As %Integer,
Reference As %Integer) As %SQLQuery(CONTAINID = 1)
{
    SELECT GAS.Object.ID, GAS.Object.NameDe FROM GAS.Object,
GAS.ObjectReference
    WHERE (
        GAS.Object.ObjectType = :ObjectType AND
        GAS.Object.ID = GAS.ObjectReference.FromObject AND
        GAS.ObjectReference.ToObject = :ReferencedObject AND
        GAS.ObjectReference.ObjectReferenceObject = :Reference
    )
    ORDER BY GAS.Object.NameDe
}

I mean, when e.g. " Reference " is not set as parameter, the query should
not search for it...

is there a possibility to use other statements in "Query" than SQL ?
or do I have to write just another query ?

brg
werner






Reply via email to