1. Paul Aspland
  2. PowerBuilder
  3. Monday, 20 December 2021 11:25 AM UTC

When I retrieve a string into a datawindow attribute, powerbuilder is padding the string (with spaces) to the limit number of characters.

The effect is that the user cannot insert into the string without first deleting the characters at the end.

I found some old articles referring to "PBTrimCatCharColumns='YES'", however this seems to have had no impact.

I am using Powerbuilder 2021 latest release.

All help appreciated !

 

Miguel Leeuwe Accepted Answer Pending Moderation
  1. Monday, 20 December 2021 15:23 PM UTC
  2. PowerBuilder
  3. # 1

Hi Paul,

I'm thinking you're using the incorrect dbparm: PBTrimCatCharColumns

Use PBTrimCharColumns, see the attached dbparm pdf.

 

PBTrimCharColumns
Description Specifies whether PowerBuilder should trim trailing spaces from data values
retrieved from the following datatypes: Char, Char for Bit Data, VarChar, and
VarChar for Bit Data.
Applies to ODBC
OLE DB
Syntax PBTrimCharColumns=value
Default value 'NO'
Usage This parameter can only be set in the pbodb125.ini file. For ODBC, you can set
the TrimSpaces parameter in the Database Profile Setup dialog box or in code
to perform the same function.
By default, PowerBuilder trims spaces from the following datatypes: Char,
Char for Bit Data, VarChar, and VarChar for Bit Data.
If your DBMS makes a distinction between Char data with trailing spaces and
Char data without trailing spaces when evaluating a WHERE clause expression,
you might receive the message Row changed between retrieve and
update when your DataWindow object’s update properties are set to “Key and
updateable columns.” To prevent this, change your DataWindow object’s
update properties. In embedded SQL, you can check Sqlca.Sqlnrows after each
update to determine if the update took place. Avoid using Char data columns
in the WHERE clause of an UPDATE or DELETE statement when
PBTrimCharColumns='YES'.
Examples To specify that PowerBuilder should trim trailing spaces, add the following
line to the section for the database you are accessing:
PBTrimCharColumns='YES'
Parameter Description
value

 

regards.

MiguelL

Attachments (1)
Comment
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Monday, 20 December 2021 15:21 PM UTC
  2. PowerBuilder
  3. # 2

SET ANSI_PADDING (Transact-SQL) - SQL Server | Microsoft Docs

 

you need to make sure the string is trimmed. because the database will not if you have ansi padding on, which is the default.  

users will often accidently add a space at the end of what they type, so this can be a pain to handle.  It would be a really nice feature to have in a datawindow/datastore: auto-trim string.

 

 

 

 

 

Comment
There are no comments made yet.
Paul Aspland Accepted Answer Pending Moderation
  1. Monday, 20 December 2021 14:06 PM UTC
  2. PowerBuilder
  3. # 3

I'm using MS SQL 2019 and the 'MSOLEDBSQL SQL Server' driver, however I've checked with MS ODBC and get the same result.

The database itself has the string stored correctly (no padding).

Comment
There are no comments made yet.
Paul Aspland Accepted Answer Pending Moderation
  1. Monday, 20 December 2021 12:39 PM UTC
  2. PowerBuilder
  3. # 4

I'm using MS SQL 2019 and the 'MSOLEDBSQL SQL Server' driver, however I've checked with MS ODBC and get the same result.

The database itself has the string stored correctly (no padding).

 

Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Monday, 20 December 2021 11:37 AM UTC
  2. PowerBuilder
  3. # 5

Hi,

Which database (Oracle, ms sqlserver, etc.) are you using and which driver (ODBC, JDBC, native, OLEDB, etc.)

regards

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.