Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to get logical data from PostgreSQL
Message
From
22/01/2005 16:48:46
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Client/server
Title:
How to get logical data from PostgreSQL
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
00979680
Message ID:
00979680
Views:
73
PostgreSQL has boolean and bit bata types.
Unfortunately, VFP returns them as character columns.
Also, trying to set conversion to logical data type does not work.

Any idea how to force VFP to return logical column from PostgreSQL data ?

To reproduce:

1. Create PostgreSQL data source PostgreSQL
2. Run the code

Observed results: C, C, "Type conversion is invalid" error
Expected results: L, L, No error
cconnstr= 'DSN=PostgreSQL;' + ;
  "DRIVER=PostgreSQL; UID=postgres; PWD=masterkey;"

tnConnHnd = sqlstringconnect( cconnstr )
IF tnConnHnd <= 0
  AERROR(gaError)
  MESSAGEBOX(gaerror[1,2])
  return
  ENDIF

SQLEXEC(tnConnHnd,'DROP TABLE test')

IF SQLEXEC(tnConnHnd,'create table test ( test boolean )') < 0
  * This does not work also:
  * IF SQLEXEC(tnConnHnd,'create table test ( test bit )') < 0
  AERROR(gaError)
  MESSAGEBOX(gaerror[1,2])
  RETURN
  ENDIF

CreateCursorAdapter()
MESSAGEBOX( TYPE('cursoradapter1.test'))

CreateRemoteView()
MESSAGEBOX( TYPE('test'))

DBSetProp('TEST.TEST', 'Field', 'DataType', "L")

* Next USE causes error
* Type conversion required by the DataType property for field 'Test' 
* is invalid.

USE test

RETURN


PROCEDURE CreateCursorAdapter

PUBLIC ca AS cursoradapter
ca =CREATEOBJECT( 'cursoradapter' )
ca.DataSourceType='ODBC'
ca.DataSource = tnConnHnd 
ca.SelectCmd = "SELECT * FROM TEST"
IF !ca.cursorfill()
  AERROR(gaError)
  MESSAGEBOX(gaerror[1,2])
  RETURN
  ENDIF
ENDPROC

PROCEDURE CreateRemoteView

CREATE DATABASE test
CREATE CONNECTION test CONNSTRING (cconnstr)

CREATE SQL VIEW test REMOTE ;
   CONNECTION test ; 
   AS SELECT * FROM test

USE test
ENDPROC
Andrus
Next
Reply
Map
View

Click here to load this message in the networking platform