1. Falguni Patel
  2. PowerBuilder
  3. Sunday, 8 October 2023 03:47 AM UTC

Hi,

 

I have migrated my application from PB 2019 to PB 2022. I am receiving below error message for datastore retrieval:

the data types varchar and text are incompatible in the greater than and equal to operator

 

However, the same works fine in Crystal Report retrieval and SSMS query using same connection type. This was working find for PB 2019 as well.

The datastore I am trying to retrieve is as below:

SELECT st_master.stock_id,
st_master.company_id
FROM st_master
WHERE ( st_master.company_id = :as_company_id ) AND
( st_master.stock_id >= :as_stock_id_from ) AND
st_master.stock_id <= :as_stock_id_to AND
( st_master.stock_type = 'S' ) AND
( st_master.status = 'A' )

 

The datatype for both columns are varchar in SQL Server.

 

Your advise will be greatly appreciated.

 

Kind regards,

Falguni

 

mike S Accepted Answer Pending Moderation
  1. Sunday, 8 October 2023 13:55 PM UTC
  2. PowerBuilder
  3. # 1

thats an error from the database, not powerbuilder. 

 

 

search (google it) for this error for YOUR database type (sql server).

check to see the exact definition of those columns.  are they text? varchar(max)?  varchar(some fixed size?)

are any of the other columns NOT varchar type (company id?)

start removing parts of the where clause to find out the exact part this is giving you the problem.

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Sunday, 8 October 2023 12:43 PM UTC
  2. PowerBuilder
  3. # 2

Hi Falguni;

   Food for thought ...

  1. Did you check to see if that DWO works OK in the DW Painter's "preview" pane?
  2. Did you extract the SQL from the DWO & make sure that it works ok in the DB Painter's SQL Pane?
  3. Did you run an SQL Trace to see if the SQL is being altered at runtime?

Regards ... Chris 

Comment
  1. Falguni Patel
  2. Monday, 9 October 2023 23:12 PM UTC
Thanks Chris,



My analysis are as below:

When I created a datastore having below statement where as_company_id and as_stk_from are retrieval arguments declared as String

SELECT st_master.stock_id

FROM st_master

WHERE ( st_master.company_id = :as_company_id ) AND

( st_master.stock_id = :as_stk_from )



The SQL Server Trace is as below:

declare @p1 int

set @p1=24

exec sp_prepexec @p1 output,N'@P1 varchar(5),@P2 varchar(20)',N'SELECT st_master.stock_id FROM st_master WHERE ( st_master.company_id = @P1 ) AND ( st_master.stock_id = @P2 ) ','PIBL','B10001'

select @p1



In the same datawindow, as soon as I add >= as per below

SELECT st_master.stock_id

FROM st_master

WHERE ( st_master.company_id = :as_company_id ) AND

( st_master.stock_id >= :as_stk_from )





The SQL trace is as below:

declare @p1 int

set @p1=NULL

exec sp_prepexec @p1 output,N'@P1 varchar(5),@P2 text',N'SELECT st_master.stock_id FROM st_master WHERE ( st_master.company_id = @P1 ) AND ( st_master.stock_id >= @P2 ) ','PIBL','B10001'

select @p1



As per above example, the PB Datawindow changes the SQL sp_prepexec statement when operator is changed to >= and causes this issue which is a PB datawindow bug.



Kindly note that the statement copied to SSMS query executes well and gives correct result.



Appreciate if you could address this to Appeon team to fix at earliest as my legacy application is unstable after migrating to PB2022 R2.



  1. Helpful
  1. Chris Pollach @Appeon
  2. Monday, 9 October 2023 23:30 PM UTC
Hi Falguni;

Since you seem to have a reproducible scenario ... please open a Support Ticket and include a reproducible test case PB App & Test DB to the ticket for Appeon Engineering to study.

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.