Param in Query / Multiple String

edited 9:35PM in FastReport 4.0
Hy, i use Fastreport with Delphi, and in a big query i want to filter the data in a column of type STRING.
The user select multiple string in a CheckListbox in Delphi and i must send this selection for my query is correct.

The User select 3 filters 'A1','B2','B5' in delphi.


My Query :
SELECT * FROM TABLE1 WHERE ACOLUMN1 IN (:PARAM1)

PARAM1 :
Data Type : 'STRING'
Value : <ASELECT> <- My Variable is set in Delphi


But i don't find the syntax for setting correctly 'A1','B2','B5' in my Variable ASELECT in Delphi.

Thank for your Help.



Comments

  • edited August 2010
    UP

    I set the Variable Value in Delphi :

    Variable.value := '''' + 'A1' + '''' + ',' + '''' + 'B2' + '''' + ',' + '''' + 'B5' + '''';

    And When i execute the report, i have an error :

    "Error in the Expression ''A1','B2','B5'' : ';' expected".

    If someone can help me, or indicate a solution more easy for setting my Variable Value .......

    Thank
  • gordkgordk St.Catherines On. Canada.
    edited 9:35PM
    you may need to use an or query and three variables.
  • edited 9:35PM
    it's not possible, in my delphi app, the user select one or many items in a checklist.
    The number of select is variables.

    Or there is not a filter ?
  • gordkgordk St.Catherines On. Canada.
    edited 9:35PM
    i believe it is the expression parser
    it cannot resolve the where clause parameter portion
    WHERE ACOLUMN1 IN (:PARAM1)
    what you may have to do is work entirely from delphi and pass the complete sql into
    the query object after the report is loaded by using the findobjectmethod and setting the sql prop.
  • gordkgordk St.Catherines On. Canada.
    edited 9:35PM
    There is a work around
    if the query's sqlstring is hard coded it will work. so build the string, add it to the query.
    here is a sample change i made in the main demo internalquery report to illustrate.
    create a variable mystrvar and give it a value of '"FL","CA"'
    cleared the sql prop of the query

    var
    sqlstr:string; // added global variable
    // added procedure for ok button
    procedure Button1OnClick(Sender: TfrxComponent);
    begin

    sqlstr :='select c.* from Customer c where c.State in('+<mystrvar>+')';
    //showmessage(sqlstr); this was to check the string
    bdequery1.sql.add(sqlstr);
    end;
    You need to be care full when you set the mystrvar value from delphi
    so that the value has begining and ending delimiters
    try ''''+quotedstr(value)+','+quotedstr(value)+''''

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.