SQL property access

Hi,

Hi, I have this report, where the user selects the data column by which the report is ordered. I created a report variable "order", and within the report, using pascal scripting, I want to assign a value to the SQL property of a DBXQuery component, the corresponding SQL statement; I tried with:

procedure Page1OnBeforePrint(Sender: TfrxComponent);
begin
if Get('orden') = 'proveedor' then
begin
DBXQuery_regoper_part.SQL:='select
regoper_part_id,
regoper_id,
proveedor_id,
prv_rfc,
prv_nombre,
RPP_NUMPARTIDA,
rpp_numpoliza,
rpp_numfactura,
rpp_mesfactura,
rpp_iva,
rpp_importe

from regoper_part_v
where regoper_id = :regoper_id
order by PRV_NOMBRE';
end;
end;



I get expression expected. How can I properly code this assignation?

Thank you

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 9:12AM
    better to use a parameterized query and pass value to variable.
    Look at main demo internaldatasets internalquery report
    look at the sql and the parameters of the query.
  • edited 9:12AM
    Hi,

    I found that the following code does not have syntax errors:
    wrote:
    procedure Page1OnBeforePrint(Sender: TfrxComponent);
    begin
    if Get('orden') = 'proveedor' then
    begin
    DBXQuery_regoper_part.SQL:= TStrings('select regoper_part_id, regoper_id, proveedor_id, prv_rfc,prv_nombre,RPP_NUMPARTIDA,rpp_numpoliza,rpp_numfactura,rpp_mesfactura,rpp_iva,rpp_importe from regoper_part_v where regoper_id = :regoper_id order by PRV_NOMBRE');
    end;
    end;

    begin

    end.

    Yet when executing it, I get: "Undeclared identifier "proveedor""

    In Delphi, when calling this report I have:

    Self.frxReport_regoper.Variables.Variables:= 'proveedor';
    Self.frxReport_regoper.ShowReport();

    Is the script code " if Get('orden') = 'proveedor' then" correct? or am I missing something?

    Thank you
  • edited 9:12AM
    Hi gordk,

    Thank you for your reply; I tryed something like:

    (Delphi)
    Self.frxReport_regoper.Variables.Variables:= DataSource.DataSet.FieldByName( objetoBD.z_campoId ).AsString;
    Self.frxReport_regoper.Variables.Variables:= 'PRV_NOMBRE';
    Self.frxReport_regoper.ShowReport();

    Then, in the Report query (DBXQuery_regoper_part.SQL):

    select
    regoper_part_id,
    regoper_id,
    proveedor_id,
    prv_rfc,
    prv_nombre,
    RPP_NUMPARTIDA,
    rpp_numpoliza,
    rpp_numfactura,
    rpp_mesfactura,
    rpp_iva,
    rpp_importe

    from regoper_part_v
    where regoper_id = :regoper_id
    order by :orden

    And I get:

    :-(

    "Undeclared identifier PRV_NOMBRE"

    Any ideas?
  • gordkgordk St.Catherines On. Canada.
    edited 9:12AM
    when passing strin values into categorized variables from delphi extra ' are required
    read the programmers manual on working with variables

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.