1. Sivaprakash BKR
  2. PowerBuilder
  3. Monday, 31 October 2022 13:20 PM UTC

Hello,

Have anyone developed multi - database application in Powerbuilder ?   ie. a common application that will update either SQL Server or PostGreSQL or SQLite or others ...  depending on the connection that's made in the open event of the application.

If yes, would like to hear from your experience the points needs to be taken care of.

Will use ODBC to connect PostGreSQL and SQLite.  (currently) OLE-DB to connect SQL Server, later might switch to MSOLEDBSQL.  

Happiness Always
BKR Sivaprakash

 

Brett Weaver Accepted Answer Pending Moderation
  1. Wednesday, 30 November 2022 01:05 AM UTC
  2. PowerBuilder
  3. # 1

I have supported applications that talk to SQL Anywhere, Sybase ASE and SQL Server depending on an option switch. I seem to remember one was also talking to Oracle vis ODBC as well.

Chris' list seems to address most of the issues

 

Comment
  1. Sivaprakash BKR
  2. Thursday, 1 December 2022 05:09 AM UTC
Thanks Brett
  1. Helpful
There are no comments made yet.
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Tuesday, 1 November 2022 06:16 AM UTC
  2. PowerBuilder
  3. # 2

Thanks all for your valuable inputs.

In our earlier application, we used SQL Server with stored procedures for many reports.   No we are moving away from SPs.   

We have developed in SQL Server and now in PostGreSQL.   New to SQLite.   For few customers, where portability is required, we plan to use SQLite.  Complete app with DB in a pendrive / external HDD, which can be used in any computer.  Yes we may need to install SQLite drivers, if not available.  TopwizProgramming's ODBC API and RunAndWait will be handy in those situations.

We should choose a common minimum features available in all database servers.

Also, We need to find a way to solve the following issues

1.  As already pointed out, we need a way to fetch Top N rows ...   the syntax differs from SQL Server to PostGreSQL.   No idea about SQLite.  Is there any common (ansi) way to fetch the top N records?  Can this limit be set in a datawindow (graphics mode), that it can translate to equivalent DB ?

2.  Computed Columns
          In PostGreSQL
                Date field        Cast(null as date) as field2  returns date as datatype in datawindow, ODBC
          In SQL Server
                 Date field       cast(null as date) as field2   returns char(10) as datatype, OLE DB.
                                                                              returns date as datatype, SNC SQL Native Client

Should go with different dw objects, if required.

Will analyze further in the coming days.

Happiness Always
BKR Sivaprakash

Comment
  1. Sivaprakash BKR
  2. Tuesday, 1 November 2022 10:29 AM UTC
Miguel

Yes, Oracle was there initially, later we dropped it.

  1. Helpful
  1. Bruce Armstrong
  2. Saturday, 5 November 2022 20:49 PM UTC
>>As already pointed out, we need a way to fetch Top N rows ... the syntax differs from SQL Server to PostGreSQL. No idea about SQLite. Is there

>>any common (ansi) way to fetch the top N records? Can this limit be set in a datawindow (graphics mode), that it can translate to equivalent DB ?



Apparently not. Each vendor seems to have a slightly different syntax for it. Perhaps you might consider creating a SQL generating NVO for common functions like that. You then create a database specific descendant of that to generate the SQL that database wants. At runtime, create the descendant that you need for the database you're working with. You might just use custom descendants of a transaction object and use that for SQLCA.

  1. Helpful
  1. Miguel Leeuwe
  2. Sunday, 6 November 2022 07:56 AM UTC
Hi Bruce,

As already pointed out:

For SQLITE you can use the LIMIT keyword:



https://www.sqlitetutorial.net/sqlite-limit/

  1. Helpful
There are no comments made yet.
Bruce Armstrong Accepted Answer Pending Moderation
  1. Tuesday, 1 November 2022 00:33 AM UTC
  2. PowerBuilder
  3. # 3

1.  Do all databases interactions with a DataWindow

2.  Leave all of the DataWindows in graphic mode.  That will allow PowerBuilder to target the SQL generated for the target database.

Comment
  1. Chris Pollach @Appeon
  2. Tuesday, 1 November 2022 10:18 AM UTC
Tip #2 is a very good point Bruce!
  1. Helpful
There are no comments made yet.
Matt Balent Accepted Answer Pending Moderation
  1. Monday, 31 October 2022 18:35 PM UTC
  2. PowerBuilder
  3. # 4

At my very first PowerBuilder job (ca 1995) we connected to either Sybase or Oracle.

Make sure you adhere to ANSI Standards in your SQL.

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 31 October 2022 13:55 PM UTC
  2. PowerBuilder
  3. # 5

Hi Siva;

  I would recommend...

  • Keep all DB designs consistent using common data types.
  • Do not use inline DML 
  • Do not use  DBMS specific features.
  • Only use DataWindows to process all DML requests.

HTH

Regards ... Chris 

Comment
  1. mike S
  2. Monday, 31 October 2022 15:08 PM UTC
inline sql works fine as long as you use ansi standard sql and your own standard user functions



sometimes using dbms specific features are unavoidable. For example, use of TOP vs FETCH FIRST. those situations you can't avoid using a case statement, and that should be extremely rare.
  1. Helpful 2
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Monday, 31 October 2022 13:44 PM UTC
  2. PowerBuilder
  3. # 6

yes.

the single most important thing is to use ansi sql when you can and minimize the use of sql specific to a single dbms, things like use coalesce instead of isnull/nvl

 

You can also *usually* create a set of user functions to allow you to use a single standard function list (assuming you use these). for example: 

Len vs length / getdate() vs now()  / substring/SUBSTR ....

 

consider using views/stored procedures to handle some of the specific differences.

 

generally, all datawindows are designed to work in all databases.  You don't want to have to maintain the same datawindow for different databases.

 

 

Comment
  1. Olan Knight
  2. Monday, 31 October 2022 17:24 PM UTC
We use the LOGON window to identify the user, the database, and by extraction from the database name the database type.

Our naming convention prevents duplicate database names.



I also agree with most of the suggestions above except that I personally really hate stored procedures. Yes, sometimes they are necessary, particularly for performance, but in most cases you can do what is required locally and maintain immediate control over the code.
  1. Helpful 2
  1. mike S
  2. Monday, 31 October 2022 17:56 PM UTC
yeah, i agree that stored procedures are generally overused. i use them very rarely. they can be good for abstracting away from pb some dbms specific things like adding a database user.
  1. Helpful
  1. Roland Smith
  2. Tuesday, 1 November 2022 00:16 AM UTC
If your PowerBuilder app is sold to customers, stored procedures allow your customers to see business logic and possibly make changes which may cause problems.
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Monday, 31 October 2022 13:35 PM UTC
  2. PowerBuilder
  3. # 7

SQL functions can be different. The getdate function for example has different syntax on different database servers.

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.