SetCheck() on MariaDB => SOLVED

SetCheck() on MariaDB => SOLVED

Postby fraxzi » Mon Sep 03, 2018 1:20 am

Hi Folks,

I am having trouble displaying xBrowse :SetCheck() on MariaDB RS as shown:

RS:
Code: Select all  Expand view

...
SELECT False AS lcheck, rdt_reqnum, rdt_reqdat, rdt_mrnumb, rdt_mrdesc
FROM rdt_forms
...

oRS::lTinyIntAsLogical := .T.

...
oBrw:aCols[ 1 ]:SetCheck({'checkon16', 'checkoff16'}, .T.)
...

 



I tried other combinations but the result is blank:

Image

:?:
Last edited by fraxzi on Wed Sep 05, 2018 3:23 am, edited 1 time in total.
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: SetCheck() on MariaDB

Postby nageswaragunupudi » Tue Sep 04, 2018 3:50 am

Use only the
Code: Select all  Expand view

function MYSQL_TinyIntAsLogical( .t. / .f. ) --> lPrevStatus
 

to set or reset the status.

Rowset remembers the status applicable for that table in its DATA lTinyIntAsLogical. We should not change it.

Global default is .F. and we recommend keeping it as .F.

Behavior when MYSQL_TinyIntAsLogical() is set to .F. :
(Default and Recommended)


1) When a table is created, logical fields are created as fields of BIT type.
2) When a table is read (i.e., when a rowset is read) BIT type fields are read as Boolean and TinyInteger fields are read as integers. Rowset object remembers the setting when it reads the table from the server and uses the same setting throughout the life of that recordset.

Behavior when MYSQL_TinyIntAsLogical() is set to .T. :

1) When a table is created, logical fields are created as fields of TINYINTEGER type.
2) When a table is read (i.e., when a rowset is read) BIT type fields and also TINYINTEGER fields are read as Boolean. Rowset object remembers the setting when it reads the table from the server and uses the same setting throughout the life of that recordset.

So, set MYSQL_TinyIntAsLogical( .t. / .f. ) once globally at the beginning of the program, depending on your personal choice and leave it.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: SetCheck() on MariaDB

Postby fraxzi » Tue Sep 04, 2018 5:13 am

Hi Rao,

I declared it as global on my init procedure and modify conditions ...

Image

Still the :SetCheck() and the oRS column showing numeric zero instead of boolean..

:?:
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: SetCheck() on MariaDB

Postby nageswaragunupudi » Tue Sep 04, 2018 8:33 am

Please execute this:
Code: Select all  Expand view
oCn:ListColumns( cTable, .t. )

You see the structure of the table in XBrowse

Please reproduce the screenshot here.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: SetCheck() on MariaDB

Postby fraxzi » Tue Sep 04, 2018 9:14 am

Hi Rao,

Here's the result with table containing TINYINT field is it the same structure when I query a table with TINYINT field?:

Image
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: SetCheck() on MariaDB

Postby nageswaragunupudi » Tue Sep 04, 2018 9:20 am

Let me check
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: SetCheck() on MariaDB

Postby nageswaragunupudi » Tue Sep 04, 2018 10:42 am

A simple test:

Code: Select all  Expand view
function TestTinyInt()

   MYSQL_TinyIntAsLogical ( .t. )

   oCn:DropTable( "TINYTEST" )

   oCn:CreateTable( "tinytest", { { "fldlog", "L",  1, 0 }, ;
                                  { "fldchr", "C", 10, 0 }  } )

   oCn:Insert( "tinytest", "fldlog,fldchr", { { .f., "false" }, ;
                                              { .t., "true"  }  } )

   oCn:ListColumns( "tinytest", .t. )

   XBROWSER oCn:tinytest

return nil
 


Image

Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: SetCheck() on MariaDB

Postby nageswaragunupudi » Tue Sep 04, 2018 10:56 am

Please try this small test program at your end and let us see the screen-shot of the result:
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oCn
   
   oCn   := <your connection function>
   
   MYSQL_TinyIntAsLogical ( .t. )

   XBROWSER oCn:RowSet( "SELECT rdt_cnfirm,rdt_apprvd,rdt_appdby FROM rdt_forms" )

   oCn:Close()
   
return nil
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: SetCheck() on MariaDB

Postby fraxzi » Tue Sep 04, 2018 11:53 pm

Hi Rao,

The samples you provided works.. But the other query condition (expression) still not recognized as boolean (after MYSQL_TinyIntAsLogical ( .T. ) global declaration) as shown:

with TinyInt column:
Image

with expression:
Image

query with HeidiSQL:
Image

:?:
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: SetCheck() on MariaDB

Postby nageswaragunupudi » Wed Sep 05, 2018 2:43 am

MySQL returns "false AS lCheck" AS LONG INTEGER but not as TINYINT. There is no way you can return a TinyInt or Bit value from a Query, unless the field itself is TinyInt or Bit field.

We need to instruct XBrowse to treat the numeric value as logical.
This is how:
Code: Select all  Expand view

#include "fivewin.ch"

function Main()

   local oCn, oRs, oDlg, oBrw
   
   oCn   := <your connection>
   oRs   := oCn:RowSet( "SELECT false AS lCheck, rdt_aprvd, rdt_appdby FROM rdt_forms" )
   
   DEFINE DIALOG oDlg SIZE 400,300 PIXEL TRUEPIXEL
   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs AUTOCOLS CELL LINES NOBORDER
     
   WITH OBJECT oBrw:lCheck
      :SetLogical()
      :SetCheck()
   END
   oBrw:CreateFromCode()
   
   ACTIVATE DIALOG oDlg CENTERED

return nil
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: SetCheck() on MariaDB => SOLVED

Postby fraxzi » Wed Sep 05, 2018 3:25 am

Hi Rao,

You Nailed it :!:

:wink: :wink: :wink:
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: SetCheck() on MariaDB => SOLVED

Postby nageswaragunupudi » Wed Sep 05, 2018 3:56 am

You must be using lCheck column to allow the user to select/deselect different rows.
Here is another way to do it without creating a logical column in the query itself. Please test it:
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oCn, oRs, oDlg, oBrw, oFont

   oCn   := FW_DemoDB()
   oRs   := oCn:states

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 500,400 PIXEL TRUEPIXEL FONT oFont

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs ;
      COLUMNS { || oBrw:IsSelectedRow() }, "CODE", "NAME" ;
      HEADERS "" ;
      CELL LINES NOBORDER FASTEDIT

   WITH OBJECT oBrw
      WITH OBJECT :aCols[ 1 ]
         :SetCheck()
         :nHeadBmpNo := 2
         :bLClickHeader := { || oBrw:SelectRow( If( Len( oBrw:aSelected ) == oBrw:nLen, 0, 4 ) ), oBrw:Refresh() }
         :bKeyChar   := { |k| If( k == VK_SPACE, ( oBrw:SelectRow(), 0 ), nil ) }
      END
      //
      oBrw:bLDblClick   := { || oBrw:SelectRow() }
      //
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: SetCheck() on MariaDB => SOLVED

Postby fraxzi » Wed Sep 05, 2018 9:05 am

Hi Rao,

Yes you are correct! :D

The example you provided truly demonstrate xBrowse flexibility ... I so much appreciate your help.

Thanks!

:idea: :idea: :idea: :idea: :idea:
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: SetCheck() on MariaDB => SOLVED

Postby vilian » Wed Apr 08, 2020 8:31 pm

Mr Rao,

I understand the code bellow select all rows:
Code: Select all  Expand view
:bLClickHeader := { || oBrw:SelectRow( If( Len( oBrw:aSelected ) == oBrw:nLen, 0, 4 ) ), oBrw:Refresh() }


How could I avoid select some rows?
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 920
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Re: SetCheck() on MariaDB => SOLVED

Postby nageswaragunupudi » Thu Apr 09, 2020 4:03 am

Clicking on any row toggles the selection.
Selected becomes unselected and vice versa.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 90 guests