Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 5 of 5 total |
Code to convert Boolean to CHAR(1) preserving True as 'Y' and False as 'N'? |
Thu, May 23 2019 1:36 PM | Permanent Link |
Trinione | Using the EDB Manager it is easy to convert a field from Boolean to CHAR(1) and Preserve the first character as
'T'. and 'F' respectively. How can this be done by code? ........................................................ PascalNetwork.com pascal - the language we love |
Thu, May 23 2019 1:49 PM | Permanent Link |
Raul Team Elevate | On 5/23/2019 1:36 PM, Trinione wrote:
> Using the EDB Manager it is easy to convert a field from Boolean to CHAR(1) and Preserve the first character as > 'T'. and 'F' respectively. > > How can this be done by code? Simply execute sample Alter SQL and it should work - you can see SQL that EDB Manager executes from Explorer menu -> SQL History ALTER TABLE "MyTable" ALTER COLUMN "MyColumn" AS CHAR(1) COLLATE "UNI" Raul |
Thu, May 23 2019 2:01 PM | Permanent Link |
Trinione | Thank you Raul. I didn't see the SQL History, it is really helpful.
Thanks again. Raul wrote: On 5/23/2019 1:36 PM, Trinione wrote: > Using the EDB Manager it is easy to convert a field from Boolean to CHAR(1) and Preserve the first character as > 'T'. and 'F' respectively. > > How can this be done by code? Simply execute sample Alter SQL and it should work - you can see SQL that EDB Manager executes from Explorer menu -> SQL History ALTER TABLE "MyTable" ALTER COLUMN "MyColumn" AS CHAR(1) COLLATE "UNI" Raul ........................................................ PascalNetwork.com pascal - the language we love |
Thu, May 23 2019 2:53 PM | Permanent Link |
Trinione | When conversion is done to VARCHAR it loses the data and sets to NULL.
Converting to CHAR preserves the data. So, if you want to convert to VARCHAR, first convert BOOLEAN to CHAR, then convert CHAR to VARCHAR. ........................................................ PascalNetwork.com pascal - the language we love |
Sat, May 25 2019 2:07 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Trinione,
<< When conversion is done to VARCHAR it loses the data and sets to NULL. >> This actually should show up in the log messages in the EDB Manager, but doesn't due to a bug. What you should see is a series of messages like this: "The value for the TestBoolean column has been set to NULL for the row 1 due to an error (An error occurred with the column TestBoolean (The value FALSE would result in truncation))" If you execute the table alteration interactively, and not in an SQL window, then you *will* see the log messages. The issue is that VARCHARs require that any input *not* get truncated, otherwise this is considered to be an error. Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Monday, April 29, 2024 at 05:23 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |