How to format a Decimal column in DB2? - db2

Select totalvalue from user
This DB2 query is giving output like,
00000000000000000000072834.37000,
00000000000000000000147532.26000,
00000000000000000000145485.89000
I'd like to Display it as below,
72834.37,
147532.26,
145485.89
Is that possible in DB2? Thanks in Advance!

VARCHAR_FORMAT function should work in this case. Try out the below query:
SELECT
VARCHAR_FORMAT(TOTALVALUE, 'S99999999999999999999999999.999999')
FROM USER;

Try this:
Strip(CHAR(DIGITS(00000000000000000000072834.37000)),L,'0')
it should give you 72834.37000

Your DECIMAL type is being returned as a CHAR. If you're not doing it, then check your CLI settings for MapDecimalFloatDescribe.

Related

Postgres - LIKE ANY UPPER()

Is there a way to use UPPER with a LIKE ANY()?
I have the following example:
SELECT
....
where skus.number like any ('{"%00130204%", "%00130202"}')
Unfortunately the skus I'm checking here can be of different cases, so I tried doing this:
SELECT
....
where UPPER(skus.number) like any UPPER('{"%00130204%", "%00130202"}'))
Which doesn't work, is there any way to get this working in the query itself?
No need to use upper. Use the case insensitive version of like, "ilike" instead.
SELECT
....
where skus.number ilike any ('{"%00130204%", "%00130202"}')
along with being totally with #Joe on his answer as better for you query (and skipping phylosophy behind idea to represent digits in uppercase), I decided to answer the topic of your post
Is there a way to use UPPER with a LIKE ANY()?
yes - here it is:
t=# select UPPER('110013020411') like any (UPPER('{"%00130204%", "%00130202"}')::text[]) comaprison;
comaprison
------------
t
(1 row)
after you upper text in array represented as text you need to cast it back inorder to use with ANY (array)

Convert binary to uniqueidentifier in t-sql?

I have the following code that converts Unique-identifier to Binary:
CAST(GUID AS BINARY(16))
which results in this '0x56B3C0955919CD40931F550749A83AF3'
Now, I want to convert this (i.e. the binary string value '0x56B3C0955919CD40931F550749A83AF3') to Unique-Identifier.
Any simple way to achieve this?
Uh, just convert it back?
DECLARE #n UNIQUEIDENTIFIER = NEWID();
SELECT #n;
SELECT CONVERT(BINARY(16), #n);
SELECT CONVERT(UNIQUEIDENTIFIER, CONVERT(BINARY(16), #n));
If you have a binary value like 0x56B3C0955919CD40931F550749A83AF3, stop putting it into quotes when trying to convert it. For example:
SELECT CONVERT(UNIQUEIDENTIFIER, 0x56B3C0955919CD40931F550749A83AF3);
Isn't this the result you're after?
95C0B356-1959-40CD-931F-550749A83AF3

ssrs expression to split string possible?

so in my query i have select columnx from tblz
it returns 001.255556.84546
I want to be able to split this via '.' and put it into three columns.
column1 = 001
column2 = 255556
column3 = 84576
is this possible?
For info, in 2008 these dont work, you have to do the following:
=Split(Fields!returnedValue.Value, ".").GetValue(0)
Create three calculated fields with the following expressions:
=(Split(Fields!columnx.Value, ".")).GetValue(0)
=(Split(Fields!columnx.Value, ".")).GetValue(1)
=(Split(Fields!columnx.Value, ".")).GetValue(2)
I'm not sure it works or not, maybe give it a try. You might need to use IIF() statement to check values before getting them.
In SSRS you reference the field name, tell it the delimiter to use. Since you are not assigning to a variable, per se, you then need to tell it which part of the split string to use. In your example
=Split(Fields!returnedValue.Value,".")(0)
=Split(Fields!returnedValue.Value,".")(1)
=Split(Fields!returnedValue.Value,".")(2)
You would replace returnedValue with whatever the actual field name is, and place each one of those into your columns 1 - 3, respectively.
This answer was originally posted in the question instead of being posted as an answer:
=(Split(Fields!columnx.Value,".")).GetValue(0)
=(Split(Fields!columnx.Value,".")).GetValue(1)
=(Split(Fields!columnx.Value,".")).GetValue(2)

Facing issue when search using Zend_Lucene

I am using zend_lucene for search functionality.I 've the following code,
$doc->addField(Zend_Search_Lucene_Field::Text('categoryName', $result->name));
Here name in "$result->name" is varchar type in Database. Also have some following values like dinesh,kumar123,3333. For testing purpose i have stored number in name field. when i search dinesh , Search comes with exact result but when i use number search, That is 3333 Search has no result. What i done wrong on the code Zend_Search_Lucene_Field::Text.
Is there any way for search number/char/alphanumeric (kumar123) ?
Thanks in Advance
Finally i found by declaring "Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());" and use Zend_Search_Lucene_Field::Keyword instead of Zend_Search_Lucene_Field::Text

sqlite issue using WHERE statement on a varchar field in Objective-C

I have this sql statement SELECT * FROM Language WHERE LanguageCode=? where LanguageCode is a varchar(2).
When I use sqlite3-prepare-v2 on that statement I got SQLITE_ERROR but if I use SELECT * FROM Language WHERE LanguageID=? where LanguageID is the primary key numeric identity field the statement compiles just fine.
Is there any issue filtering by a varchar field using WHERE statement?
Thanks
I think there should be no issue with the where statement by using a varchar field.
Maybe you are having problem with passing the parameter. Try to print to NSLog and see the statement that is executed, and execute it with the sqlite command prompt to see if you have return values.
Be sure your ? is wrapped in single quotes.
SQLite should also give you an error string which tell you why there is an error.
Try to call sqlite3_errmsg and check the error string returned from that call. It should give you a more detailed information about what went wrong.
Claus