Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Changing SQL Object...

edited April 2002 in General
Hello!
I'm doing this procedure to call an interbase stored procedure from the
'FROM' statement....

1 - Create a Query with the Query Designer with same fields that the
procedure will return;
2 - Create in this Query the AutoSearchFields with same datatype that i need
get my procedure parameters;
3 - On the event Report.OnGetAutoSearchValues i'm changing the SQL object
with my sql;
4 - Re-link the datafields for the dbcomponents;

Here is the code:

procedure ReportOnGetAutoSearchValues;
var
sParam: string;
begin
sParam := IntToStr(Report.AutoSearchFields[0].Value) + ', ''' +
FormatDateTime('yyyy-mm-dd',
Report.AutoSearchFields[1].Values[0]) + ''', ''' +
FormatDateTime('yyyy-mm-dd',
Report.AutoSearchFields[1].Values[0]) + '''';
ChangeSQLObject(Report, 'select * from ESPELHO_PONTO(' + sParam + ')');

lblEmpresa.DataField := 'EMPRESA';
lblFuncao.DataField := 'FUNCAO';
lblCNPJ.DataField := 'CNPJ_EMPRESA';
lblNRO.DataField := 'NRO_REGISTRO';
lblHorario.DataField := 'HORARIO';
lblQuinzena.DataField := 'QUINZENA';
lblDataHora.DataField := 'DATA_HORA_ENTRADA';
HoraSai.DataField := 'DATA_HORA_SAIDA';
HoraEnt.DataField := 'DATA_HORA_ENTRADA';
lblFunc.DataField := 'FUNCIONARIO';
end;

Why, on the dbcomponent the value appear correctly in runtime, but when i
try to get it from RAP (i.e. test := mydataview[DATA_HORA_ENTRADA];) i'm
always get an empty value???

TIA.

Comments

  • edited April 2002
    In what event handler are you trying to retrieve the value from the
    dataview. Try using the variable's OnCalc event for this purpose.

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited April 2002
    I'm trying to do everything using the Detail BeforePrint event to centralize
    the code.
    I'm using a variable with datatype DATE, if i try to do

    value := cadastro['DATA_HORA_ENTRADA'];

    the variable always show current date and time, instead the date and time
    that the database sent. (And the dbText is showing the correct value).

  • edited April 2002
    Why ReportBuilder don't raise an exception when the user make some mistake
    in rap??
    i.e.:

    ShowMessage(mydataview['FOO']);

    but when the field 'foo' doesn't exist instead raising an exception,
    RBuilder returns an empty str.


This discussion has been closed.