473,385 Members | 1,927 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

SQL function for HEX input

Hi,

I am looking for an SQL function which does exactly the same like the
x'<hex-string>' in an insert.

Background:
I want to "translate" a hexadecimal string (not number) with a length
of 32 into a CHAR (16) FOR BIT DATA
in a way that the hex() function of that string returns the original
(hex) text.

The function should be able to handle hex(00) exactly the same way the
x'<hex-string>' does it.
Any ideas?

Thanks in advance

Michael
Feb 5 '08 #1
1 6664
On Feb 5, 8:36 am, globomike <M_Tiefenbac...@gmx.dewrote:
Hi,

I am looking for an SQL function which does exactly the same like the
x'<hex-string>' in an insert.

Background:
I want to "translate" a hexadecimal string (not number) with a length
of 32 into a CHAR (16) FOR BIT DATA
in a way that the hex() function of that string returns the original
(hex) text.

The function should be able to handle hex(00) exactly the same way the
x'<hex-string>' does it.

Any ideas?

Thanks in advance

Michael
I don't think there is a predefined function doing that. On the other
hand you can easily create one your self. Something along the lines
of:

create function unhex (s varchar(100))
returns varchar(100)
return
with iter (res, n) as (
values (cast(chr(16*int(substr(s,1,1)) + int(substr(s,
2,1))) as varchar(100)), 0)
union all
select rtrim(res) ||
chr(16*int(substr(s,n+3,1)) + int(substr(s,n
+4,1))), n+2
from iter
where n+2 < length(s) and n < 100

) select res from iter
where n = (select max(n) from iter) @

Not tested ;-)
HTH
/Lennart
Feb 5 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Øyvind Isaksen | last post by:
Hi! I have made a function calles "send()". When I click a button, I want the function to be prosessed. This is the code that I have made, but it dont work: <%function send()
2
by: Jerry | last post by:
With the following code I am trying to simply set and display the current date time in an input box. The input box will not accept a variable that contains any spaces (i.e., a space between date and...
2
by: bbxrider | last post by:
i'm trying to pass a form object to a function to validate the forms user input when i try to access a forms properties-like .elements there is no response from the function and no error msg, i...
6
by: Hoschi-Ingo | last post by:
Hello NG, I want to write a generic function to validate data in input items. For this I want to pass a refernce to the object which calls this function to read out the and modify it if...
0
by: Telvanni | last post by:
hey I have this function that's supposed to be allowed to take in a number in a 0.00 format and transfer it into the same number but without the decimal point void Money::Input(istream filename)...
6
by: rh0dium | last post by:
Hi Experts!! I am trying to get the following little snippet to push my data to the function func(). What I would expect to happen is it to print out the contents of a and loglevel. But it's...
10
by: rh0dium | last post by:
Hi all, Below is a basic threading program. The basic I idea is that I have a function which needs to be run using a queue of data. Early on I specified my function needed to only accept basic...
7
by: rynato | last post by:
I have a lengthy 'markup.php' file which consists of functions which take as input the various attribute values of HTML tags and spit out the HTML tag. My problem is that the function for <inputis...
12
by: Tarique | last post by:
I have tried to restrict the no. of columns in a line oriented user input.Can anyone please point out potential flaws in this method? btw.. 1.I have not used dynamic memory allocation because...
0
by: bytesFTW99 | last post by:
i have this, $(function() { $('#input').autocomplete('test.php', {json: true}); }); that bring back values from the database here is my php section
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.