Posts

Showing posts with the label type-conversion

ORA-06502 error for casting string to number (PL/SQL)

Image
Clash Royale CLAN TAG #URR8PPP ORA-06502 error for casting string to number (PL/SQL) I have variable: suma NUMBER(7,2) := 0; I want to execute the following process: suma := suma+cast(substr(jmbg,i,1) as number)*7; But when I run this process it shows the following error message: ORA-06502: PL/SQL: numeric or value error: character to number conversion error. It has problem with this line, so I have tried run this process with TO_NUMBER functions, but it did the same. How can I convert the substring to number without error message? You have to know the format in which the string represents the number; for example, does the string contain leading or trailing zeros? how many decimal digits, what is the decimal separator?, ... Once you know these things, we can find the appropriate format mask to use the to_number – Aleksej 56 mins ago ...

Converting Java escape characters & emojis in a sentence with Python

Image
Clash Royale CLAN TAG #URR8PPP Converting Java escape characters & emojis in a sentence with Python For example, if I was given the following string: temp = "That looks great ud83dudc4c Good Job!" How can I convert it so that it either shows the actual emoji (👌) or the textual meaning (OK HAND SIGN)? Final result should like: temp = "That looks great 👌 Good Job!" or temp = "That looks great :OK HAND SIGN: Good Job!" I have tried using the emoji library in Python but it appears to only support Python escape characters. Is there any way to convert Java escape characters to Python escape characters? Thanks in advance! 1 Answer 1 No need for external libraries, use the built-in str function str.decode() str print temp.decode('unicode-escape') or tell python that your string contains unicode characters by making it a string literal prepending it with u'...

Null case with concatenation

Image
Clash Royale CLAN TAG #URR8PPP Null case with concatenation I have the below situation in my project: @num1 is an integer 1. when @num1 = null/' ' then output should be space(0) 2. else if it is single digit, concatenate with '0' in the front. If double digit, show as it is. Example: 1. @num1 = null/'' output: space(0) 2. @num1 = '0' output:00 3. @num1 = '9' output:09 4. @num1 = '11' output = 11 My code: declare @num1 int = null select @num1, CASE WHEN cast(@num1 as varchar) = null THEN space(0) ELSE RIGHT(CONCAT('00', CONVERT(VARCHAR,@num1)),2) END as 'output' This code works fine for examples 2,3,4. But when I set @num1 = null, the output still shows as '00'. desired output should be space(0)/space. Missing some conversion here. Any help? By clicking "Post Your Answer", you acknowledge that you have read our updated terms of ser...

Proper export from txt to html in Powershell

Image
Proper export from txt to html in Powershell I have a script, which stores output in txt and I need to convert this output into html. The format of txt file is following: This file is generated for commits from: 2018-07-15 to: 2018-07-21 for branch: repositories contains: mineq =============somerepo============= Branch is development 1234567 Merge pull request #1227 from qp-10421_service_version_information 1234567 Merge branch 'development' into qp-10421_service_version_information 1234567 merged with development 1234567 QP-2071: update packages =============Someotherrepo============= Branch is development =============MineqConfigApi============= Branch is development 1234567 QP-10881 Remove WindowsVpnSettings service 1234567 Merge pull request #9 from quarti/QP-10881 1234567 QP-10881 Set SshClient ConnectionTimeout 10 minutes and Change sql query to skip Deleted Assets To send this text into html, I use following code: $SourceFile = "$env:WORKSPACEcommits.txt" $Ta...