1. Raymond Longoria
  2. PowerBuilder
  3. Wednesday, 31 January 2024 23:16 PM UTC

I am working in Powerbuillder 2022 R2 and I am getting an error on the Update function of a datawindow. I am getting thrown off by the error saying the sql has "ORDER BY". I assume the data window is generating the update statement. If so, why would it add that statement to the sql?

SQLSTATE = 42000
Microsoft SQL Server Native Client 11.0
Incorrect syntax near the keyword 'ORDER'.

No changes made to database.

UPDATE dbo.APP SET descr = 'Testing again', mod_uid = 't2', mod_dt = '2024-01-31 10:48:47.866'
WHERE app_id = 9097 AND timestamp = 0x0000000006C1D925 AND (APP.task_nbr = 2) AND
(ORG.type = 8) AND (APP.org_id = 7581) AND (APP.status_cd = 2) ORDER BY APP.rcvd_dtime DESC

Accepted Answer
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 1 February 2024 02:07 AM UTC
  2. PowerBuilder
  3. # Permalink

Hi Raymond;

  This sounds a bit weird to me. I would do the following to try & figure out why the "Order By" clause is being generated, as follows ...

  • Add an SQL trace (SQLCA.DBMS = "TRACE SNC") to your App's transaction object. This will give you a detailed C/S DB trace to review.
  • Check the DW Control owner of the updating DWO to see if there is any PowerScript code that might altering the SQL leaving the control to the DBMS at runtime that might be adding an "Order By".

HTH

Regards... Chris 

Comment
There are no comments made yet.
Raymond Longoria Accepted Answer Pending Moderation
  1. Thursday, 1 February 2024 20:50 PM UTC
  2. PowerBuilder
  3. # 1

Thanks Chris that helped. I found that the SqlPreview event was adding the "Order BY" statement. I added a check to not do this on an update.

Comment
  1. Chris Pollach @Appeon
  2. Thursday, 1 February 2024 21:03 PM UTC
Hi Raymond;

That's awesome news that you found the mystery culprit! :-)

Thanks for the update.

Regards .... Chris
  1. Helpful
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.