I am using a simple SQL statement in the database painter. Some columns have the NULL value, but they are displayed as blanks. How can I show that it is actually a NULL. Also when I export the result set to a CSV or XLSX I want to the word NULL in the column. I cannot find anything about how to display this. Any thoughts?
- You are here:
- Home
- Q&A
- Q&A
- PowerBuilder
- Displaying Null in Database Painter
- Louis Arena
- PowerBuilder
- Monday, 13 November 2023 22:32 PM UTC
- Tuesday, 14 November 2023 15:27 PM UTC
- PowerBuilder
- # 1
Can you modify the select to return 'NULL' if the column value is null?
select if colname is null then 'NULL' else colname endif as NullCol from tablename;
- Louis Arena
- Tuesday, 14 November 2023 15:42 PM UTC
-
Helpful Loading... Helpful 0
- Tuesday, 14 November 2023 01:14 AM UTC
- PowerBuilder
- # 2
Hi Louis;
That's exactly what Display Formats are designed to do!
- String format: "string-format;null-format"
- Example: "@@@@@@";NULL"
- Number format: Positive-format;negative-format;zero-format;null-format
- Example: "[green];[red];Zero;Null"
FYI: https://docs.appeon.com/pb2022/pbug/ug69750.html#d0e41819
Display formats can be used in both the DW & DB painters. ;-)
Regards ... Chris
- John Fauss
- Tuesday, 14 November 2023 02:30 AM UTC
-
Helpful Loading... Helpful 1
- Chris Pollach @Appeon
- Tuesday, 14 November 2023 15:58 PM UTC
Since PB will export the data to Excel from it's primary buffer where the datum is a mirror image of what the DBMS result set was, no formatting will be done on the PB side. However, if Louis opens the Excel data file in an Excel "template" he can have Excel format the datum the same was as the DW does using Display Formats via an Excel macro. In fact, PB designed the DF feature originally after the Excel DF / Macro standard. ;-)
FYI: =IF(ISBLANK(B4),"Customer Name","")
Also, Louis could use OLE and transfer the data to the Excel spreadsheet cells under PowerScript control and thus format each cell as per the IsNull() test. That would be another way. HTH
Regards ... Chris
-
Helpful Loading... Helpful 0
- Tuesday, 14 November 2023 14:47 PM UTC
- PowerBuilder
- # 3
Also, where/how in the database painter when you execute your SQL can you format the column? Obviously the datawindow is easy to manipulate. But when you run the SQL and you are in the results tab, there is no way to set the string function on a column. And it appears that when and if you can set a string function to display the value as NULL you will not be able to export NULL to CSV or XLXS. Microsoft ISQL Manager displays the NULL value, which PC should as well because that is actually the value, it is not an empty string. However, in MS ISQL I cannot export to CVS with headers. So both applications are lacking.
- Chris Pollach @Appeon
- Tuesday, 14 November 2023 15:51 PM UTC
Display Formats are also available to use in the DB Painter as well! ;-)
Regards ... Chris
-
Helpful Loading... Helpful 0
- Louis Arena
- Tuesday, 14 November 2023 15:59 PM UTC
-
Helpful Loading... Helpful 0
- Tuesday, 14 November 2023 16:39 PM UTC
- PowerBuilder
- # 4
Hi Louis;
For the DB Painter, it's a two step process
1) Create the require DF ...
2) Attach the DF to the appropriate column ...
3) Run your SQL. You should now see the DF's active. ;-)
HTH
Regards ... Chris
- Page :
- 1
However, you are not allowed to reply to this question.