Hope someone can help me out:
I need to write a code that will tell me if a number contains only the digit 9.
For example: 9, 99, 999, 9999999999
I think you got it :)
Thanks!
This works for both varchar and any integer:
where trim(trailing '9' from col) = ''
Fails for decimals, but could easily be modified.
Related
I'm trying to delete only the first zero from the values of a field which now are: 00,01,02,03 etc and I'm using this function: string_trim['0', begin].
The problem with it is that it works for all the values but not for 00, since it removes everything and in the results I receive a NULL value.
Is there any other option in order to remove only the first zero?
Thank you.
Although You did not mention it in which programming language you are asking php or mysql.But below is the hint for your issue.
Split this string into array by comma ( , ).
loop through each array and remove first zero ( right(1) or trim(STRing , '0') )
Then merge array into string by comma separated.
For DataStage this would be a solution for a Transformer stage
IF left(field,1) = "0"
THEN file[2,len(field) - 1)]
ELSE field
I wanted to count No of Special Characters(Non ASCII) inserted into a Column.
Below is the code that i wrote ,which is not working as expected,
SELECT count(BEST_ADDR_1) Inv_cnt
FROM DP_VEDW_SRC_MDB_NGN.ACCT_SUM_VIEW
WHERE BEST_ADDR_1 NOT LIKE '%[^a-z0-9A-Z]%')
Thanks in Advance
Teradata does't support character ranges in LIKE. but you can use RegExp_Replace.
Remove the non-ASCII characters and check the remaining character length
SUM(Char_Length(RegExp_Replace(BEST_ADDR_1, '[a-z0-9]', '', 1, 0, 'i')))
I am having a bit of an issue in our code.
There is a procedure that creates a dynamic trigger.
However, it creates a cursor that is longer then 30 characters.
I know what variable is making those cursors.
Does anyone know a way to limit the characters to a max. of 30?
Like, if this variable is longer then 30 characters, then cut it off.
I could find an expample, so I hope that is even possible.
You can chop off characters with substr(variable, 1, 30).
For instance:
declare
cursor_name varchar(100);
begin
cursor_name := '012345678901234567890123456789ABCDE';
cursor_name := substr(cursor_name, 1, 30);
dbms_output.put_line(cursor_name);
end;
... will output:
012345678901234567890123456789
pOutputIndexFile is "G:\new1.dat"
fileNumber is "2.dat"
pOutputIndexFile->replace(QRegExp("\\[0-9]{1,1}\\.dat"),fileNumber);
this doesn't change my string to "G:\new2.dat". How can I do this?
I got it fine with
pOutputIndexFile->replace(QRegExp("\\d\\d?.dat"),fileNumber);
It can be done by:
pOutputIndexFile->replace(QRegExp("\\d{1,10}.dat"),fileNumber);
\d{1,10} means match a sequence of digits that contains at least one digit but no more than ten.
So even when pOutputIndexFile is "G:\new964.dat" and fileNumber is "965.dat" the result is:
"G:\new965.dat"
Your regular expression is looking for files with the extension idx, not dat. Since it doesn't find one, nothing is replaced.
You can try with this :
pOutputIndexFile->replace(QRegExp("[0-9]{1}\.dat"),fileNumber);
[0-9] : means a number
{1} : means exactly one char
\. : protect the .
dat : dat
Can you please help me to understand this error in scan().
I believe the error is in what=list(.) If so, can someone help clarify?
It looks like it is expecting the list to contain only real numbers, but instead the list contains real numbers (0) and strings ("").
If you would like to give an empty value for a number, instead of "" try using NA. So the line would be
what=list(NA, NA, 0, 0, 0)