#51 Re: mORMot 1 » Two Oracle and mORMot question » 2015-03-25 21:23:04

Thank you very much. I will try to use this.

#52 mORMot 1 » Two Oracle and mORMot question » 2015-03-23 22:49:10

ASiwon
Replies: 6

Hello,

I have two questions related to the user rights and Oracle in mORMot:
1. Is it possible to set role while creating connection to the Oracle using mORMot?
2. Is it possible to give an information about request of password change while logging in to the Oracle database? I'm asking because since Oracle 11 are used the default policy even for SYSTEM account and requires to change password after some time period. Using other Delphi components to connecting to the Oracle I'm usually checking password grace period. If exception: ORA-28001 or ORA-28002 is raised then application knows that it should automatically change its password. Is it something similar in mORMot?

#53 Re: mORMot 1 » TID fields documentation - question and mistake » 2015-03-23 22:14:34

About avoiding deletion when there is still pending items, it is not implemented yet AFAIR.
You could create a feature request ticket.

Done.

#54 Re: mORMot 1 » Problem with calling stored procedure from Oracle database » 2015-03-20 10:17:34

Yes, When I have changed BindNull to Bind for all InOut parameters then the procedure is called correctly. This change I can use in my production environment and for now this problem is solved for me. Thank you very much for help.

#55 mORMot 1 » Problem with calling stored procedure from Oracle database » 2015-03-20 07:31:09

ASiwon
Replies: 2

Hello,

I'm writing because I have some problem with calling stored procedure from Oracle 11 XE database using mORMot. I know that calling stored procedure is not the best solution but for now I have no another choice. But after some hours of looking the problem I'm confused and I have no idea what is wrong in my code.

I have big (93 parameters) stored procedure which writes some data to the database. Procedure works as facade template - just calls other internal procedures which performs the task. Oracle procedure header looks like:

create or replace procedure u_eks.SP_WAGONY_OBECNE_INSERT(
     -- Identyfikatory
   io_wz_id                 in out integer, --u_eks.t_wagony_zdania.wz_id%type,
   io_wz_we_id              in out integer, --u_eks.t_wagony_zdania.wz_we_id%type,
   io_wz_wp_id              in out integer, --u_eks.t_wagony_zdania.wz_wp_id%type,
     -- dane podstawienia
   i_w_nr_wagonu            in varchar2, --u_eks.t_wagony_zdania.w_nr_wagonu%type,
   i_w_seria                in varchar2, --u_eks.t_wagony_zdania.w_seria%type,
   i_w_rodz_numer           in u_eks.t_wagony_zdania.w_rodz_numer%type,
   i_w_zly_numer            in u_eks.t_wagony_zdania.w_zly_numer%type,
   i_w_tara_z_bel           in u_eks.t_wagony_zdania.w_tara_z_belki%type,
   i_w_tara_przewozowa      in u_eks.t_wagony_zdania.w_tara_przewozowa%type,
   i_w_tara_dekl_lad        in u_eks.t_wagony_podstawienia.w_tara_dekl_lad%type,
   i_w_tara_dekl_lad_rodzaj in u_eks.t_wagony_podstawienia.w_tara_dekl_lad_rodzaj%type,
   i_w_gr_obciaz            in u_eks.t_wagony_podstawienia.w_gr_obciaz%type,
   i_w_masa_lad             in u_eks.t_wagony_podstawienia.w_masa_lad%type,
   i_wp_masa_lad_przewoz    in u_eks.t_wagony_podstawienia.wp_masa_lad_przewoz%type,
   i_w_masa_tow             in u_eks.t_wagony_zdania.w_masa_tow%type,
   i_w_masa_prz_l           in u_eks.t_wagony_podstawienia.w_masa_prz_l%type,
   i_w_masa_prz_t           in u_eks.t_wagony_zdania.w_masa_prz_t%type,
   i_w_masa_przew           in u_eks.t_wagony_zdania.w_masa_przew%type,
   i_w_masa_opak_l          in u_eks.t_wagony_podstawienia.w_masa_opak_l%type,
   i_w_masa_opak_t          in u_eks.t_wagony_zdania.w_masa_opak_t%type,
   i_w_masa_wydz_lad        in u_eks.t_wagony_podstawienia.w_masa_wydz_lad%type,
   i_w_masa_wydz_tow        in u_eks.t_wagony_zdania.w_masa_wydz_tow%type,
   i_w_ilosc_osi            in u_eks.t_wagony_podstawienia.w_ilosc_osi%type,
   i_w_ilosc_szt_lad        in u_eks.t_wagony_podstawienia.w_ilosc_szt_lad%type,
   i_w_ilosc_opak_tow       in u_eks.t_wagony_zdania.w_ilosc_opak_tow%type,
   i_w_ilosc_szt_tow        in u_eks.t_wagony_zdania.w_ilosc_szt_tow%type,
   i_w_stezenie_lad         in u_eks.t_wagony_podstawienia.w_stezenie_lad%type,
   i_w_stezenie_tow         in u_eks.t_wagony_zdania.w_stezenie_tow%type,
   i_w_id_ladunku           in u_eks.t_wagony_podstawienia.w_id_ladunku%type,
   i_w_id_nadawcy           in u_eks.t_wagony_podstawienia.w_id_nadawcy%type,
   i_w_id_towaru            in u_eks.t_wagony_zdania.w_id_towaru%type,
   i_w_towar_opis_dod       in varchar2, --u_eks.t_wagony_zdania.w_towar_opis_dod%type,
   i_w_id_odbiorcy          in u_eks.t_wagony_zdania.w_id_odbiorcy%type,
   i_w_id_r25               in u_eks.t_wagony_podstawienia.w_id_r25%type,
   io_w_lp_r25              in out integer,
   i_w_id_r25t              in u_eks.t_wagony_podstawienia.w_id_r25t%type,
   io_w_lp_r25t             in out integer,
   i_w_id_lis_prz           in u_eks.t_wagony_podstawienia.w_id_lis_prz%type,
   i_w_lp_lis_prz           in u_eks.t_wagony_podstawienia.w_lp_lis_prz%type,
     -- data i czas ukończenia załadunku
   i_w_czas_uk_za           in u_eks.t_wagony_zdania.w_czas_uk_za%type,
     -- data i czas ukończenia wyładunku
   i_w_czas_uk_wy           in u_eks.t_wagony_zdania.w_czas_uk_wy%type,
   i_w_czas_uk_wy_pol_auto  in u_eks.t_wagony_zdania.w_czas_uk_wy_pol_auto%type,
     -- data i czas rozpoczęcia załadunku
   i_w_czas_roz_za          in u_eks.t_wagony_zdania.w_czas_roz_za%type,
     -- data i czas rozpoczęcia dyspozycji
   i_w_czas_dysp_od         in u_eks.t_wagony_podstawienia.w_czas_dysp_od%type,
     -- data i czas ponownego dysponowania wagonów
   i_w_czas_ponow_dysp      in u_eks.t_wagony_zdania.w_czas_ponow_dysp%type,
     -- Dodatkowe czasy pomniejszające czas pobytu
   i_w_czas_roz_odprawy     in u_eks.t_wagony_zdania.w_czas_roz_odprawy%type,
   i_w_czas_odprawy         in u_eks.t_wagony_zdania.w_czas_odprawy%type,
   i_w_czas_roz_czyn_adm    in u_eks.t_wagony_zdania.w_czas_roz_czyn_adm%type,
   i_w_czas_czyn_adm        in u_eks.t_Wagony_Zdania.w_Czas_Czyn_Adm%type,
   i_w_id_p_podst           in u_eks.t_wagony_zdania.w_id_p_podst%type,
   i_w_lp_p_podst           in u_eks.t_wagony_zdania.w_lp_p_podst%type,
   i_w_vat                  in u_eks.t_wagony_zdania.w_vat%type,
   i_w_zmiana_tary          in u_eks.t_wagony_zdania.w_zmiana_tary%type,
   i_w_podw_op_lad          in u_eks.t_wagony_zdania.w_podw_op_lad%type,
   i_w_podzial_masy_l       in u_eks.t_wagony_podstawienia.w_podzial_masy_l%type,
   i_w_podzial_masy_t       in u_eks.t_wagony_zdania.w_podzial_masy_t%type,
   i_w_akt_hamul_p          in u_eks.t_wagony_podstawienia.w_akt_hamul_p%type,
   i_w_akt_hamul_z          in u_eks.t_wagony_zdania.w_akt_hamul_z%type,
   i_w_dlugosc              in u_eks.t_wagony_zdania.w_dlugosc%type,
   i_w_ciez_ham_1           in u_eks.t_wagony_zdania.w_ciez_ham_1%type,
   i_w_ciez_ham_2           in u_eks.t_wagony_zdania.w_ciez_ham_2%type,
   i_w_ciez_ham_pr          in u_eks.t_wagony_zdania.w_ciez_ham_pr%type,
   i_w_masa_przest          in u_eks.t_wagony_zdania.w_masa_przest%type,
   i_w_typ_hamulca          in u_eks.t_wagony_zdania.w_typ_hamulca%type,
   i_w_rodzaj_hamul         in u_eks.t_wagony_zdania.w_rodzaj_hamul%type,
   i_w_hamul_oerl           in u_eks.t_wagony_zdania.w_hamul_oerl%type,
   i_w_hamul_nast           in u_eks.t_wagony_zdania.w_hamul_nast%type,
   i_wz_uzyt_wag_kod_liter  in varchar2, --u_eks.t_wagony_zdania.wz_uzyt_wag_kod_liter%type,
   i_wz_uzyt_wag_kod_cyfr   in varchar2, --u_eks.t_wagony_zdania.wz_uzyt_wag_kod_cyfr%type,
   i_w_ub_ub_id             in u_eks.t_wagony_podstawienia.w_ub_ub_id%type,
   i_wz_ub_ub_id            in u_eks.t_wagony_zdania.w_ub_ub_id%type,
   i_wz_un_un_id            in u_eks.t_wagony_zdania.w_un_un_id%type,
   i_w_cpw_id               in u_eks.t_wagony_zdania.w_cpw_id%type,
   i_w_dysp_wag_id          in integer,
   i_w_dysp_wag_typ         in number,
   i_w_import               in u_eks.t_wagony_podstawienia.w_import%type,
   i_w_eksport              in u_eks.t_wagony_zdania.w_eksport%type,
   i_w_odmowa               in u_eks.t_wagony_zdania.w_odmowa%type,
   i_w_lad_uszkodz          in u_eks.t_wagony_podstawienia.w_lad_uszkodz%type,
   i_w_ilosc_plomb_tow      in u_eks.t_wagony_zdania.w_ilosc_plomb_tow%type,
   i_we_tr_tr_id            in u_eks.t_wagony_eksp_id.we_tr_tr_id%type,
   i_w_lad_zamroz           in u_eks.t_wagony_podstawienia.w_lad_zamroz%type,
   i_w_lad_zamroz_prot      in u_eks.t_wagony_podstawienia.w_lad_zamroz_prot%type,
     -- Medium
   i_w_medium_gt_id         in u_eks.t_wagony_podstawienia.w_medium_gt_id%type,
     -- identyfikator schematu pracy wybranego dla podstawienia wagonu
   i_w_sp_sp_id             in u_eks.t_wagony_eksp_id.we_sp_sp_id%type,
     -- identyfikator wagonu z kartoteki wagonow prywatnych, ktory zostal zidentyfikowany
     -- z podstawieniem
   i_we_wi_id               in u_tab.t_wagony_id.w_w_id%type,
     -- czas wstawienia wagonu na tor
   i_we_czas_podstawienia   in u_eks.t_wagony_eksp_id.we_czas_podstawienia%type default null,
   i_we_czas_zabrania       in u_eks.t_wagony_eksp_id.we_czas_zabrania%type default null,
     -- rodzaj pobytu na bocznicy - loko/przejściowe
   i_we_pobyt_rodzaj        in u_eks.t_wagony_eksp_id.we_pobyt_rodzaj%type,
     -- Dane do integracji z systemem SAP - przybycie
   i_w_sdz_nr_zamowienia    in varchar2, --u_eks.t_wagony_podstawienia.w_sdz_nr_zamowienia%type,
   i_w_sdz_nr_pozycji       in u_eks.t_wagony_podstawienia.w_sdz_nr_pozycji%type,
     -- Dane do integracji z systemem SAP - wysyłka
   i_w_sdd_nr_dostawy       in varchar2, --u_eks.t_wagony_zdania.w_sdd_nr_dostawy%type,
   i_w_sdd_nr_pozycji       in u_eks.t_wagony_zdania.w_sdd_nr_pozycji%type)

I can call this procedure from other tools (PL/SQL Developer) or even from other Delphi components (ODAC) without any problems. But when I'm trying to call this procedure from mORMot then always exception is raised:

TSQLDBOracleStatement error: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 2

This is strange exception, because whole procedure is executed. In the last line of the procedure I'm calling message using Oracle's pipe - everything is sent correctly. So exception is raised not inside of the procedure (it would be deeper stack of Oracle calls in exception message) but after procedure call. While setting value of the out parameters? I have no idea but if calling of the message using Oracle's pipe is called in SQL code after the procedure call it is not sent.

When I made some changes inside of the Oracle procedure then everything starts working, but this changes are only for testing purpose. I can't to bring them to the production system. This change is removing the code which gets new value for parameter: io_w_lp_r25. Value for this parameter is selected from Oracle sequence and for now has value like: 130000. Range of the integer value is not exceeded. I'm sure. If selecting value from sequences is commented then procedure is called correctly. Unfortunately I can't extract it as example to the debug purpose.

Here is a code which calls Oracle procedure using mORMot:

procedure TBkWazeniaImportyPodstaw.PodstawienieDodajWagony;
const
  cSQLExec =
    'begin' + #13#10 +
    '  ' + cSpWagonyObecneInsert + '(' + #13#10 +
        'io_wz_id                 => ?,' + #13#10 +  // 1
        'io_wz_we_id              => ?,' + #13#10 +  // 2
        'io_wz_wp_id              => ?,' + #13#10 +  // 3
        'i_w_nr_wagonu            => ?,' + #13#10 +  // 4
        'i_w_seria                => ?,' + #13#10 +  // 5
        'i_w_rodz_numer           => ?,' + #13#10 +  // 6
        'i_w_zly_numer            => ?,' + #13#10 +  // 7
        'i_w_tara_z_bel           => ?,' + #13#10 +  // 8
        'i_w_tara_dekl_lad        => ?,' + #13#10 +  // 9
        'i_w_tara_dekl_lad_rodzaj => ?,' + #13#10 +  // 10
        'i_w_tara_przewozowa      => ?,' + #13#10 +  // 11
        'i_w_gr_obciaz            => ?,' + #13#10 +  // 12
        'i_w_masa_lad             => ?,' + #13#10 +  // 13
        'i_wp_masa_lad_przewoz    => ?,' + #13#10 +  // 14
        'i_w_masa_tow             => ?,' + #13#10 +  // 15
        'i_w_masa_prz_l           => ?,' + #13#10 +  // 16
        'i_w_masa_prz_t           => ?,' + #13#10 +  // 17
        'i_w_masa_przew           => ?,' + #13#10 +  // 18
        'i_w_masa_opak_l          => ?,' + #13#10 +  // 19
        'i_w_masa_opak_t          => ?,' + #13#10 +  // 20
        'i_w_masa_wydz_lad        => ?,' + #13#10 +  // 21
        'i_w_masa_wydz_tow        => ?,' + #13#10 +  // 22
        'i_w_ilosc_osi            => ?,' + #13#10 +  // 23
        'i_w_ilosc_szt_lad        => ?,' + #13#10 +  // 24
        'i_w_ilosc_opak_tow       => ?,' + #13#10 +  // 25
        'i_w_ilosc_szt_tow        => ?,' + #13#10 +  // 26
        'i_w_stezenie_lad         => ?,' + #13#10 +  // 27
        'i_w_stezenie_tow         => ?,' + #13#10 +  // 28
        'i_w_id_ladunku           => ?,' + #13#10 +  // 29
        'i_w_id_nadawcy           => ?,' + #13#10 +  // 30
        'i_w_id_towaru            => ?,' + #13#10 +  // 31
        'i_w_towar_opis_dod       => ?,' + #13#10 +  // 32
        'i_w_id_odbiorcy          => ?,' + #13#10 +  // 33
        'i_w_id_r25               => ?,' + #13#10 +  // 34
        'io_w_lp_r25              => ?,' + #13#10 +  // 35
        'i_w_id_r25t              => ?,' + #13#10 +  // 36
        'io_w_lp_r25t             => ?,' + #13#10 +  // 37
        'i_w_id_lis_prz           => ?,' + #13#10 +  // 38
        'i_w_lp_lis_prz           => ?,' + #13#10 +  // 39
        'i_w_czas_uk_za           => ?,' + #13#10 +  // 40
        'i_w_czas_uk_wy           => ?,' + #13#10 +  // 41
        'i_w_czas_uk_wy_pol_auto  => ?,' + #13#10 +  // 42
        'i_w_czas_roz_za          => ?,' + #13#10 +  // 43
        'i_w_czas_dysp_od         => ?,' + #13#10 +  // 44
        'i_w_czas_ponow_dysp      => ?,' + #13#10 +  // 45
        'i_w_czas_roz_odprawy     => ?,' + #13#10 +  // 46
        'i_w_czas_odprawy         => ?,' + #13#10 +  // 47
        'i_w_czas_roz_czyn_adm    => ?,' + #13#10 +  // 48
        'i_w_czas_czyn_adm        => ?,' + #13#10 +  // 49
        'i_w_id_p_podst           => ?,' + #13#10 +  // 50
        'i_w_lp_p_podst           => ?,' + #13#10 +  // 51
        'i_w_vat                  => ?,' + #13#10 +  // 52
        'i_w_zmiana_tary          => ?,' + #13#10 +  // 53
        'i_w_podw_op_lad          => ?,' + #13#10 +  // 54
        'i_w_podzial_masy_l       => ?,' + #13#10 +  // 55
        'i_w_podzial_masy_t       => ?,' + #13#10 +  // 56
        'i_w_akt_hamul_p          => ?,' + #13#10 +  // 57
        'i_w_akt_hamul_z          => ?,' + #13#10 +  // 58
        'i_w_dlugosc              => ?,' + #13#10 +  // 59
        'i_w_ciez_ham_1           => ?,' + #13#10 +  // 60
        'i_w_ciez_ham_2           => ?,' + #13#10 +  // 61
        'i_w_ciez_ham_pr          => ?,' + #13#10 +  // 62
        'i_w_masa_przest          => ?,' + #13#10 +  // 63
        'i_w_typ_hamulca          => ?,' + #13#10 +  // 64
        'i_w_rodzaj_hamul         => ?,' + #13#10 +  // 65
        'i_w_hamul_oerl           => ?,' + #13#10 +  // 66
        'i_w_hamul_nast           => ?,' + #13#10 +  // 67
        'i_wz_uzyt_wag_kod_liter  => ?,' + #13#10 +  // 68
        'i_wz_uzyt_wag_kod_cyfr   => ?,' + #13#10 +  // 69
        'i_w_ub_ub_id             => ?,' + #13#10 +  // 70
        'i_wz_ub_ub_id            => ?,' + #13#10 +  // 71
        'i_wz_un_un_id            => ?,' + #13#10 +  // 72
        'i_w_cpw_id               => ?,' + #13#10 +  // 73
        'i_w_dysp_wag_id          => ?,' + #13#10 +  // 74
        'i_w_dysp_wag_typ         => ?,' + #13#10 +  // 75
        'i_w_import               => ?,' + #13#10 +  // 76
        'i_w_eksport              => ?,' + #13#10 +  // 77
        'i_w_odmowa               => ?,' + #13#10 +  // 78
        'i_w_lad_uszkodz          => ?,' + #13#10 +  // 79
        'i_w_ilosc_plomb_tow      => ?,' + #13#10 +  // 80
        'i_we_tr_tr_id            => ?,' + #13#10 +  // 81
        'i_w_lad_zamroz           => ?,' + #13#10 +  // 82
        'i_w_lad_zamroz_prot      => ?,' + #13#10 +  // 83
        'i_w_medium_gt_id         => ?,' + #13#10 +  // 84
        'i_w_sp_sp_id             => ?,' + #13#10 +  // 85
        'i_we_wi_id               => ?,' + #13#10 +  // 86
        'i_we_czas_podstawienia   => ?,' + #13#10 +  // 87
        'i_we_czas_zabrania       => ?,' + #13#10 +  // 88
        'i_we_pobyt_rodzaj        => ?,' + #13#10 +  // 89
        'i_w_sdz_nr_zamowienia    => ?,' + #13#10 +  // 90
        'i_w_sdz_nr_pozycji       => ?,' + #13#10 +  // 91
        'i_w_sdd_nr_dostawy       => ?,' + #13#10 +  // 92
        'i_w_sdd_nr_pozycji       => ?);' + #13#10 + // 93*)
    'end;';
var
  item: TBkWagonPodstawienie;
  sql: string;
  stmt: ISQLDBStatement;
begin
  sql := cSQLExec;
  while sql.Contains('  ') do
    sql := StringReplace(sql, '  ', ' ', [rfReplaceAll]);
  stmt := FDbConnection.NewStatementPrepared(sql, False, True);
  for item in FWagonyPodstawienia do
    PodstawienieDodajWagon(item, stmt);
end;

procedure TBkWazeniaImportyPodstaw.PodstawienieDodajWagon(const APodstawienie: TBkWagonPodstawienie;
  const AStatement: ISQLDBStatement);
var
  i: Integer;
begin
    // Domyślne ustawienie wszystkich parametrów na null.
  for i := 1 to 3 do
    AStatement.BindNull(i, paramInOut);
  for i := 4 to 93 do
    AStatement.BindNull(i);
    // Numer wagonu
  AStatement.BindTextS(4, APodstawienie.WagonNumer, paramIn);
  AStatement.BindTextS(5, APodstawienie.WagonSeria, paramIn);
  AStatement.Bind(6, Integer(APodstawienie.WagonNumerRodzaj), paramIn);
  AStatement.Bind(7, Integer(APodstawienie.WagonNumerBlad), paramIn);
  AStatement.Bind(12, APodstawienie.WagonGranicaObciazenia, paramIn);
  AStatement.Bind(23, APodstawienie.WagonIloscOsi, paramIn);
    // Dane ładunku
  AStatement.Bind(9, APodstawienie.TaraPrzybyciaDekl, paramIn);
  AStatement.Bind(13, APodstawienie.MasaLadunkuDekl, paramIn);
    // Dokument podstawienia
  AStatement.Bind(34, DokumentPodstawieniaId, paramIn);
  AStatement.BindNull(35, paramInOut, ftInt64);
  AStatement.BindNull(36, paramIn);
  AStatement.BindNull(37, paramInOut, ftInt64);
    // Flaga obliczania automatycznego czasu wyładunku
  AStatement.Bind(42, 0, paramIn);
    // Flaga ponownego podstawienia
  AStatement.Bind(51, 0, paramIn);
    // Flaga zmiany tary
  AStatement.Bind(53, 0, paramIn);
  Astatement.BindCurrency(52, 0, paramIn);
    // Flaga podwójnej operacji ładunkowej
  AStatement.Bind(54, 0, paramIn);
    // Podział masy ładunku/towaru
  AStatement.Bind(55, 0, paramIn);
  AStatement.Bind(56, 0, paramIn);
    // Aktywne hamulce na przybyciu/zdaniu.
  AStatement.Bind(57, 1, paramIn);
  AStatement.Bind(58, 1, paramIn);
    // Flaga hamulec typu oerlikon
  AStatement.Bind(66, 0, paramIn);
    // Flaga hamulec z nastawiaczem
  AStatement.Bind(67, 0, paramIn);
    // Użytkownik bocznicy
  AStatement.Bind(70, PodstawienieParametry.UzytkownikBocznicyId, paramIn);
    // Dysponowanie wagonu typ
  AStatement.Bind(75, 1, paramIn);
    // Import
  AStatement.Bind(76, 0, paramIn);
    // Eksport
  AStatement.Bind(77, 0, paramIn);
    // Odmowa wagonu
  AStatement.Bind(78, 0, paramIn);
    // Ładunek uszkodzony
  AStatement.Bind(79, 0, paramIn);
    // Ilość plomb towaru
  AStatement.Bind(80, 0, paramIn);
    // Tor podstawienia wagonu
  AStatement.Bind(81, PodstawienieParametry.PodstawienieTorId, paramIn);
    // Ładunek zamrożony
  AStatement.Bind(82, 0, paramIn);
    // Ładunek zamrożony - protokół
  AStatement.Bind(83, 0, paramIn);
    // Powiązanie z wagonem z kartoteki... - trzeba dorobić w przyszłości.
    //'    i_we_wi_id                  => ?,' + #13#10 +  // 86
  AStatement.BindDateTime(87, PodstawienieParametry.PodstawienieCzas, paramIn);
    // Rodzaj pobytu - Loko
  AStatement.BindTextS(89, cPobytLoko, paramIn);
  AStatement.ExecutePrepared;
end;

And I'm really sure, that varchar parameters values have correct length. Here is also exception from log file:

20150320 01032624 SQL   		TSQLDBOracleStatement(7FE21BB0) begin   U_EKS.SP_WAGONY_OBECNE_INSERT(  io_wz_id => NULL,  io_wz_we_id => NULL,  io_wz_wp_id => NULL,  i_w_nr_wagonu => '31-51-5345282-8',  i_w_seria => '',  i_w_rodz_numer => 0,  i_w_zly_numer => 0,  i_w_tara_z_bel => NULL,  i_w_tara_dekl_lad => 0,  i_w_tara_dekl_lad_rodzaj => NULL,  i_w_tara_przewozowa => NULL,  i_w_gr_obciaz => 0,  i_w_masa_lad => 0,  i_wp_masa_lad_przewoz => NULL,  i_w_masa_tow => NULL,  i_w_masa_prz_l => NULL,  i_w_masa_prz_t => NULL,  i_w_masa_przew => NULL,  i_w_masa_opak_l => NULL,  i_w_masa_opak_t => NULL,  i_w_masa_wydz_lad => NULL,  i_w_masa_wydz_tow => NULL,  i_w_ilosc_osi => 0,  i_w_ilosc_szt_lad => NULL,  i_w_ilosc_opak_tow => NULL,  i_w_ilosc_szt_tow => NULL,  i_w_stezenie_lad => NULL,  i_w_stezenie_tow => NULL,  i_w_id_ladunku => NULL,  i_w_id_nadawcy => NULL,  i_w_id_towaru => NULL,  i_w_towar_opis_dod => NULL,  i_w_id_odbiorcy => NULL,  i_w_id_r25 => 20941,  io_w_lp_r25 => NULL,  i_w_id_r25t => NULL,  io_w_lp_r25t => NULL,  i_w_id_lis_prz => NULL,  i_w_lp_lis_prz => NULL,  i_w_czas_uk_za => NULL,  i_w_czas_uk_wy => NULL,  i_w_czas_uk_wy_pol_auto => 0,  i_w_czas_roz_za => NULL,  i_w_czas_dysp_od => NULL,  i_w_czas_ponow_dysp => NULL,  i_w_czas_roz_odprawy => NULL,  i_w_czas_odprawy => NULL,  i_w_czas_roz_czyn_adm => NULL,  i_w_czas_czyn_adm => NULL,  i_w_id_p_podst => NULL,  i_w_lp_p_podst => 0,  i_w_vat => 0,  i_w_zmiana_tary => 0,  i_w_podw_op_lad => 0,  i_w_podzial_masy_l => 0,  i_w_podzial_masy_t => 0,  i_w_akt_hamul_p => 1,  i_w_akt_hamul_z => 1,  i_w_dlugosc => NULL,  i_w_ciez_ham_1 => NULL,  i_w_ciez_ham_2 => NULL,  i_w_ciez_ham_pr => NULL,  i_w_masa_przest => NULL,  i_w_typ_hamulca => NULL,  i_w_rodzaj_hamul => NULL,  i_w_hamul_oerl => 0,  i_w_hamul_nast => 0,  i_wz_uzyt_wag_kod_liter => NULL,  i_wz_uzyt_wag_kod_cyfr => NULL,  i_w_ub_ub_id => 324,  i_wz_ub_ub_id => NULL,  i_wz_un_un_id => NULL,  i_w_cpw_id => NULL,  i_w_dysp_wag_id => NULL,  i_w_dysp_wag_typ => 1,  i_w_import => 0,  i_w_eksport => 0,  i_w_odmowa => 0,  i_w_lad_uszkodz => 0,  i_w_ilosc_plomb_tow => 0,  i_w... (truncated) length=2400
20150320 01032624 EXC   		ESQLDBOracle {"Statement":{"SQL":"begin\r\n U_EKS.SP_WAGONY_OBECNE_INSERT(\r\nio_wz_id => ?,\r\nio_wz_we_id => ?,\r\nio_wz_wp_id => ?,\r\ni_w_nr_wagonu => ?,\r\ni_w_seria => ?,\r\ni_w_rodz_numer => ?,\r\ni_w_zly_numer => ?,\r\ni_w_tara_z_bel => ?,\r\ni_w_tara_dekl_lad => ?,\r\ni_w_tara_dekl_lad_rodzaj => ?,\r\ni_w_tara_przewozowa => ?,\r\ni_w_gr_obciaz => ?,\r\ni_w_masa_lad => ?,\r\ni_wp_masa_lad_przewoz => ?,\r\ni_w_masa_tow => ?,\r\ni_w_masa_prz_l => ?,\r\ni_w_masa_prz_t => ?,\r\ni_w_masa_przew => ?,\r\ni_w_masa_opak_l => ?,\r\ni_w_masa_opak_t => ?,\r\ni_w_masa_wydz_lad => ?,\r\ni_w_masa_wydz_tow => ?,\r\ni_w_ilosc_osi => ?,\r\ni_w_ilosc_szt_lad => ?,\r\ni_w_ilosc_opak_tow => ?,\r\ni_w_ilosc_szt_tow => ?,\r\ni_w_stezenie_lad => ?,\r\ni_w_stezenie_tow => ?,\r\ni_w_id_ladunku => ?,\r\ni_w_id_nadawcy => ?,\r\ni_w_id_towaru => ?,\r\ni_w_towar_opis_dod => ?,\r\ni_w_id_odbiorcy => ?,\r\ni_w_id_r25 => ?,\r\nio_w_lp_r25 => ?,\r\ni_w_id_r25t => ?,\r\nio_w_lp_r25t => ?,\r\ni_w_id_lis_prz => ?,\r\ni_w_lp_lis_prz => ?,\r\ni_w_czas_uk_za => ?,\r\ni_w_czas_uk_wy => ?,\r\ni_w_czas_uk_wy_pol_auto => ?,\r\ni_w_czas_roz_za => ?,\r\ni_w_czas_dysp_od => ?,\r\ni_w_czas_ponow_dysp => ?,\r\ni_w_czas_roz_odprawy => ?,\r\ni_w_czas_odprawy => ?,\r\ni_w_czas_roz_czyn_adm => ?,\r\ni_w_czas_czyn_adm => ?,\r\ni_w_id_p_podst => ?,\r\ni_w_lp_p_podst => ?,\r\ni_w_vat => ?,\r\ni_w_zmiana_tary => ?,\r\ni_w_podw_op_lad => ?,\r\ni_w_podzial_masy_l => ?,\r\ni_w_podzial_masy_t => ?,\r\ni_w_akt_hamul_p => ?,\r\ni_w_akt_hamul_z => ?,\r\ni_w_dlugosc => ?,\r\ni_w_ciez_ham_1 => ?,\r\ni_w_ciez_ham_2 => ?,\r\ni_w_ciez_ham_pr => ?,\r\ni_w_masa_przest => ?,\r\ni_w_typ_hamulca => ?,\r\ni_w_rodzaj_hamul => ?,\r\ni_w_hamul_oerl => ?,\r\ni_w_hamul_nast => ?,\r\ni_wz_uzyt_wag_kod_liter => ?,\r\ni_wz_uzyt_wag_kod_cyfr => ?,\r\ni_w_ub_ub_id => ?,\r\ni_wz_ub_ub_id => ?,\r\ni_wz_un_un_id => ?,\r\ni_w_cpw_id => ?,\r\ni_w_dysp_wag_id => ?,\r\ni_w_dysp_wag_typ => ?,\r\ni_w_import => ?,\r\ni_w_eksport => ?,\r\ni_w_odmowa => ?,\r\ni_w_lad_uszkodz => ?,\r\ni_w_ilosc_plomb_tow => ?,\r\ni_we_tr_tr_id => ?,\r\ni_w_lad_zamroz => ?,\r\ni_w_lad_zamroz_prot => ?,\r\ni_w_medium_gt_id => ?,\r\ni_w_sp_sp_id => ?,\r\ni_we_wi_id => ?,\r\ni_we_czas_podstawienia => ?,\r\ni_we_czas_zabrania => ?,\r\ni_we_pobyt_rodzaj => ?,\r\ni_w_sdz_nr_zamowienia => ?,\r\ni_w_sdz_nr_pozycji => ?,\r\ni_w_sdd_nr_dostawy => ?,\r\ni_w_sdd_nr_pozycji => ?);\r\nend","SQLWithInlinedParams":"begin\r\n U_EKS.SP_WAGONY_OBECNE_INSERT(\r\nio_wz_id => NULL,\r\nio_wz_we_id => NULL,\r\nio_wz_wp_id => NULL,\r\ni_w_nr_wagonu => '31-51-5345282-8',\r\ni_w_seria => '',\r\ni_w_rodz_numer => 0,\r\ni_w_zly_numer => 0,\r\ni_w_tara_z_bel => NULL,\r\ni_w_tara_dekl_lad => 0,\r\ni_w_tara_dekl_lad_rodzaj => NULL,\r\ni_w_tara_przewozowa => NULL,\r\ni_w_gr_obciaz => 0,\r\ni_w_masa_lad => 0,\r\ni_wp_masa_lad_przewoz => NULL,\r\ni_w_masa_tow => NULL,\r\ni_w_masa_prz_l => NULL,\r\ni_w_masa_prz_t => NULL,\r\ni_w_masa_przew => NULL,\r\ni_w_masa_opak_l => NULL,\r\ni_w_masa_opak_t => NULL,\r\ni_w_masa_wydz_lad => NULL,\r\ni_w_masa_wydz_tow => NULL,\r\ni_w_ilosc_osi => 0,\r\ni_w_ilosc_szt_lad => NULL,\r\ni_w_ilosc_opak_tow => NULL,\r\ni_w_ilosc_szt_tow => NULL,\r\ni_w_stezenie_lad => NULL,\r\ni_w_stezenie_tow => NULL,\r\ni_w_id_ladunku => NULL,\r\ni_w_id_nadawcy => NULL,\r\ni_w_id_towaru => NULL,\r\ni_w_towar_opis_dod => NULL,\r\ni_w_id_odbiorcy => NULL,\r\ni_w_id_r25 => 20941,\r\nio_w_lp_r25 => NULL,\r\ni_w_id_r25t => NULL,\r\nio_w_lp_r25t => NULL,\r\ni_w_id_lis_prz => NULL,\r\ni_w_lp_lis_prz => NULL,\r\ni_w_czas_uk_za => NULL,\r\ni_w_czas_uk_wy => NULL,\r\ni_w_czas_uk_wy_pol_auto => 0,\r\ni_w_czas_roz_za => NULL,\r\ni_w_czas_dysp_od => NULL,\r\ni_w_czas_ponow_dysp => NULL,\r\ni_w_czas_roz_odprawy => NULL,\r\ni_w_czas_odprawy => NULL,\r\ni_w_czas_roz_czyn_adm => NULL,\r\ni_w_czas_czyn_adm => NULL,\r\ni_w_id_p_podst => NULL,\r\ni_w_lp_p_podst => 0,\r\ni_w_vat => 0,\r\ni_w_zmiana_tary => 0,\r\ni_w_podw_op_lad => 0,\r\ni_w_podzial_masy_l => 0,\r\ni_w_podzial_masy_t => 0,\r\ni_w_akt_hamul_p => 1,\r\ni_w_akt_hamul_z => 1,\r\ni_w_dlugosc => NULL,\r\ni_w_ciez_ham_1 => NULL,\r\ni_w_ciez_ham_2 => NULL,\r\ni_w_ciez_ham_pr => NULL,\r\ni_w_masa_przest => NULL,\r\ni_w_typ_hamulca => NULL,\r\ni_w_rodzaj_hamul => NULL,\r\ni_w_hamul_oerl => 0,\r\ni_w_hamul_nast => 0,\r\ni_wz_uzyt_wag_kod_liter => NULL,\r\ni_wz_uzyt_wag_kod_cyfr => NULL,\r\ni_w_ub_ub_id => 324,\r\ni_wz_ub_ub_id => NULL,\r\ni_wz_un_un_id => NULL,\r\ni_w_cpw_id => NULL,\r\ni_w_dysp_wag_id => NULL,\r\ni_w_dysp_wag_typ => 1,\r\ni_w_import => 0,\r\ni_w_eksport => 0,\r\ni_w_odmowa => 0,\r\ni_w_lad_uszkodz => 0,\r\ni_w_ilosc_plomb_tow => 0,\r\ni_we_tr_tr_id => 202,\r\ni_w_lad_zamroz => 0,\r\ni_w_lad_zamroz_prot => 0,\r\ni_w_medium_gt_id => NULL,\r\ni_w_sp_sp_id => NULL,\r\ni_we_wi_id => NULL,\r\ni_we_czas_podstawienia => NULL,\r\ni_we_czas_zabrania => NULL,\r\ni_we_pobyt_rodzaj => 'L',\r\ni_w_sdz_nr_zamowienia => NULL,\r\ni_w_sdz_nr_pozycji => NULL,\r\ni_w_sdd_nr_dostawy => NULL,\r\ni_w_sdd_nr_pozycji => NULL);\r\nend","CurrentRow":0,"TotalRowsRetrieved":0,"Connection":{"Connected":true,"ServerTimeStampAtConnection":"2015-03-20T01:03:26","TotalConnectionCount":1,"TransactionCount":1,"InTransaction":true,"RollbackOnDisconnect":true,"LastErrorMessage":"","LastErrorWasAboutConnection":false,"Properties":{"ClientVersion":"oci.dll rev. 11.2.0.2","EnvironmentInitializationMode":7,"InternalBufferSize":131072,"RowsPrefetchSize":131072,"BlobPrefetchSize":4096,"StatementCacheSize":30,"Engine":"Oracle","ServerName":"xe","DatabaseName":"","UserID":"system","DBMS":2,"DBMSEngineName":"Oracle","BatchSendingAbilities":13,"BatchMaxSentAtOnce":10000,"LoggedSQLMaxSize":0,"LogSQLStatementOnException":false,"ForcedSchemaName":"","UseCache":true,"RollbackOnDisconnect":true,"StoreVoidStringAsNull":false}}},"Message":"TSQLDBOracleStatement error: ORA-06502: PL/SQL: numeric or value error: character string buffer too small\nORA-06512: at line 2"} at 00A80B14  stack trace API 008FF874 008FF89C 5005FDB8 77B10243 77B109BF 00A80B14 00A8572D 00A84FF3 059762BB 05976395 0597562B 05978302 009A170B 
20150320 01032624 DB    		TSQLDBOracleStatement(7FE21BB0) 0 row(s) in 6.45ms

I'm still using mORMot from 16 March 2015 09:16:18, revision 1389 from GitHub svn repository and Delphi XE4.

#56 mORMot 1 » TID fields documentation - question and mistake » 2015-03-18 20:13:34

ASiwon
Replies: 2

Hello,

I think in documentation in section 5.1.6. TID fields is a small bug. In first example in this section exists a code:

TSQLOrder = class(TSQLRecord)
...
published Client: TID
read fClient write fClient;
published OrderedBy: TSQLRecordClientID
read fOrderedBy write fOrderedBy;
published OrderedByCascade: TSQLRecordClientToBeDeletedID
read fOrderedByCascade write fOrderedByCascade;

But in this code is an syntax error. I think it should be property word instead of published word.

I have one question to the TID fields. In mORMot is now possible to simulate set default and delete cascade behavior for delete operation. It is very smart and usefull. But what with the most usual behavior from databases: restrict? Is it possible to define TID type to avoid deletion of record which are linked with records in other tables?

#57 Re: mORMot 1 » Growing indentation of text in log files » 2015-03-18 20:01:56

I have change setting to ptIdentifiedInOnFile. In the log file exist now an thread identifier in every line of the log file as expected. I will send you an information if I will find any unexpected results.

#58 Re: mORMot 1 » Growing indentation of text in log files » 2015-03-18 15:10:48

I have changed parameter PerThreadLog to the ptOneFilePerThread value. Now log file looks correct (there is no strange indentation) but there is still only one log file. In the name of this file is added integer value (ThreadId?) Is it necessary to set TSynLog.Family options for particular threads? To setting Family options I'm using TSQLLog class not TSynLog class. Maybe here is a problem?

#59 Re: mORMot 1 » Growing indentation of text in log files » 2015-03-18 12:24:11

Hello,

I'm using version from date 16 march 2015 09:16:18, revision 1389 from github svn repository.

After long time log file looks like:

20150317 11551003  +    		TSQLRestServerDB(011F1E70).URI(POST root/BkWazeniaImport._free_/10118 inlen=2)
20150317 11551003 call  			TSQLRestServerDB(011F1E70) BkWazeniaImport._free_
20150317 11551003  -    		00.000.017
20150317 11551003 srvr  		TSQLRestServerDB(011F1E70)   POST root/BkWazeniaImport._free_ SOA-Interface -> 200 with outlen=0 in 38 us
20150317 11551003  -    	72.108.686
20150317 11551145  +    																																												TSQLRestServerDB(011F1E70).URI(GET root/TimeStamp inlen=0)
20150317 11551145 call  																																													TSQLRestServerDB(011F1E70) TimeStamp
20150317 11551145 srvr  																																													TSQLRestServerDB(011F1E70)   GET root/TimeStamp SOA-Method -> 200 with outlen=12 in 28 us
20150317 11551145  -    																																												00.000.020
20150317 11552719  +    																																	TSQLRestServerDB(011F1E70).URI(GET root/Auth?UserName=User inlen=0)
20150317 11552719 call  																																		TSQLRestServerDB(011F1E70) Auth
20150317 11552719 debug 																																		TSQLRestServerDB(011F1E70) {  "errorCode":400,  "errorText":"Bad Request"  }
20150317 11552719 srvr  																																		TSQLRestServerDB(011F1E70)   GET root/Auth SOA-Method -> 400 with outlen=49 in 33 us
20150317 11552719  -    																																	00.000.024
20150317 11552944  +    		TSQLRestServerDB(011F1E70).URI(POST root/BkWazeniaImport._contract_ inlen=2)
20150317 11552944 call  			TSQLRestServerDB(011F1E70) BkWazeniaImport._contract_
20150317 11552944 srvr  			TSQLRestServerDB(011F1E70)   POST root/BkWazeniaImport._contract_ SOA-Interface -> 200 with outlen=31 in 28 us
20150317 11552944  -    		00.000.020
20150317 11553213  +    						TSQLRestServerDB(011F1E70).URI(GET root/BkWazenieZrodloDanych/1/ParametryWagi inlen=0)
20150317 11553213 SQL   							TSQLDBOracleStatement(023FDF60) select ZDW_PARAMETRY_WAGI from U_EKS.T_ZRODLA_DANYCH_WAZENIA where ZDW_ID=1
20150317 11553213 DB    							TSQLDBOracleStatement(023FDF60) 1 row(s) in 569us
20150317 11553213 srvr  							TSQLRestServerDB(011F1E70)   GET root/BkWazenieZrodloDanych ORM-Get -> 200 with outlen=104 in 977 us
20150317 11553213  -    						00.000.971
20150317 11553501  +    																																																							TSQLRestServerDB(011F1E70).URI(GET root/TimeStamp inlen=0)
20150317 11553501 call  																																																								TSQLRestServerDB(011F1E70) TimeStamp
20150317 11553501 srvr  																																																								TSQLRestServerDB(011F1E70)   GET root/TimeStamp SOA-Method -> 200 with outlen=12 in 29 us
20150317 11553501  -    																																																							00.000.021
20150317 11553642  +    																																																					TSQLRestServerDB(011F1E70).URI(GET root/Auth?UserName=User inlen=0)
20150317 11553642 call  																																																						TSQLRestServerDB(011F1E70) Auth
20150317 11553642 debug 																																																						TSQLRestServerDB(011F1E70) {  "errorCode":400,  "errorText":"Bad Request"  }
20150317 11553642 srvr  																																																						TSQLRestServerDB(011F1E70)   GET root/Auth SOA-Method -> 400 with outlen=49 in 33 us
20150317 11553642  -    																																																					00.000.024
20150317 11553740  +    																	TSQLRestServerDB(011F1E70).URI(POST root/BkWazeniaImport._contract_ inlen=2)
20150317 11553740 call  																		TSQLRestServerDB(011F1E70) BkWazeniaImport._contract_
20150317 11553740 srvr  																		TSQLRestServerDB(011F1E70)   POST root/BkWazeniaImport._contract_ SOA-Interface -> 200 with outlen=31 in 27 us
20150317 11553740  -    																	00.000.020
20150317 11553806  +    																																																																		TSQLRestServerDB(011F1E70).URI(GET root/BkWazenieZrodloDanych/1/ParametryWagi inlen=0)
20150317 11553806 SQL   																																																																			TSQLDBOracleStatement(023FDF60) select ZDW_PARAMETRY_WAGI from U_EKS.T_ZRODLA_DANYCH_WAZENIA where ZDW_ID=1
20150317 11553806 DB    																																																																			TSQLDBOracleStatement(023FDF60) 1 row(s) in 623us
20150317 11553806 srvr  																																																																			TSQLRestServerDB(011F1E70)   GET root/BkWazenieZrodloDanych ORM-Get -> 200 with outlen=104 in 1029 us

So some log informations have short indentation and some informations have long indentation.
But my mORMot service is connected to the Oracle database which is used also for writing by other apps. And I have many conflicts while updating data in the database which can happens also in production version. In this cases in log file request timeouts are reported. Maybe in this case freeing of the context takes much more time than usual. Please look in the above log example: for line 20150317 11551003  -        72.108.686 - logged time is long. Maybe this is very specific environment related problem. But in all cases REST service works correctly and still response for all requests.

#60 mORMot 1 » Growing indentation of text in log files » 2015-03-16 14:41:29

ASiwon
Replies: 7

Hello,

I found strange problem in log files which was created using TSQLLog class instances. The problem occurs only, when for called procedure an exception is raised. Here is small example:

20150316 14403761  +    TSQLRestServerDB(011F1E70).URI(POST root/BkWazeniaImport.Dodaj inlen=519)
20150316 14403761 call  	TSQLRestServerDB(011F1E70) BkWazeniaImport.Dodaj
20150316 14403761 call  	TServiceFactoryServer(0125D140) Adding BkWazeniaImport instance (id=10)
20150316 14403761  +    	TBkSerwisWazenieImport(01278CC0).Dodaj
20150316 14403761  +    		TSQLRestServerDB(011F1E70).URI(GET root inlen=522)
20150316 14403761 SQL   			TSQLDBOracleStatement(023FDE40) select WWI_ID as ID,WWI_ZDW_ID as WagaId,WWI_STANOWISKO as WagaStanowisko,WWI_GRANICA_OBC as WagonGranicaObciazenia,WWI_NR_WAGONU as WagonNumer,WWI_NR_WAGONU_BLAD as WagonNumerBlad,WWI_NR_WAGONU_FILTR as WagonNumerFiltr,WWI_NR_WAGONU_RODZ as WagonNumerRodzaj,WWI_WE_ID as WagonPobytId,WWI_TARA_Z_BEL as WagonTaraZBelki,WWI_WAGOWY as WagowyDane,WWI_WW_ID as WazenieBkId,WWI_CZAS_WAZENIA as WazenieCzas,WWI_WAZENIE_ID as WazenieIdZewnetrzne,WWI_TOWAR_NAZWA as WazenieLadunekNazwa,WWI_TOWAR_NUMER as WazenieLadunekNumer,WWI_MASA_BRUTTO as WazenieMasaBrutto,WWI_MASA_NETTO as WazenieMasaNetto,WWI_POSREDNIE as WazeniePosrednie,WWI_RODZAJ_WAZ as WazenieRodzaj,WWI_POTWIERDZ as WazenieRodzajPotwierdz,WWI_SKLAD as WazenieSklad,WWI_SKLAD_ID as WazenieSkladId,WWI_STATUS as WazenieStatus,WWI_TECHNOLOGICZNY as WazenieTechnologiczne from U_EKS.T_WAGONY_WAZENIA_IMPORTY where rownum<=1 and WWI_ZDW_ID=1 and WWI_STANOWISKO='HK1' and WWI_CZAS_WAZENIA='2015-01-02 06:55:14'
20150316 14403809 DB    			TSQLDBOracleStatement(023FDE40) 0 row(s) in 154.06ms
20150316 14403809 srvr  			TSQLRestServerDB(011F1E70)   GET root/ ORM-Get -> 200 with outlen=476 in 154191 us
20150316 14403809  -    		00.154.196
20150316 14403809 info  		Utworzono strukturę importu danych ważenia.
20150316 14403809  +    		TSQLRestServerDB(011F1E70).URI(POST root/BkWazenieImport inlen=607)
20150316 14403809 SQL   			TSQLDBOracleStatement(023FDE40) insert into U_EKS.T_WAGONY_WAZENIA_IMPORTY (WWI_ID,WWI_ZDW_ID,WWI_STANOWISKO,WWI_GRANICA_OBC,WWI_NR_WAGONU,WWI_NR_WAGONU_BLAD,WWI_NR_WAGONU_FILTR,WWI_NR_WAGONU_RODZ,WWI_WE_ID,WWI_TARA_Z_BEL,WWI_WAGOWY,WWI_WW_ID,WWI_CZAS_WAZENIA,WWI_WAZENIE_ID,WWI_TOWAR_NAZWA,WWI_TOWAR_NUMER,WWI_MASA_BRUTTO,WWI_MASA_NETTO,WWI_POSREDNIE,WWI_RODZAJ_WAZ,WWI_POTWIERDZ,WWI_SKLAD,WWI_SKLAD_ID,WWI_STATUS,WWI_TECHNOLOGICZNY) values (59721,1,'HK1',0,'82-51-5329990-4',1,'409992351528',0,0,0,'Renata Pach-Chalupka',0,'2015-01-02 06:55:14',313653,'KOKS STABIL','KOKS STABIL',55600,0,0,4,1,'680',34516,0,0)
20150316 14403809 EXC   			ESQLDBOracle {"Statement":{"SQL":"insert into U_EKS.T_WAGONY_WAZENIA_IMPORTY (WWI_ID,WWI_ZDW_ID,WWI_STANOWISKO,WWI_GRANICA_OBC,WWI_NR_WAGONU,WWI_NR_WAGONU_BLAD,WWI_NR_WAGONU_FILTR,WWI_NR_WAGONU_RODZ,WWI_WE_ID,WWI_TARA_Z_BEL,WWI_WAGOWY,WWI_WW_ID,WWI_CZAS_WAZENIA,WWI_WAZENIE_ID,WWI_TOWAR_NAZWA,WWI_TOWAR_NUMER,WWI_MASA_BRUTTO,WWI_MASA_NETTO,WWI_POSREDNIE,WWI_RODZAJ_WAZ,WWI_POTWIERDZ,WWI_SKLAD,WWI_SKLAD_ID,WWI_STATUS,WWI_TECHNOLOGICZNY) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)","SQLWithInlinedParams":"insert into U_EKS.T_WAGONY_WAZENIA_IMPORTY (WWI_ID,WWI_ZDW_ID,WWI_STANOWISKO,WWI_GRANICA_OBC,WWI_NR_WAGONU,WWI_NR_WAGONU_BLAD,WWI_NR_WAGONU_FILTR,WWI_NR_WAGONU_RODZ,WWI_WE_ID,WWI_TARA_Z_BEL,WWI_WAGOWY,WWI_WW_ID,WWI_CZAS_WAZENIA,WWI_WAZENIE_ID,WWI_TOWAR_NAZWA,WWI_TOWAR_NUMER,WWI_MASA_BRUTTO,WWI_MASA_NETTO,WWI_POSREDNIE,WWI_RODZAJ_WAZ,WWI_POTWIERDZ,WWI_SKLAD,WWI_SKLAD_ID,WWI_STATUS,WWI_TECHNOLOGICZNY) values (59721,1,'HK1',0,'82-51-5329990-4',1,'409992351528',0,0,0,'Renata Pach-Chalupka',0,'2015-01-02 06:55:14',313653,'KOKS STABIL','KOKS STABIL',55600,0,0,4,1,'680',34516,0,0)","CurrentRow":0,"TotalRowsRetrieved":0,"Connection":{"Connected":true,"ServerTimeStampAtConnection":"2015-03-16T14:39:49","TotalConnectionCount":1,"TransactionCount":0,"InTransaction":false,"RollbackOnDisconnect":true,"LastErrorMessage":"","LastErrorWasAboutConnection":false,"Properties":{"ClientVersion":"oci.dll rev. 11.2.0.1","EnvironmentInitializationMode":7,"InternalBufferSize":131072,"RowsPrefetchSize":131072,"BlobPrefetchSize":4096,"StatementCacheSize":30,"Engine":"Oracle","ServerName":"kolprem","DatabaseName":"","UserID":"system","DBMS":2,"DBMSEngineName":"Oracle","BatchSendingAbilities":13,"BatchMaxSentAtOnce":10000,"LoggedSQLMaxSize":0,"LogSQLStatementOnException":false,"ForcedSchemaName":"","UseCache":true,"RollbackOnDisconnect":true,"StoreVoidStringAsNull":false}}},"Message":"TSQLDBOracleStatement error: ORA-12899: wartość zbyt duża dla kolumny \"U_EKS\".\"T_WAGONY_WAZENIA_IMPORTY\".\"WWI_TOWAR_NUMER\" (obecna: 11, maksymalna: 6)"} at 00768834  stack trace API 005FFC02 5005FDB8 77B1B46B 77AD0133 00768834 0076CB8A 00753634 007513FA 00668A70 0066D57C 006A587C 0066463A 00664F70 006603D7 00679333 0246249A 024621B1 02462F05 00690AB7 00000001 00691A9D 006695FD 00669753 0066CC53 00668B8C 0066D57C 0072CD69 00722597 5016C3B9 50060BA6 
20150316 14403809 DB    			TSQLDBOracleStatement(023FDE40) 0 row(s) in 1.18ms
20150316 14403809 debug 			TSQLRestServerDB(011F1E70) {  "errorCode":400,  "errorText":"Bad Request"  }
20150316 14403809 srvr  			TSQLRestServerDB(011F1E70)   POST root/BkWazenieImport ORM-Write -> 400 with outlen=49 in 1261 us
20150316 14403809  -    		00.001.262
20150316 14403809 ERROR 		TSQLRestClientDB(023A4980) POST root/BkWazenieImport returned 400 Bad Request with message  {  "errorCode":400,  "errorText":"Bad Request"  } stack trace API 00601061 006647A9 00664F70 006603D7 00679333 0246249A 024621B1 02462F05 00690AB7 00000001 00691A9D 006695FD 00669753 0066CC53 00668B8C 0066D57C 0072CD69 00722597 5016C3B9 50060BA6 773E338A 77AF9F72 77AF9F45 
20150316 14403809 fail  		Podczas zapisu danych ważenia wystąpił błąd: 400: {  "errorCode":400,  "errorText":"Bad Request"  } stack trace API 00601129 002C292F 024624E8 024621B1 02462F05 00690AB7 00000001 00691A9D 006695FD 00669753 0066CC53 00668B8C 0066D57C 0072CD69 00722597 5016C3B9 50060BA6 773E338A 77AF9F72 77AF9F45 
20150316 14403809 EXC   		Exception ("Podczas zapisu danych ważenia wystąpił błąd: 400: {\r\n\"errorCode\":400,\r\n\"errorText\":\"Bad Request\"\r\n}") at 002C294E  stack trace 50060EFF 00724A5A 5005990B 0072CD69 00722597 00726AE8 5016C3B9 50060BA6 773E338A 77AF9F72 77AF9F45 
20150316 14403809 debug 		TSQLRestServerDB(011F1E70) {  "errorCode":500,  "error":  {"Exception":{"Exception":"Podczas zapisu danych ważenia wystąpił błąd: 400: {\r\n\"errorCode\":400,\r\n\"errorText\":\"Bad Request\"\r\n}")}  }
20150316 14403809 srvr  		TSQLRestServerDB(011F1E70)   POST root/BkWazeniaImport.Dodaj SOA-Interface -> 500 with outlen=180 in 156094 us
20150316 14403809  -    	00.156.048
20150316 14403910  +    	TSQLRestServerDB(011F1E70).URI(GET root/TimeStamp inlen=0)
20150316 14403910 call  		TSQLRestServerDB(011F1E70) TimeStamp
20150316 14403910 srvr  		TSQLRestServerDB(011F1E70)   GET root/TimeStamp SOA-Method -> 200 with outlen=12 in 30 us
20150316 14403910  -    	00.000.021
20150316 14403910  +    		TSQLRestServerDB(011F1E70).URI(GET root/Auth?UserName=User inlen=0)
20150316 14403910 call  			TSQLRestServerDB(011F1E70) Auth
20150316 14403910 debug 			TSQLRestServerDB(011F1E70) {  "errorCode":400,  "errorText":"Bad Request"  }
20150316 14403910 srvr  			TSQLRestServerDB(011F1E70)   GET root/Auth SOA-Method -> 400 with outlen=49 in 20 us
20150316 14403910  -    		00.000.018
20150316 14403910  +    	TSQLRestServerDB(011F1E70).URI(POST root/BkWazeniaImport._contract_ inlen=2)
20150316 14403910 call  		TSQLRestServerDB(011F1E70) BkWazeniaImport._contract_
20150316 14403910 srvr  		TSQLRestServerDB(011F1E70)   POST root/BkWazeniaImport._contract_ SOA-Interface -> 200 with outlen=31 in 15 us
20150316 14403910  -    	00.000.014
20150316 14403910  +    	TSQLRestServerDB(011F1E70).URI(GET root/BkWazenieZrodloDanych/1/ParametryWagi inlen=0)
20150316 14403910 SQL   		TSQLDBOracleStatement(023FDE40) select ZDW_PARAMETRY_WAGI from U_EKS.T_ZRODLA_DANYCH_WAZENIA where ZDW_ID=1
20150316 14403910 DB    		TSQLDBOracleStatement(023FDE40) 1 row(s) in 979us
20150316 14403910 srvr  		TSQLRestServerDB(011F1E70)   GET root/BkWazenieZrodloDanych ORM-Get -> 200 with outlen=104 in 1384 us
20150316 14403910  -    	00.001.385
20150316 14403915  +    	TSQLRestServerDB(011F1E70).URI(GET root/BkWazenieZrodloDanych/1/ParametryImportu inlen=0)
20150316 14403915 SQL   		TSQLDBOracleStatement(023FDE40) select ZDW_PARAMETRY_IMPORTU from U_EKS.T_ZRODLA_DANYCH_WAZENIA where ZDW_ID=1
20150316 14403915 DB    		TSQLDBOracleStatement(023FDE40) 1 row(s) in 936us
20150316 14403915 srvr  		TSQLRestServerDB(011F1E70)   GET root/BkWazenieZrodloDanych ORM-Get -> 200 with outlen=153 in 1350 us
20150316 14403915  -    	00.001.343
20150316 14403918  +    	TSQLRestServerDB(011F1E70).URI(GET root/BkWazenieZrodloDanych/1 inlen=0)
20150316 14403918 SQL   		TSQLDBOracleStatement(023FDE40) select ZDW_ID as ID,ZDW_AKTYWNY as Aktywne,ZDW_NAZWA as Nazwa,ZDW_PARAMETRY_DANE as ParametryDanych,ZDW_WGS_ID as SystemWagowy,ZDW_UBW_UBW_ID as WydzialId from U_EKS.T_ZRODLA_DANYCH_WAZENIA where ZDW_ID=1
20150316 14403918 DB    		TSQLDBOracleStatement(023FDE40) 1 row(s) in 949us
20150316 14403918 srvr  		TSQLRestServerDB(011F1E70)   GET root/BkWazenieZrodloDanych ORM-Get -> 200 with outlen=129 in 1018 us
20150316 14403918  -    	00.001.011
20150316 14403946  +    TSQLRestServerDB(011F1E70).URI(POST root/BkWazeniaImport.Dodaj inlen=519)

For the line:
20150316 14403761  +    TSQLRestServerDB(011F1E70).URI(POST root/BkWazeniaImport.Dodaj inlen=519)

- (leave event) is never? or after long time called. In my test environment there is only one client which calls procedure sequentially. So before next call should be leave event logged. After some calls indentation of the log desciptions is growing and growing. At the end of my log file it looks like:

20150316 14511900  +    																							TSQLRestServerDB(011F1E70).URI(POST root/BkWazeniaImport.Dodaj inlen=490)
20150316 14511900 call  																								TSQLRestServerDB(011F1E70) BkWazeniaImport.Dodaj
20150316 14511900 call  																								TServiceFactoryServer(0125D140) Adding BkWazeniaImport instance (id=267)
20150316 14511900  +    																								TBkSerwisWazenieImport(04E91330).Dodaj
20150316 14511900  +    																									TSQLRestServerDB(011F1E70).URI(GET root inlen=522)
20150316 14511900 SQL   																										TSQLDBOracleStatement(023FDF60) select WWI_ID as ID,WWI_ZDW_ID as WagaId,WWI_STANOWISKO as WagaStanowisko,WWI_GRANICA_OBC as WagonGranicaObciazenia,WWI_NR_WAGONU as WagonNumer,WWI_NR_WAGONU_BLAD as WagonNumerBlad,WWI_NR_WAGONU_FILTR as WagonNumerFiltr,WWI_NR_WAGONU_RODZ as WagonNumerRodzaj,WWI_WE_ID as WagonPobytId,WWI_TARA_Z_BEL as WagonTaraZBelki,WWI_WAGOWY as WagowyDane,WWI_WW_ID as WazenieBkId,WWI_CZAS_WAZENIA as WazenieCzas,WWI_WAZENIE_ID as WazenieIdZewnetrzne,WWI_TOWAR_NAZWA as WazenieLadunekNazwa,WWI_TOWAR_NUMER as WazenieLadunekNumer,WWI_MASA_BRUTTO as WazenieMasaBrutto,WWI_MASA_NETTO as WazenieMasaNetto,WWI_POSREDNIE as WazeniePosrednie,WWI_RODZAJ_WAZ as WazenieRodzaj,WWI_POTWIERDZ as WazenieRodzajPotwierdz,WWI_SKLAD as WazenieSklad,WWI_SKLAD_ID as WazenieSkladId,WWI_STATUS as WazenieStatus,WWI_TECHNOLOGICZNY as WazenieTechnologiczne from U_EKS.T_WAGONY_WAZENIA_IMPORTY where rownum<=1 and WWI_ZDW_ID=1 and WWI_STANOWISKO='HK1' and WWI_CZAS_WAZENIA='2014-10-07 03:11:30'
20150316 14511904 DB    																										TSQLDBOracleStatement(023FDF60) 1 row(s) in 65.47ms
20150316 14511904 srvr  																										TSQLRestServerDB(011F1E70)   GET root/ ORM-Get -> 200 with outlen=631 in 65586 us
20150316 14511904  -    																									00.065.591
20150316 14511904 info  																									Utworzono strukturę importu danych ważenia.
20150316 14511904 debug 																									Znaleziono rekord z zapisem danych ważenia. Identyfikator: 60080
20150316 14511904 info  																									Znaleziono rekord z zapisem danych ważenia - ścieżka aktualizacji danych ważenia.
20150316 14511904  +    																									TSQLRestServerDB(011F1E70).URI(PUT root/BkWazenieImport/60080 inlen=578)
20150316 14512110 srvr  																										TSQLRestRoutingREST(024396A0) TimeOut {"TSQLRestRoutingREST(024396A0)":{}}.Execute(execORMWrite) after 2000 ms
20150316 14512110 debug 																										TSQLRestServerDB(011F1E70) {  "errorCode":408,  "errorText":"Request Timeout"  }
20150316 14512110 srvr  																										TSQLRestServerDB(011F1E70)   PUT root/BkWazenieImport ORM-Write -> 408 with outlen=53 in 2090599 us
20150316 14512110  -    																									02.090.603
20150316 14512110 ERROR 																									TSQLRestClientDB(023A4980) PUT root/BkWazenieImport/60080 returned 408 Request Timeout with message  {  "errorCode":408,  "errorText":"Request Timeout"  } stack trace API 00601061 006647A9 006653AF 0065FFD6 006795A7 024621A5 02462F05 00690AB7 00000001 00691A9D 006695FD 00669753 0066CC53 00668B8C 0066D57C 0072CD69 00722597 5016C3B9 50060BA6 773E338A 77AF9F72 77AF9F45 
20150316 14512110 info  																									Zmieniono import ważenia o identyfikatorze: 60080
20150316 14512110 info  																									Zakończono przetwarzanie danych ważenia.
20150316 14512110 srvr  																									TSQLRestServerDB(011F1E70)   POST root/BkWazeniaImport.Dodaj SOA-Interface -> 200 with outlen=27 in 2156412 us
20150316 14512110  -    																								02.156.368
20150316 14512230  +    																									TSQLRestServerDB(011F1E70).URI(LOCK root/BkWazenieZrodloDanych/1 inlen=0)
20150316 14512230 SQL   																										TSQLDBOracleStatement(023FDF60) select ZDW_ID as ID,ZDW_AKTYWNY as Aktywne,ZDW_NAZWA as Nazwa,ZDW_PARAMETRY_DANE as ParametryDanych,ZDW_WGS_ID as SystemWagowy,ZDW_UBW_UBW_ID as WydzialId from U_EKS.T_ZRODLA_DANYCH_WAZENIA where ZDW_ID=1
20150316 14512230 DB    																										TSQLDBOracleStatement(023FDF60) 1 row(s) in 514us
20150316 14512230 srvr  																										TSQLRestServerDB(011F1E70)   LOCK root/BkWazenieZrodloDanych ORM-Get -> 200 with outlen=129 in 584 us
20150316 14512230  -    																									00.000.576
20150316 14512357  +    																								TSQLRestServerDB(011F1E70).URI(PUT root/BkWazenieZrodloDanych/1 inlen=122)
20150316 14512618 srvr  																									TSQLRestRoutingREST(02439290) TimeOut {"TSQLRestRoutingREST(02439290)":{}}.Execute(execORMWrite) after 2000 ms
20150316 14512618 debug 																									TSQLRestServerDB(011F1E70) {  "errorCode":408,  "errorText":"Request Timeout"  }
20150316 14512618 srvr  																									TSQLRestServerDB(011F1E70)   PUT root/BkWazenieZrodloDanych ORM-Write -> 408 with outlen=53 in 2405761 us
20150316 14512618  -    																								02.405.756
20150316 14512737  +    																										TSQLRestServerDB(011F1E70).URI(UNLOCK root/BkWazenieZrodloDanych/1 inlen=0)
20150316 14512737 srvr  																											TSQLRestServerDB(011F1E70)   UNLOCK root/BkWazenieZrodloDanych ORM-Get -> 200 with outlen=0 in 21 us
20150316 14512737  -    																										00.000.016
20150316 14512857  +    																								TSQLRestServerDB(011F1E70).URI(POST root/BkWazeniaImport._free_/267 inlen=2)
20150316 14512857 call  																									TSQLRestServerDB(011F1E70) BkWazeniaImport._free_
20150316 14512857  -    																								00.000.018
20150316 14512857 srvr  																								TSQLRestServerDB(011F1E70)   POST root/BkWazeniaImport._free_ SOA-Interface -> 200 with outlen=0 in 38 us
20150316 14512857  -    																							99.802.458

Is it a problem in mORMot or I'm doing something wrong?

#61 Re: mORMot 1 » Memory managment in mORMot question » 2015-03-16 10:46:44

Thank you very much. This helped me a lot!

#62 Re: mORMot 1 » Memory managment in mORMot question » 2015-03-16 07:34:24

Hello,

please let me know if you would like to make changes in mORMot code or not. This is very important to me and I have very little time to decide what I should to do. If you don't want to make changes then Ok - I will change my copy of sources. But I just need to know: should I wait for change or not.

#63 Re: mORMot 1 » Memory managment in mORMot question » 2015-03-14 10:00:10

Can you add to the mORMot source code, changes to the GarbageCollectorFree procedure which I have described in previous post?

#64 Re: mORMot 1 » Memory managment in mORMot question » 2015-03-13 13:10:51

The problem may indeed come from the fact that there are two GarbageCollectorFree calls... one in the main program, and another in the package.

There is only one GarbageCollectorFree call - from main program. It was tested using debugger. I'm using bpl packages, not dll libraries. MORMot is also compiled in separate package. Delphi compiler adds some code which prevents to calling more than once initialization or finalization units sections while packages are loaded or unloaded.

In fact, even RemoveTable/DeleteTable would not be sufficient, since the global "garbage collector" list is filled from RTTI information and JSON serialization.
Perhaps TJSONSerializer.RegisterClassForJSON(aTable) is the problem.
What does full debug mode say to you? What is the failing class type which is released twice?

The problem is that Access Violation exception is occured not for FreeAndNil call but in the line with condition:

if PObject(GarbageCollectorFreeAndNilList.List[i])^<>nil then

and this is not problem with GarbageCollectorFreeAndNilList variable. This variable has not nil value. For whole list which has 14 items problem occurs only for items: 9, 10, 11. Items before and after those items are freed correctly. Assembler code for this line looks like:

SynCommons.pas.43108: if PObject(GarbageCollectorFreeAndNilList.List[i])^<>nil then
008D9F8B A1B4F7AB00       mov eax,[$00abf7b4]
008D9F90 8B4004           mov eax,[eax+$04]
008D9F93 8B55FC           mov edx,[ebp-$04]
008D9F96 8B0490           mov eax,[eax+edx*4]
008D9F99 833800           cmp dword ptr [eax],$00
008D9F9C 7413             jz $008d9fb1

and AV is raised on line: cmp dword ptr [eax],$00

Of course exceptions are ignored and FastMM4 shows report:

This application has leaked memory. The small block leaks are (excluding expected leaks registered by pointer):

1 - 84 bytes: TSQLPropInfoRTTIInt64 x 1, TSQLPropInfoRTTIDateTime x 1, TSQLPropInfoRTTITID x 3, TSQLPropInfoRTTIInt32 x 9, TSQLPropInfoRTTIRawBlob x 2, TSQLPropInfoRTTIRawUTF8 x 4, TSQLPropInfoRTTIUnicode x 8, TSQLPropInfoRTTIEnum x 6, TSQLPropInfoList x 3, TSQLRecordFill x 33, UnicodeString x 5685, AnsiString x 45, Unknown x 4
85 - 292 bytes: AnsiString x 1, Unknown x 949
293 - 516 bytes: TSQLRecordProperties x 3, AnsiString x 2, Unknown x 33
Note: Memory leak detail is logged to a text file in the same folder as this application. To disable this memory leak check, undefine "EnableMemoryLeakReporting".

and detailed report for TSQLRecordProperties looks like:

--------------------------------2015/3/13 12:42:45--------------------------------
A memory block has been leaked. The size is: 516

This block was allocated by thread 0x1468, and the stack trace (return addresses) at the time was:
5005995A [System.pas][System][System.@GetMem][4189]
5005EA1B [System.pas][System][System.TObject.NewInstance][15174]
5005F23E [System.pas][System][System.@ClassCreate][16486]
A92268 [mORMot.pas][mORMot][TSQLRecordProperties.$bctr$qqrp17System.TMetaClass][36823]
739336 [GetRawStackTrace]
402B4E [FastMM4][FastMM4.CalculateHeaderCheckSum]
739336 [GetRawStackTrace]
739336 [GetRawStackTrace]
A6B294 [mORMot.pas][mORMot][TSQLModel.GetTableIndexExisting$qqrp17System.TMetaClass][25276]
403BA0 [FastMM4][FastMM4.DebugGetMem]
A67EB1 [mORMot.pas][mORMot][PropsCreate$qqrp17System.TMetaClass][24379]
5005EA24 [System.pas][System][System.TObject.NewInstance][15174]
A696FC [mORMot.pas][mORMot][TSQLModelRecordProperties.$bctr$qqrp16Mormot.TSQLModelp17System.TMetaClass28Mormot.TSQLRecordVirtualKind][24866]
A6A1C6 [mORMot.pas][mORMot][TSQLModel.SetTableProps$qqri][25018]
402B4E [FastMM4][FastMM4.CalculateHeaderCheckSum]
402B5D [FastMM4][FastMM4.UpdateHeaderAndFooterCheckSums]
403E54 [FastMM4][FastMM4.DebugReallocMem]
403E66 [FastMM4][FastMM4.DebugReallocMem]
50059997 [System.pas][System][System.@ReallocMem][4311]
50064245 [System.pas][System][System.DynArraySetLength][32317]
A6A8AC [mORMot.pas][mORMot][TSQLModel.AddTable$qqrp17System.TMetaClasspi][25099]
5BB27CB 
108942B [System.Generics.Collections.pas][GxRESTServerClasses][GxRESTServerClasses.{System.Generics.Collections}TList<GxRESTServerIntf.IGxModelRegister>.GetItem][680]
10873BA [GxRESTServerClasses.pas][GxRESTServerClasses][GxRESTServerClasses.TGxModelItems.ModelPrepare][229]
A0DBB0 [SynLog.pas][SynLog][TSynLog.Log$qqr22Syncommons.TSynLogInfox20System.UnicodeStringp14System.TObject][2860]
1088B06 [GxRESTServerClasses.pas][GxRESTServerClasses][GxRESTServerClasses.TGxRESTServerCreator.CreateServer][491]
50065B94 [System.pas][System][System.@IntfCopy][34063]
50065B83 [System.pas][System][System.@IntfClear][34016]
1090701 [GxRESTServerStdFactory.pas][GxRESTServerStdFactory][GxRESTServerStdFactory.TGxRESTServerFactory.Build][114]
1090A99 [GxRESTServerStdFactory.pas][GxRESTServerStdFactory][GxRESTServerStdFactory.TGxRESTServerFactory.BuildAndRun][125]
406A71 [uBkSerwerMain.pas][uBkSerwerMain][uBkSerwerMain.TfBkServerMain.actServiceStartExecute][64]
5016F382 [System.Classes.pas][System.Classes][System.Classes.TBasicAction.Execute][16354]
5043C27C [Vcl.ActnList.pas][Vcl.ActnList][Vcl.ActnList.TCustomAction.Execute][284]
5016F224 [System.Classes.pas][System.Classes][System.Classes.TBasicActionLink.Execute][16270]
5045303B [Vcl.Controls.pas][Vcl.Controls][Vcl.Controls.TControl.Click][7338]
50477C7F [Vcl.StdCtrls.pas][Vcl.StdCtrls][Vcl.StdCtrls.TCustomButton.Click][5313]
504787F9 [Vcl.StdCtrls.pas][Vcl.StdCtrls][Vcl.StdCtrls.TCustomButton.CNCommand][5774]
50452AFC [Vcl.Controls.pas][Vcl.Controls][Vcl.Controls.TControl.WndProc][7224]
72A5DF35 [Unknown function at HIMAGELIST_QueryInterface]
77057415 [Unknown function at RtlpNtSetValueKey]
76FB9AC4 [RtlDeactivateActivationContextUnsafeFast]
76FB9A10 [RtlActivateActivationContextUnsafeFast]
76FB9AC4 [RtlDeactivateActivationContextUnsafeFast]
74ED8E71 [CallNextHookEx]
74ED90D1 [Unknown function at CallNextHookEx]
74ED913E [Unknown function at CallNextHookEx]
74ED90E8 [Unknown function at CallNextHookEx]
74ED9115 [Unknown function at CallNextHookEx]
74ED8FCE [Unknown function at CallNextHookEx]
74ED913E [Unknown function at CallNextHookEx]
504575BA [Vcl.Controls.pas][Vcl.Controls][Vcl.Controls.TWinControl.WndProc][10039]
76AA20FE [Unknown function at GlobalFindAtomW]
50477929 [Vcl.StdCtrls.pas][Vcl.StdCtrls][Vcl.StdCtrls.TButtonControl.WndProc][5150]
50452737 [Vcl.Controls.pas][Vcl.Controls][Vcl.Controls.TControl.Perform][7002]
50457720 [Vcl.Controls.pas][Vcl.Controls][Vcl.Controls.DoControlMsg][10108]
504581B0 [Vcl.Controls.pas][Vcl.Controls][Vcl.Controls.TWinControl.WMCommand][10383]
5057A9E5 [Vcl.Forms.pas][Vcl.Forms][Vcl.Forms.TCustomForm.WMCommand][6154]
50452AFC [Vcl.Controls.pas][Vcl.Controls][Vcl.Controls.TControl.WndProc][7224]
50452AFC [Vcl.Controls.pas][Vcl.Controls][Vcl.Controls.TControl.WndProc][7224]
6680CA49 [Unknown function at GetThemeTransitionDuration]
74EE88CF [Unknown function at GetMonitorInfoW]
74EE88E7 [Unknown function at GetMonitorInfoW]
74EE8850 [GetMonitorInfoW]
74EE885E [GetMonitorInfoW]
6680CC36 [Unknown function at GetThemeTransitionDuration]
74EDAD27 [Unknown function at PostMessageW]
504575BA [Vcl.Controls.pas][Vcl.Controls][Vcl.Controls.TWinControl.WndProc][10039]
5005FA89 [System.pas][System][System.TMonitor.TryEnter][17109]
5005F61D [System.pas][System][System.TMonitor.Enter][16808]
5005F4C9 [System.pas][System][System.TMonitor.CheckOwningThread][16730]
5005F79F [System.pas][System][System.TMonitor.Exit][16911]
505777FE [Vcl.Forms.pas][Vcl.Forms][Vcl.Forms.TCustomForm.WndProc][4388]
50456BFB [Vcl.Controls.pas][Vcl.Controls][Vcl.Controls.TWinControl.MainWndProc][9751]
50456C12 [Vcl.Controls.pas][Vcl.Controls][Vcl.Controls.TWinControl.MainWndProc][9754]
50456BFB [Vcl.Controls.pas][Vcl.Controls][Vcl.Controls.TWinControl.MainWndProc][9751]
50170092 [System.Classes.pas][System.Classes][System.Classes.StdWndProc][16860]
74ED8E71 [CallNextHookEx]
74ED90D1 [Unknown function at CallNextHookEx]
74ED8FCE [Unknown function at CallNextHookEx]
74ED932C [Unknown function at CallNextHookEx]
74F07924 [Unknown function at EndTask]
74ED9529 [Unknown function at CallNextHookEx]
76FAC6CC [ZwCallbackReturn]
74EDE4A9 [SendMessageW]
72A8139B [Unknown function at AddMRUStringW]
72A814E2 [Unknown function at AddMRUStringW]
72A81432 [Unknown function at AddMRUStringW]
74ED8E71 [CallNextHookEx]
74ED90D1 [Unknown function at CallNextHookEx]
74ED913E [Unknown function at CallNextHookEx]
74ED90E8 [Unknown function at CallNextHookEx]
5016EDE0 [System.Classes.pas][System.Classes][System.Classes.TComponent.UpdateAction][16030]
5057C6A2 [Vcl.Forms.pas][Vcl.Forms][Vcl.Forms.ProcessUpdate][7244]
5005EE17 [System.pas][System][System.@IsClass][15664]
5057C718 [Vcl.Forms.pas][Vcl.Forms][Vcl.Forms.TraverseClients3][7261]
76FB9A10 [RtlActivateActivationContextUnsafeFast]
5057C77F [Vcl.Forms.pas][Vcl.Forms][Vcl.Forms.TCustomForm.CMActionUpdate][7283]
74ED8E71 [CallNextHookEx]
74ED90D1 [Unknown function at CallNextHookEx]
74ED8FCE [Unknown function at CallNextHookEx]
74EDDDD5 [CallWindowProcW]
504576CB [Vcl.Controls.pas][Vcl.Controls][Vcl.Controls.TWinControl.DefaultHandler][10080]
504534A7 [Vcl.Controls.pas][Vcl.Controls][Vcl.Controls.TControl.WMLButtonUp][7473]
504575BA [Vcl.Controls.pas][Vcl.Controls][Vcl.Controls.TWinControl.WndProc][10039]
50452AFC [Vcl.Controls.pas][Vcl.Controls][Vcl.Controls.TControl.WndProc][7224]
505777FE [Vcl.Forms.pas][Vcl.Forms][Vcl.Forms.TCustomForm.WndProc][4388]
74ED913E [Unknown function at CallNextHookEx]
74ED90E8 [Unknown function at CallNextHookEx]
50452737 [Vcl.Controls.pas][Vcl.Controls][Vcl.Controls.TControl.Perform][7002]
50582B0A [Vcl.Forms.pas][Vcl.Forms][Vcl.Forms.TApplication.DispatchAction][11494]
505801E8 [Vcl.Forms.pas][Vcl.Forms][Vcl.Forms.TApplication.WndProc][9857]
5005F79F [System.pas][System][System.TMonitor.Exit][16911]
5005F7F0 [System.pas][System][System.TMonitor.Exit][16933]
50434B58 [Vcl.Graphics.pas][Vcl.Graphics][Vcl.Graphics.FreeMemoryContexts][7047]
50456BFB [Vcl.Controls.pas][Vcl.Controls][Vcl.Controls.TWinControl.MainWndProc][9751]
76FB9AC4 [RtlDeactivateActivationContextUnsafeFast]
76FB9AC4 [RtlDeactivateActivationContextUnsafeFast]
74EDAC68 [SetTimer]
74EE1415 [GetCapture]
50456DF0 [Vcl.Controls.pas][Vcl.Controls][Vcl.Controls.TWinControl.IsControlMouseMsg][9807]
74ED8E71 [CallNextHookEx]
504575BA [Vcl.Controls.pas][Vcl.Controls][Vcl.Controls.TWinControl.WndProc][10039]
74ED913E [Unknown function at CallNextHookEx]
74A9FBF6 [Unknown function at CtfImeDestroyInputContext]
50477929 [Vcl.StdCtrls.pas][Vcl.StdCtrls][Vcl.StdCtrls.TButtonControl.WndProc][5150]
50456BFB [Vcl.Controls.pas][Vcl.Controls][Vcl.Controls.TWinControl.MainWndProc][9751]
50170092 [System.Classes.pas][System.Classes][System.Classes.StdWndProc][16860]
74ED8E71 [CallNextHookEx]
74ED90D1 [Unknown function at CallNextHookEx]
74ED8FCE [Unknown function at CallNextHookEx]
76FB09D6 [KiUserCallbackDispatcher]
74EDA66F [Unknown function at GetMessageW]
74EDA6E0 [DispatchMessageW]
50580ECF [Vcl.Forms.pas][Vcl.Forms][Vcl.Forms.TApplication.HandleMessage][10318]
5058120A [Vcl.Forms.pas][Vcl.Forms][Vcl.Forms.TApplication.Run][10456]
408512 [BkSerwerApp][BkSerwerApp.BkSerwerApp][14]
76AA7C04 [BaseThreadInitThunk]
76FCB5AF [Unknown function at RtlInitializeExceptionChain]
76FCB57A [Unknown function at RtlInitializeExceptionChain]

The block is currently used for an object of class: TSQLRecordProperties

The allocation number is: 2437

What if we just get rid of GarbageCollectorFree in the SynCommons finalization unit when a package is unloaded?
This would definitively leak a little bit of memory, not only a few bytes, I guess...
It may be a temporary workaround, certainly better than the Access Violations themselves...

Maybe it is a solution, but it will makes memory leaks tests a little harder. Memory leaks in this case is not a problem - this code is called only once - on application turn off but it will be reported everytime and this is not good. Maybe better solution is add possibility to call GarbageCollectorFree manually? I can call it just before package unloading. Packages unloading it is the one of the last things which I do before application turn off and it will be no difference - from finalization section or manually. I made small test - if I call GarbageCollectorFree procedure before package unloading then everything works correctly - no memory leaks, no exceptions are raised. There should be only no call to the mORMot code after calling GarbageCollectorFree. For example calling log procedures are also prohibited. The only change I made in SynCommons code is additional condition to prevent call GarbageCollectorFree twice  (manually and from finalization section) and header for procedure in interface section. After changes procedure looks like:

procedure GarbageCollectorFree;
var i: integer;
begin
  if GarbageCollectorFreeing then Exit;

  GarbageCollectorFreeing := true;
  for i := GarbageCollector.Count-1 downto 0 do // last in, first out
  try
    GarbageCollector.Delete(i); // will call GarbageCollector[i].Free
  except
    on E: Exception do
      ; // just ignore exceptions in client code destructors
  end;
  for i := GarbageCollectorFreeAndNilList.Count-1 downto 0 do // LIFO
  try
    if PObject(GarbageCollectorFreeAndNilList.List[i])^<>nil then
      FreeAndNil(PObject(GarbageCollectorFreeAndNilList.List[i])^);
  except
    on E: Exception do
      ; // just ignore exceptions in client code destructors
  end;
  FreeAndNil(GarbageCollectorFreeAndNilList);
end;

#65 Re: mORMot 1 » Memory managment in mORMot question » 2015-03-13 09:52:56

Hello,

I'm using FastMM4 for testing my applications too. And now if I'm trying to test my application which is using mORMot then depending on configuration I have memory leaks or exceptions in GarbageCollectorFree procedure. I think that it is not framework related question, because all samples are working correctly with no FastMM4 reports but I'm writing because I don't see anything wrong in my code. I don't see anything wrong but it doesn't mean that code is correct.

Is it possible that this is applications architecture related problem? In my case exception in GarbageCollectorFree occurs only for items with TSQLRecordProperties class instances object. Exactly three times (my simple model has only 3 classes) The main different from samples is that model classes are defined in dynamically loaded package (using SysUtils.LoadPackage method) So GarbageCollectorFree is called from System.FinalizeUnits procedure when packages were unloaded. I think it could works correctly when the classes would be removed manually from model when package is unloaded. Is it possible to manually remove a class from model? Unfortunatelly I can't find RemoveTable or DeleteTable in TSQLModel methods list.

#66 mORMot 1 » Memory managment in mORMot question » 2015-03-12 13:01:15

ASiwon
Replies: 8

Hello,

I found in mORMots code this piece of code:

  for i := GarbageCollectorFreeAndNilList.Count-1 downto 0 do // LIFO
  try
    if PObject(GarbageCollectorFreeAndNilList.List[i])^<>nil then
      FreeAndNil(PObject(GarbageCollectorFreeAndNilList.List[i])^);
  except
    on E: Exception do
      ; // just ignore exceptions in client code destructors
  end;

It is in SynCommons.GarbageCollectorFree. Can you explain what kind of errors  could exist in client code destructors? In my application in this piece Access Violation exception is raised for every model element. But in fact I have no idea where is the problem in my code.

#67 Re: mORMot 1 » Problem with reading data from Oracle database. » 2015-02-15 20:05:20

I have one question yet. Is it possible to check in code that while query execution some exception occured? When it was a bug in mORMot then after creation of instance of the class TSQLRecord then only empty record was created - exactly like in situation when record was not found. Sometime I don't know record exist or not in the database. But if an error occur I want to just know about it - not only from log files.

#68 Re: mORMot 1 » Extension of TSynLog and ISynLog question/proposal. » 2015-02-15 19:50:14

No problem. Thank you very much for great support. Now everything is working correctly.

#69 Re: mORMot 1 » Extension of TSynLog and ISynLog question/proposal. » 2015-02-15 10:15:36

I have no idea why error not exists on your side. The problem occurs only while compiling unit mORMotSQLite3.pas. Here is part of this unit. As you can see parameters for DebuggerNotify procedure are set in wrong order.

function SQLVarToSQlite3Context(const Res: TSQLVar; Context: TSQLite3FunctionContext): boolean;
var tmp: array[0..31] of AnsiChar;
begin
  case Res.VType of
    ftNull:
      sqlite3.result_null(Context);
    ftInt64:
      sqlite3.result_int64(Context,Res.VInt64);
    ftDouble:
      sqlite3.result_double(Context,Res.VDouble);
    ftCurrency:
      sqlite3.result_double(Context,Res.VCurrency);
    ftDate: begin
      DateTimeToIso8601ExpandedPChar(Res.VDateTime,tmp);
      sqlite3.result_text(Context,tmp,-1,SQLITE_TRANSIENT_VIRTUALTABLE);
    end;
    // WARNING! use pointer(integer(-1)) instead of SQLITE_TRANSIENT=pointer(-1)
    // due to a bug in Sqlite3 current implementation of virtual tables in Win64
    ftUTF8:
      if Res.VText=nil then
       sqlite3.result_text(Context,@NULCHAR,0,SQLITE_STATIC) else
       sqlite3.result_text(Context,Res.VText,-1,SQLITE_TRANSIENT_VIRTUALTABLE);
    ftBlob:
      sqlite3.result_blob(Context,Res.VBlob,Res.VBlobLen,SQLITE_TRANSIENT_VIRTUALTABLE);
    else begin
      {$ifdef WITHLOG}
      SynSQLite3Log.DebuggerNotify(sllWarning,[ord(Res.VType)],'SQLVarToSQlite3Context(%)');
      {$endif}
      result := false; // not handled type
      exit;
    end;
  end;
  result := true;
end;

This code was just updated from github repository.

#70 Re: mORMot 1 » Extension of TSynLog and ISynLog question/proposal. » 2015-02-14 21:31:47

Hello,

I have tried to compile mORMot after changes. Now it is impossible to compile mORMot units when define WITHLOG is declared. It is because for procedure DebuggerNotify order of parameters was changed.

#71 Re: mORMot 1 » Extension of TSynLog and ISynLog question/proposal. » 2015-02-13 22:50:09

Hello,

the problem is not completely resolved yet. I still have two separated messages for which messages are written incorrectly. But I can't explain why or reproduce this problem in small example. The files are formatted as UTF8 and I'm using DelphiXE4. For this code:

    log.Log(sllDebug, 'Dane ważenia: %', [RecordSaveJSON(AWazenieDane, TypeInfo(TBkWazenieDane))]));

result in the log file looks like:

20150213 23210351 debug         Dane waࠥnia: {"WagaId":281,"WagonGranicaObciazenia":56000,"WagonNumer":"315153289715","WagonNumerRodzaj":"wnrWagonUIC","WagonPobytId":0,"WagonTaraZBelki":24000,"WagowyDane":"Jaś Wagowy","WagowyNazwisko":"","WagowyImie":"","WazenieCzas":"2015-02-13T23:21:03","WazenieId":256,"WazenieLadunekNazwa":"","WazenieLadunekNumer":"","WazenieMasaBrutto":24200,"WazenieMasaNetto":0,"WazenieRodzaj":2,"WazenieRodzajPotwierdz":false,"WazeniePosrednie":false,"WazenieSklad":"10","WazenieTechnologiczne":false}

But for this code:

    log.Log(sllDebug, '% %', ['Dane ważenia:', RecordSaveJSON(AWazenieDane, TypeInfo(TBkWazenieDane))]);

result in the log file is correct and looks like:

20150213 23395624 debug         Dane ważenia: {"WagaId":281,"WagonGranicaObciazenia":56000,"WagonNumer":"315153289715","WagonNumerRodzaj":"wnrWagonUIC","WagonPobytId":0,"WagonTaraZBelki":24000,"WagowyDane":"Jaś Wagowy","WagowyNazwisko":"","WagowyImie":"","WazenieCzas":"2015-02-13T23:39:56","WazenieId":256,"WazenieLadunekNazwa":"","WazenieLadunekNumer":"","WazenieMasaBrutto":24200,"WazenieMasaNetto":0,"WazenieRodzaj":2,"WazenieRodzajPotwierdz":false,"WazeniePosrednie":false,"WazenieSklad":"10","WazenieTechnologiczne":false}

Because this problem has incidental nature this workaround is completely enough for me.

#72 mORMot 1 » Documentation - example for section 5.2 - small correction needed » 2015-02-13 21:39:55

ASiwon
Replies: 1

Hello,

code from example in section 5.2 can't be succesfully compiled with current version of mORMot. Now function Add requires additional value for parameter: SendData.

#73 Re: mORMot 1 » Extension of TSynLog and ISynLog question/proposal. » 2015-02-13 21:23:13

Hello,

it is not a problem of mORMot but my mistake. I wrote log message when a pas file was formatted as Ansi. After that I have changed file format to the UTF8 format but national chars was still encoded in Ansi format. If format of file set to UTF8 before writing message for logging then everything works correctly.

#74 Re: mORMot 1 » Extension of TSynLog and ISynLog question/proposal. » 2015-02-13 13:29:39

thank you very much for change - it works as expected. I have yet one logging related problem. If in the log message are used polish national chars then those chars are completely damaged in log file. For example if I'm trying to log message like this:

  log.Log(sllInfo, '% ąćęłńóśźż ĄĆĘŁŃÓŚŹŻ', ['Test:']);

Of course it is only a stupid example to show the problem. In the log file this message will be visible as:

20150213 14141308 info          Test: ڦ괱? Ɔʣғ̏

Is it possible to correct this problem or just national chars shouldn't be used in logging messages?

#75 mORMot 1 » Problem with reading data from Oracle database. » 2015-02-13 12:40:21

ASiwon
Replies: 4

Hello,

I have problem with reading data from Oracle database. I have following structure:

  TBkWazenieImport = class(TSQLRecord)
  private
    FWagaId: Integer;
    FWagonGranicaObciazenia: Integer;
    FWagonNumer: String;
    FWagonNumerBlad: Boolean;
    FWagonNumerFiltr: String;
    FWagonNumerRodzaj: TBkWagonNumerRodzaj;
    FWagonPobytId: Integer;
    FWagonTaraZBelki: Integer;
    FWagowyDane: String;
    FWazenieCzas: TDateTime;
    FWazenieIdZewnetrzne: Int64;
    FWazenieLadunekNazwa: String;
    FWazenieLadunekNumer: String;
    FWazenieMasaBrutto: Integer;
    FWazenieMasaNetto: Integer;
    FWazeniePosrednie: Boolean;
    FWazenieRodzaj: Byte;
    FWazenieRodzajPotwierdz: Boolean;
    FWazenieSklad: String;
    FWazenieStatus: Integer;
    FWazenieTechnologiczne: Boolean;
    procedure SetWagonNumer(const AValue: String);
  public
    procedure ComputeFieldsBeforeWrite(aRest: TSQLRest; aOccasion: TSQLEvent); override;
  published
    property WagaId: Integer read FWagaId write FWagaId;
    property WagonGranicaObciazenia: Integer read FWagonGranicaObciazenia write FWagonGranicaObciazenia;
    property WagonNumer: String read FWagonNumer write SetWagonNumer;
    property WagonNumerBlad: Boolean read FWagonNumerBlad write FWagonNumerBlad;
    property WagonNumerFiltr: String index 15 read FWagonNumerFiltr;
    property WagonNumerRodzaj: TBkWagonNumerRodzaj read FWagonNumerRodzaj write FWagonNumerRodzaj;
    property WagonPobytId: Integer read FWagonPobytId write FWagonPobytId;
    property WagonTaraZBelki: Integer read FWagonTaraZBelki write FWagonTaraZBelki;
    property WagowyDane: String read FWagowyDane write FWagowyDane;
    property WazenieCzas: TDateTime read FWazenieCzas write FWazenieCzas;
    property WazenieIdZewnetrzne: Int64 read FWazenieIdZewnetrzne write FWazenieIdZewnetrzne;
    property WazenieLadunekNazwa: String index 40 read FWazenieLadunekNazwa write FWazenieLadunekNazwa;
    property WazenieLadunekNumer: String index 6 read FWazenieLadunekNumer write FWazenieLadunekNumer;
    property WazenieMasaBrutto: Integer read FWazenieMasaBrutto write FWazenieMasaBrutto;
    property WazenieMasaNetto: Integer read FWazenieMasaNetto write FWazenieMasaNetto;
    property WazeniePosrednie: Boolean read FWazeniePosrednie write FWazeniePosrednie;
    property WazenieRodzaj: Byte read FWazenieRodzaj write FWazenieRodzaj;
    property WazenieRodzajPotwierdz: Boolean read FWazenieRodzajPotwierdz write FWazenieRodzajPotwierdz;
    property WazenieSklad: String index 5 read FWazenieSklad write FWazenieSklad;
    property WazenieStatus: Integer read FWazenieStatus write FWazenieStatus;
    property WazenieTechnologiczne: Boolean read FWazenieTechnologiczne write FWazenieTechnologiczne;
  end;

this structure is registered to the model in the following way:

  AModel.AddTable(TBkWazenieImport);
  VirtualTableExternalMap(AModel, TBkWazenieImport, AConnectionProp, cTbWagWazeniaImporty).
    MapField('ID', cFdWWIId).
    MapField('WagaId', cFdWWIWagaId).
    MapField('WagonGranicaObciazenia', cFdWWIGranicaObciazenia).
    MapField('WagonNumer', cFdWWINrWagonu).
    MapField('WagonNumerBlad', cFdWWINrWagonuBlad).
    MapField('WagonNumerFiltr', cFdWWINrWagonuFiltr).
    MapField('WagonNumerRodzaj', cFdWWINrWagonuRodz).
    MapField('WagonPobytId', cFdWWIWagonId).
    MapField('WagonTaraZBelki', cFdWWITaraZBelki).
    MapField('WagowyDane', cFdWWIWagowy).
    MapField('WazenieCzas', cFdWWICzasWazenia).
    MapField('WazenieIdZewnetrzne', cFdWWIWazenieZewnId).
    MapField('WazenieLadunekNazwa', cFdWWITowarNazwa).
    MapField('WazenieLadunekNumer', cFdWWITowarNumer).
    MapField('WazenieMasaBrutto', cFdWWIMasaBrutto).
    MapField('WazenieMasaNetto', cFdWWIMasaNetto).
    MapField('WazeniePosrednie', cFdWWIPosrednie).
    MapField('WazenieRodzaj', cFdWWIRodzajWaz).
    MapField('WazenieRodzajPotwierdz', cFdWWIPotwierdz).
    MapField('WazenieSklad', cFdWWISklad).
    MapField('WazenieStatus', cFdWWIStatus).
    MapField('WazenieTechnologiczne', cFdWWITechnolog);

cFd* values are constants with correct field names in the database. Now if I'm trying to read record in the such way:

Result := TBkWazenieImport.Create(ServerStruct.DbClient, 13934)

then everything works fine. But if I'm trying to read record in the such way:

    Result := TBkWazenieImport.Create(ServerStruct.DbClient, 'WagaId = ? AND WazenieIdZewnetrzne = ?',
      [WazenieDane.WagaId, WazenieDane.WazenieId])

then no record is retrieved. Additionaly in the log file the following problem is reported:

20150213 13123735  +            TSQLRestServerDB(04DC5650).0066741F
20150213 13124440  +                TSQLDBOracleConnection(02EE3130).007650FD
20150213 13124440  -                00.000.002
20150213 13124440  +                TSQLDBOracleConnection(02EE3130).00764940
20150213 13124446 SQL                   TSQLDBOracleStatement(04D67340) SELECT NLS_CHARSET_ID(PROPERTY_VALUE) FROM DATABASE_PROPERTIES WHERE PROPERTY_NAME='NLS_CHARACTERSET'
20150213 13124446 DB                    TSQLDBOracleStatement(04D67340) 1 row(s) in 2.31ms
20150213 13124446 info                  TSQLDBOracleConnection(02EE3130) Connected to localhost as system with oci.dll rev. 10.2.0.1, codepage 65001 (873/AL32UTF8)
20150213 13124446 SQL                   TSQLDBOracleStatement(04D67340) ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD-HH24:MI:SS'
20150213 13124446 DB                    TSQLDBOracleStatement(04D67340) 0 row(s) in 424us
20150213 13124446 SQL                   TSQLDBOracleStatement(04D67340) alter session set NLS_NUMERIC_CHARACTERS = ". "
20150213 13124446 DB                    TSQLDBOracleStatement(04D67340) 0 row(s) in 457us
20150213 13124446  -                00.095.292
20150213 13124446 EXC               ESQLDBOracle ("TSQLDBOracleStatement error: ORA-00923: FROM keyword not found where expected") at 00763B9C  stack trace API 006046C0 006046E8
20150213 13124446 ERROR             "ESQLDBOracle(02F98400)":"TSQLDBOracleStatement error: ORA-00923: FROM keyword not found where expected" stack trace API 00606104 0076A20F 0076548E 006B2DE3 006B291C 00770B15 0076FAFD 00663AB1 00662CAB 00667587 00699175 0065E439 0065C5A3 0065859F 0064D041 0076054F 007600DA 00760E0F 00686AF3
20150213 13124446 EXC               ESQLDBOracle ("TSQLDBOracleStatement error: ORA-00923: FROM keyword not found where expected") at 00763B9C  stack trace API 006046C0 006046E8
20150213 13124446 SQL               TSQLDBOracleConnection(02EE3130) select WWI_ID as RowID,WWI_ZDW_ID as WagaId,WWI_GRANICA_OBC as WagonGranicaObciazenia,WWI_NR_WAGONU as WagonNumer,WWI_NR_WAGONU_BLAD as WagonNumerBlad,WWI_NR_WAGONU_FILTR as WagonNumerFiltr,WWI_NR_WAGONU_RODZ as WagonNumerRodzaj,WWI_WE_ID as WagonPobytId,WWI_TARA_Z_BEL as WagonTaraZBelki,WWI_WAGOWY as WagowyDane,WWI_CZAS_WAZENIA as WazenieCzas,WWI_WAZENIE_ID as WazenieIdZewnetrzne,WWI_TOWAR_NAZWA as WazenieLadunekNazwa,WWI_TOWAR_NUMER as WazenieLadunekNumer,WWI_MASA_BRUTTO as WazenieMasaBrutto,WWI_MASA_NETTO as WazenieMasaNetto,WWI_POSREDNIE as WazeniePosrednie,WWI_RODZAJ_WAZ as WazenieRodzaj,WWI_POTWIERDZ as WazenieRodzajPotwierdz,WWI_SKLAD as WazenieSklad,WWI_STATUS as WazenieStatus,WWI_TECHNOLOGICZNY as WazenieTechnologiczne from U_EKS.T_WAGONY_WAZENIA_IMPORTY where rownum<=1 and WWI_ZDW_ID=?OOR? and WWI_WAZENIE_ID=?OOR?
20150213 13124446 DB                TSQLDBOracleStatement(04D67240) 0 row(s) in 99.98ms
20150213 13124446 EXC               ESQLDBOracle ("TSQLDBOracleStatement error: ORA-00923: FROM keyword not found where expected") at 00763B9C  stack trace API 006046C0 006046E8
20150213 13124446 srvr              GET root ERROR=400 (Bad Request)
20150213 13124446  -            07.181.810
20150213 13124446 ERROR         TSQLRestClientDB(02F75A60) GET root returned 400 Bad Request with message  {  "ErrorCode":400,  "ErrorText":"Bad Request"  } stack trace API 00605E0E 0065E5AB 0065C5A3 0065859F 0064D041 0076054F 007600DA 00760E0F 00686AF3

Executed SQL query has correct table and field values, but for first field the word RowId is used. But it is impossible to use the word RowId in the Oracle queries. This word is added to the query in function TSQLRestStorageExternal.AdaptSQLForEngineList - for condition Field=0 is always value 'RowId' used.

And finally is it a bug or I'm doing something wrong?

best regards
Adam Siwon

#76 mORMot 1 » Extension of TSynLog and ISynLog question/proposal. » 2015-02-07 13:40:24

ASiwon
Replies: 13

Is it possible to add to the interface ISynLog and TSynLog class method:

    procedure Log(Level: TSynLogInfo; const Text: String; Instance: TObject=nil; TextTruncateAtLength: integer=maxInt); overload;

which will convert value from Text parameter to RawUTF8 format and will call regular Log method? Now if I want to logging value from variable of type string then I must to use function StringToUTF8 in every call. A just want to avoid warning:

W1057 Implicit string cast from 'string' to 'RawUTF8'

Usually I'm writing class helper to do conversion in cases like this but it is impossible to use class helper with interfaces.

#77 Re: mORMot 1 » Access Violation while record serializing » 2015-02-06 18:41:29

Please do not be angry with me. mORMot documentation is really huge and sometime I have problem to find required information.

I have another documentation related question. In section 5.3.1. Return a list of objects exists example:

var aList: TObjectList<TSQLBaby>;
 aMale: TSQLBaby;
...
aList := Client.RetrieveObjectList<TSQLBaby>('Name LIKE ? AND Sex = ?' ,['A%' ,ord(sMale)]);
try
 for aMale in aList do
 DoSomethingWith(aMale);
finally
 aList.Free;
end;

But in mORMot code function RetrieveObjectList doesn't exists. I think this line in example should looks like:

aList := Client.RetrieveList<TSQLBaby>('Name LIKE ? AND Sex = ?' ,['A%' ,ord(sMale)]);

best regards
Adam Siwon

#78 Re: mORMot 1 » Access Violation while record serializing » 2015-02-05 22:18:59

Hello,

thank you very much. Now it works as expected. It would be nice to add this information to the documentation. In sections 10.1.3. Record serialization and 10.1.3.1. Automatic serialization via Enhanced RTTI there is no direct information about this requirement.

best regards
Adam Siwon

#79 mORMot 1 » Access Violation while record serializing » 2015-02-05 20:06:19

ASiwon
Replies: 5

Hello,

I have problem when I'm trying to call service function via interfaces. When function has record param, then Access Violation is raised while executing. After small investigation I found where exists the problem. The problem occurs while serializing record parameter. I wrote small demo example:

  
type 
  TTestRecord = record
    Int: Integer;
    Bool: Boolean;
    Text: String;
  end;

procedure Test;
var
  tw: TTextWriter;
  rec: TTestRecord;
  stream: TStream;
begin
  stream := TMemoryStream.Create;
  try
    tw := TTextWriter.Create(stream);
    tw.AddRecordJSON(rec, TypeInfo(TTestRecord));
  finally
    stream.Free;
  end;
end;

The Access Violation exception is raised in line: tw.AddRecordJSON(rec, TypeInfo(TTestRecord));

But if definition of the record is changed to:

  TTestRecord = record
    Int: Integer;
    Text: String;
    Bool: Boolean;
  end;

then everything works correctly. I'm using Delphi XE4Pro, and current version of mORMot.

best regards
Adam Siwon

#80 Re: mORMot 1 » Nil references problem » 2015-02-05 10:01:26

Hello,

with trigger in the database everything works correctly.

best regards
Adam Siwon

#81 Re: mORMot 1 » Nil references problem » 2015-02-04 12:15:43

Hello,

Perhaps there is an option about the constraints definition in Oracle?

Unfortunately in Oracle there is no option for the constraint definition to solve this problem. In constraint definition it is impossible to use expression like: nullif(column, 0). Only column names must be used.

Or a small PL/SQL which may take place before the integrity check, replacing the 0 with a null?

As I wrote earlier I can just to create the trigger for the table which will replace 0 values with a null for some fields. But it must be created manually for particular tables. Neverthless I do this if it will be necessary and changes in mORMot code are too complicated to do.

best regards
Adam Siwon

#82 mORMot 1 » Nil references problem » 2015-02-03 22:06:42

ASiwon
Replies: 4

Hello,

I'm newbie in mORMot. Now I'm trying to write my first mORMot powered project. I'm very impressed - this library is amazing. Thank you very much for writing this project.

I have problem with storing object to the external Oracle database. When object has only simple types there is no problem to write it to the database. But in some cases I have object with references to other objects. Here is sample code:

TUser = class(TSQLRecord)
private
  FName: RawUTF8;
published
  property Name: RawUTF8 read FName write FName;
  // and other properties
end;

TOperation = class(TSQLRecord)
  private
    FUser: TUser;
    ...
  published
    property User: TUser read FUser write FUser;
    // and other properties

When I'm trying to store instance of class TOperation to the database I'm getting an error. Here is log:

20150203 21515014 SQL   	TSQLDBOracleStatement(035B4730) update U_EKS.T_WAGONY_WAZENIA_IMPORTY set WWI_ZDW_ID=161,WWI_GRANICA_OBC=56000,WWI_NR_WAGONU='84-51-7582810-0',WWI_NR_WAGONU_BLAD=0,WWI_NR_WAGONU_FILTR='001828571548',WWI_NR_WAGONU_RODZ=0,WWI_WE_ID=0,WWI_TARA_Z_BEL=22700,WWI_UZ_ID=0,WWI_WAGOWY='',WWI_CZAS_WAZENIA='2014-01-30 23:04:54',WWI_WAZENIE_ID=407688,WWI_TOWAR_NAZWA='',WWI_TOWAR_NUMER='',WWI_MASA_BRUTTO=22750,WWI_MASA_NETTO=0,WWI_POSREDNIE=0,WWI_RODZAJ_WAZ=2,WWI_POTWIERDZ=0,WWI_SKLAD='2',WWI_STATUS=-8,WWI_TECHNOLOGICZNY=0 where WWI_ID=13795
20150203 21515014 EXC   	ESQLDBOracle ("TSQLDBOracleStatement error: ORA-02291: integrity constraint (U_EKS.FK_WWI_BTK_UZYTKOWNICY) violated - parent key not found") at 006E34E8  stack trace API 00602E68 00602E90 

Property User is mapped to the wwi_uz_id field. MORMot is trying to write value 0 to this field. I have read NULL handling section in documentation and I know this is correct operation. But in my database are integrity constraint created. Its because there are many modules which are not using mORMot and for now they need this constraints to work correctly.

So the question is: Is it possible in mORMot to store to the databases fields NULL instead of zero value for references which have value nil? I found an option StoreVoidStringAsNull but I can't find nothing for nil references. If this is impossible I will write database trigger which will updating zero value to the NULL but I think this is very incorrect way.

best regards
Adam Siwon

Board footer

Powered by FluxBB