1. Christopher Baker
  2. PowerBuilder
  3. Friday, 5 January 2024 23:36 PM UTC

Hello,

 

Is the use of Cross/Outer Apply supported in datawindow sql queries?

Im running into a problem, using either 'ODB ODBC' or 'MSQLEDBSQL SQL Server' for my db connection to a sql server 2019 instance.

The problem is when including an apply in my query, the column names in the "Name" and "DB Name" columns of the Column Specification list in the datawindow painter lose the table names. as in they go from being Table.Column or table_column, to just Column. with larger queries, this also causes ambiguous column names to be excluded from the list.

I created an example using the MS AdventureWorks2019 database in PB 2022 R2. The use of apply in this example is to showcase the the the problem with the datawindow painter.

 Below are screenshots of the column specification and sql for both example datawindows.

 

d_withoutapply sql

Select c.AccountNumber, p.lastname, p.firstname
From Person.Person p
Left Join Sales.Customer c on p.BusinessEntityID = c.PersonID
where c.CustomerID is not null

 

d_withapply sql


Select c.AccountNumber, p.lastname, p.firstname, t.Total
From Person.Person p
Left Join Sales.Customer c on p.BusinessEntityID = c.PersonID
Outer Apply (Select SUM(TotalDue) as Total
From Sales.SalesOrderHeader x
where x.CustomerID = c.CustomerID
Group by CustomerID) t
where c.CustomerID is not null

 

Accepted Answer
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Saturday, 6 January 2024 00:13 AM UTC
  2. PowerBuilder
  3. # Permalink

Hi Chris;

  The "Outer Apply" & "Cross Apply" are SS specific DBMS conventions and not ANSI SQL (which is what PB expects).

  •   For the "Outer Apply" command, use a "LEFT OUTER JOIN" command instead.
  •   For the "Cross Apply" command,  use an "INNER JOIN" command instead.

 However, please feel free to open a support ticket as an enhancement request for Cross Apply and Outer Apply to be supported.

  Suggestion: As a workaround - if you really need to use these commands - I would suggest using these commands within a Stored Procedure that then returns a known standard result set.   HTH 

Regards ... Chris 

Comment
  1. Chris Pollach @Appeon
  2. Tuesday, 9 January 2024 16:29 PM UTC
Hi Chris;

Thank you for marking this post as "resolved"! :-)

Regards ... Chris
  1. Helpful
  1. Christopher Baker
  2. Thursday, 11 January 2024 14:47 PM UTC
Hey Chris,



Thank you for the info last week.

Just to clarify, what is the latest version of Ansi Sql that is currently supported by PB?
  1. Helpful
  1. Chris Pollach @Appeon
  2. Thursday, 11 January 2024 15:56 PM UTC
Hi Chris;

When Appeon took over PB from SAP in 2016 it was PB version 12.6. That version's SQL features were still based on the SQL-92 specification.

Appeon PB (AFAIK) still uses that default in the way it "thinks" and "Handles" DML and result sets.

HTH

Regards ... Chris
  1. Helpful 1
There are no comments made yet.


There are replies in this question but you are not allowed to view the replies from this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.