Page 1 of 1

PGDBE testing

Posted: Wed Apr 05, 2017 6:13 am
by skiman
Hi,

I just did a test to see if the PGDBE could be an option.

I have the following test program, as you can find in the docs.

Code: Select all

#include "Common.ch"

// PostgresSQL DBE header file is required
#include "pgdbe.ch"

PROCEDURE Main
  LOCAL cConnect
  LOCAL oSession

  // Load the PostgreSQL DatabaseEngine
  IF(!DbeLoad("pgdbe"))
    Alert( "Unable to load the PostgreSQL DatabaseEngine", {"Quit"} )
    QUIT
  ENDIF

  // Establish the connection
  cConnect := "DBE=pgdbe;SERVER=localhost;DB=northwind;UID=postgres;PWD=aboservice"
  oSession := DacSession():New( cConnect )

  // Check for connection success
  IF .NOT. oSession:isConnected()
    ? oSession:GetLastMessage()
    Alert( "Unable to establish connection to server", {"Quit"} )
    QUIT
  ENDIF
  // Perform simple select and browse
  // the result set
  SELECT * FROM customers VIA (oSession)   // IMPORTANT oSession MUST be between (  )  !!!!

  Browse()

  // Up to here it is working.
  alert("Use and show name of first record")
  use customers alias klant  via PGDBE
  klant->(dbgoto(1))
  alert( klant->companyname )

  // Disconnect from server
  oSession:disconnect()
RETURN
I don't receive any error, but I don't succeed to show any data in ISAM style. The 'use customers alias klant via PGDBE' opens the database, when i Put a klant->(BROWSE()) I see the browse with correct columns but no data.
After the dbgotop of dbgoto(1), the klant->companyname remains empty.

Anyone an idea what's wrong with this?

Re: PGDBE testing

Posted: Wed Apr 05, 2017 7:34 am
by PedroAlex
Hi,

I use to connect a remote DB.
I can add new records and consult records.
but in SQL mode.

I remember doing some tests on ISAM mode and it works ok, but very slow..

Have you tried DbAppend() and populate some records?

Regards
Pedro

Re: PGDBE testing

Posted: Wed Apr 05, 2017 7:48 am
by skiman
Hi,

Just tried the following.
klant->(dbappend()) -> this gives me an error.

Then I did the following:
dbesetdefault("pgdbe").
The I removed the VIA clause of the use.

Result remains the same.

The I tried : use customers alias klant NEW -> adding the NEW clause gives an error.

Meanwhile I tried to find more info about the PGDBE. I also checked the Alaska newsgroup. I suppose I better stop with it. I didn't read any positive comment about this driver.

Re: PGDBE testing

Posted: Wed Apr 05, 2017 8:22 am
by rdonnay
I am not using any of the new SQL features of Xbase++ 2.0.
There are just too many problems with it.

Fortunately ADS handles ISAM and SQL very nicely and that's what I suggest for my customers.

Re: PGDBE testing

Posted: Wed Apr 05, 2017 8:34 am
by PedroAlex
Hi Chris..

The future of our dbfs is SQL.
With pgdbe or without pgdbe ..
I would believe it will be with PgDbe ..
I think it would be very useful if Roger created a specific topic for PostGre SQL

Try this code:

Code: Select all


PROCEDURE Main()

LOCAL oSession
LOCAL cConnStr

DbeLoad("pgdbe")
DbeSetDefault("pgdbe")

cConnStr := "DBE=pgdbe;SERVER=localhost;"
cConnStr += "DB=northwind;UID=postgres;PWD=aboservice"

oSession := DacSession():New(cConnStr)
IF(!oSession:IsConnected())
  MsgBox("Connection failed ("+Var2Char(oSession:GetLastMessage())+")")
  QUIT
ENDIF

//MsgBox("Connected to PostgreSQL server")

// Test of Table exist
IF(!TABLE("Customers"))
   MsgBox("No Customers table")
Else
   MsgBox("Table Customers ok")
ENDIF

USE CUSTOMERS INDEX CustName ALIAS Cust NEW

Cust->( DbsetOrder(1) )
Cust->( DbGoTop() )
Cust->( Browse() )


//......


oSession:disconnect()
DbeUnLoad("pgdbe")
ReTURN


Re: PGDBE testing

Posted: Wed Apr 05, 2017 1:04 pm
by Auge_Ohr
hi,

since 2012 i use PostgreSQL "native" with libpq.dll
http://bb.donnay-software.com/donnay/vi ... f=7&t=2160

If you want to use SQL i recommend to learn "real" SQL Query and not to follow Alaska ISAM Stuff.

Re: PGDBE testing

Posted: Thu Apr 06, 2017 1:11 am
by skiman
Hi,
USE CUSTOMERS INDEX CustName ALIAS Cust
I created the index on the table Customers, but now I get an error 'Order can not be found' with the operation DbSetIndex.
USE CUSTOMERS INDEX CustName ALIAS Cust NEW
Adding the NEW clause gives 'Internal data structures corrupted' on Operation DbUseArea.

Since the PG20 help manual is empty in the chapter 'Navigational Support ISAM' it is really hard to start with this.

Re: PGDBE testing

Posted: Thu Apr 06, 2017 1:16 am
by skiman
Auge_Ohr wrote:hi,

since 2012 i use PostgreSQL "native" with libpq.dll
http://bb.donnay-software.com/donnay/vi ... f=7&t=2160

If you want to use SQL i recommend to learn "real" SQL Query and not to follow Alaska ISAM Stuff.
Hi Jimmy,

We want to use 'real SQL' and we will use it in another language. I thought to move to PostGres with Xbase++. At the same moment we can work on our new software, which could use the same database. This way our users of our software can decide when to upgrade to the new software, but can still use the old software.

It looks as this would be a nightmare, so I don't think this is the way to go.

Re: PGDBE testing

Posted: Mon Apr 10, 2017 6:37 pm
by pedroah
Dear Chris

The first thing you have to do is migrating your actual table to Postgresql with the dbfupzise tool from Alaska. It needs a xml structure to do the job, here is a tool to make it

http://bb.donnay-software.com/donnay/vi ... f=7&t=1403

You can use universal sql for dbf and postgresql and work for both.

Roger have excellents samples here

http://bb.donnay-software.com/donnay/vi ... =15&t=1993

Isam is slow, but you can play making temp file dbf, xml or other, and you can move data from one source to another wherever you want.

The better thing is with a single change in compilation, you can have both version, dbf style and postgresql isam style.

The last Release have resolve issues about PostgreSQL ISAM.

A personal recommendation, SSD Disk and good amount of memory.

Re: PGDBE testing

Posted: Tue May 16, 2017 2:02 am
by cobasystems
rdonnay wrote:I am not using any of the new SQL features of Xbase++ 2.0.
There are just too many problems with it.

Fortunately ADS handles ISAM and SQL very nicely and that's what I suggest for my customers.

O'Sensei Roger,
your advice is worth gold. Therefore, tell it to me.
When at last solve to start working with SQL database
What to choose:

   1. Alaska Xbase ++ 2.0 and PgSQL (min. $ 2500)
   2. Oracle 11g XE and Oracle Apex 5.1 (free)

Thank you in advance.