1. Mark Winsor
  2. PowerBuilder
  3. Tuesday, 14 May 2024 18:54 PM UTC

When converting an application from PB9 to PB2019 I get this error on the below datawindow. It appears to interpret the the string retrieval argument as a "text" datatype.

The error is: [ODBC 17 for SQL Server][SQL Server]The data types varchar and text are incompatible in the less then or equal to operator.

The SQL that generates the error is this:

SELECT routing.countrycode,
routing.startingpostalcode,
routing.endingpostalcode,
routing.routingcode
FROM routing
WHERE ( routing.countrycode = :CountryCode ) AND
( routing.startingpostalcode <= :PostalCode ) AND
( routing.endingpostalcode >= :PostalCode )

if I cast my retrieval argument to a varchar I can get it to work. Is there some setting somewhere that I am missing to make the syntax above work?

This SQL works:

SELECT routing.countrycode,
routing.startingpostalcode,
routing.endingpostalcode,
routing.routingcode
FROM routing
WHERE ( routing.countrycode = :CountryCode ) AND
( routing.startingpostalcode <= Cast(:PostalCode as varchar(6)) ) AND
( routing.endingpostalcode >= Cast(:PostalCode as varchar(6)) )

Mark Winsor Accepted Answer Pending Moderation
  1. Tuesday, 14 May 2024 20:22 PM UTC
  2. PowerBuilder
  3. # 1

Sorry I pressed the wrong button as my reply to your question is above your question. 

Comment
There are no comments made yet.
Mark Winsor Accepted Answer Pending Moderation
  1. Tuesday, 14 May 2024 20:20 PM UTC
  2. PowerBuilder
  3. # 2

As a follow up, this is either a setting that I do not know of that I need to adjust, or it is a bug that has been fixed in PB2022 as the behavior does not occur in PB2022.

Comment
There are no comments made yet.
Mark Winsor Accepted Answer Pending Moderation
  1. Tuesday, 14 May 2024 20:10 PM UTC
  2. PowerBuilder
  3. # 3

The database variables are varchar. This worked fine in PB9. The reason it is being used with varchar is that it is part of a shipping application where the tables contain a starting and ending postal code and a zone. Given a specific postal code, I need to find the row that has the span that includes this postal code. 

So the table would be:

StartingPostalCode varchar(6)

EndingPostalCode varchar(6)

Zone int

 

This may contain rows like such:

21001, 21100, 5

21101, 22100, 6

 

Given a postal code of 21093, I need the zone. 

 

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Tuesday, 14 May 2024 19:33 PM UTC
  2. PowerBuilder
  3. # 4

The <> operators are usually used with numbers. What are you trying to accomplish by using <> with characters?

It would help if you told us what the datatypes are of all the involved columns.

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.