Página 1 de 1

Hbpgsql data null com fieldput

Enviado: 30 Mar 2021 09:38
por marco.prodata
Caros,

Como gravar data em branco usando a hbpgsql usando o oRow:fieldput?

Hbpgsql data null com fieldput

Enviado: 31 Mar 2021 15:26
por marco.prodata
Mandei um PR com a solução do problema, vamos ver se aceitam.

Hbpgsql data null com fieldput

Enviado: 31 Mar 2021 16:29
por alxsts
Olá!

E qual é a solução para o problema? Poderia compartilhar, caso a tenha encontrado?

Hbpgsql data null com fieldput

Enviado: 31 Mar 2021 17:30
por Itamar M. Lins Jr.
Olá!
No harbour 3.4 do Viktor tem algumas intervenções dele sobre esse problema.
Não lembro, mas li no Changelog alguma coisa.

Código: Selecionar todos

2017-05-23 22:35 UTC Viktor Szakats (vszakats users.noreply.github.com)
  * contrib/hbpgsql/tpostgre.prg
    + add :SetNull( <lSet> ) to TPQServer class
      and a param to :Query( <cQuery>, [ <lNull> ] )
      TPQQuery class constructor is also extended.

      With :SetNull( .T. ) retains NULL information as NIL. Standard
      behaviour of hbpgsql library, until now, was to substitute NULL
      with blank xBase value - thus :SetNull( .F. ) is the default
      setting.

    ; Merge from Aleksander Czajczyński's fork (with minor cleanups):
      https://github.com/alcz/harbour/commit/d5e681f79efd38f937935e07769361a50234db18
Não sei se tem no HB32. tem que ficar lendo lá e cá...

Saudações,
Itamar M. Lins Jr.

Hbpgsql data null com fieldput

Enviado: 31 Mar 2021 17:34
por Itamar M. Lins Jr.
Olá!
Abri o link e achei isso.

Código: Selecionar todos

2015-05-07 22:24 UTC+0200 Aleksander Czajczynski (hb fki.pl)

  * src/rdd/dbcmd.c
    + added HB_FieldPut( <n>, <xVal> ) which is like FieldPut(), but
      accepts NIL value as 2-nd parameter. FieldPut() ignores NIL and
      shouldn't be changed, because of Clipper compatibility
      and possible regressions.

  * contrib/hbpgsql/tpostgre.prg
    + added :SetNull( <lSet> ) to TPQServer class
      and a param to :Query( <cQuery>, [ <lNull> ] )
      TPQQuery class constructor is also extended.

      With :SetNull( .T. ) retains NULL information as NIL. Standard
      behaviour of hbpgsql library, until now, was to substute NULL
      as blank xBase value - thus :SetNull( .F. ) is the default setting.
Saudações,
Itamar M. Lins Jr.

Hbpgsql data null com fieldput

Enviado: 01 Abr 2021 15:42
por marco.prodata
alxsts escreveu:Olá!

E qual é a solução para o problema? Poderia compartilhar, caso a tenha encontrado?
Agora basta usar: oRow:FieldPut( <numerodocampo>, ctod('')) que vai funcionar, na verdade qualquer campo que vc passar oRow:FieldPut(<numerodocampo>, nil) vai gravar null no bd.

https://github.com/harbour/core/pull/235
Esse é o PR que tinha mandando, o Aleksander mesclou com outras mudanças q tinha no repositório do Viktor e publicou.

Vou fazer outro acrescentando a possibilidade de trabalhar com campos timestamp do banco de dados, baseado num exemplo que um usuário da lista do harbour me mandou, e ver se os caras implementam também