Bear in mind that the length of queryranges is not unlimited!.And will cause a runtime Sql-error if it goes beyond approx. 255. Hence You should either decompose the queryrangevaluestring into substrings of 255 and insert info a new range. Or accumulate them i a set, and afterwards use the following metod.:
 
query ConvertSet2query()
        {
        QueryBuildRange         QueryBuildRange;
        str                             QueryString;
        QueryBuildDataSource    QueryBuildDataSource    = query.addDataSource(this.tableid());
        SetIterator             It                      = new SetIterator(this.set());
        ;
            QueryBuildRange     = QueryBuildDataSource.AddRange(this.fieldid());
        
            if (this.set().empty())
            {
                Querystring = Sysquery::valuenotemptystring;
            }
            else
            {
                while (it.more())
                {
                    Querystring += it.value()+',';
                    if(strlen(Querystring) > 240) // then we are safe
                    {
                        QueryBuildRange = QueryBuildDataSource.AddRange(this.fieldid());
                        QueryBuildRange.value(QueryString);
                        QueryString = '';
                    }
                    it.next();
                }
            }
            QueryBuildRange     = QueryBuildDataSource.AddRange(this.fieldid());
            QueryBuildRange.value(QueryString);
        return  query;
        }
BTW I do not think it is not nessecary to resrtict the search on dataareaid.
 
:-J
Jacob
----- Original Message -----
Sent: Friday, January 23, 2004 1:23 AM
Subject: RE: [development-axapta] Re: Filtering on a memo field

I forgot to keep in mind the dataAreaID, I figure you�d catch it Don, but incase anyone else is looking.  

 

BTW you�ll notice searching memo fields in the where clause is not a SQL shortcoming, but an Axapta one.

 

-Preston

 

static void pl_scratch(Args _args)

{

    docuRef                         dr;

    Connection                      con = new Connection();

    Statement                       sqlStmt = Con.createStatement();

    ResultSet                       sqlTable;

    notes                           sqlStr;

    str                             searchWord;

    str                             rangeList;

    str                             dataareaID;

    ;

 

    dataareaID = curExt();

 

    searchWord = "Remark";

 

 

    sqlSTR = strFmt("select recID from docuref where notes like '\%%1\%' AND refCompanyID = '%2'", searchWord, dataareaID);

 

    info(sqlStr);

 

    sqlTable = sqlStmt.executeQuery(sqlSTR);

 

     while (sqlTable.next()){

 

      //build recidList to use in other query

      rangeList = rangeList + (rangeList ? ", " + int2STR(sqlTable.getInt(1)) : int2STR(sqlTable.getInt(1)));

    

     }

    info(rangeList);

 

}



Yahoo! Groups Links


Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links

Reply via email to