packages that convert hex to dec
501645Mar 25 2006 — edited Mar 27 2006hi,
i have a table posicional which has large object on it..the column grarep(graphical representation) and attr_posn contains hexadecimal value of coordinates that is used in automated mapping
SQL>DESCRIBE POSICIONAL;
Name Null Type
------- ----- ----------
class_id NUMBER(10)
class_memb NUMBER(10)
codigo NUMBER(10)
simbolo NUMBER(10)
xmin NUMBER(10)
ymin NUMBER(10)
xmax NUMBER(10)
grarep BLOB
attr_posn BLOB
usuario VARCHAR2(30)
fecha DATE
texto VARCHAR2(50)
--Once i query grarep and attr_posn
SQL>SELECT grarep from posicional;
Column or attribute type cannot be displayed by SQL
--I made a function blobtochar to be able to view the data on grarep and attr_posn
CREATE OR REPLACE FUNCTION Blobtochar (field_name IN BLOB)
RETURN VARCHAR2 IS
OutputStr VARCHAR2(32767);
-- OutputStr LONG;
AmtToRead NUMBER:=4000;
Position NUMBER:=1;
LENGTH NUMBER;
BEGIN
LENGTH := DBMS_LOB.GETLENGTH(field_name);
LOOP
OutputStr := OutputStr || DBMS_LOB.SUBSTR(field_name, AmtToRead, Position);
Position := Position + AmtToRead;
LENGTH := LENGTH - 4000;
EXIT WHEN LENGTH < 4000;
END LOOP;
RETURN OutputStr;
END Blobtochar;
/
SQL>SELECT blobtochar(grarep) from posicional
--now i can view the data in grarep..
--for example
SQL>SELECT class_memb, blobtochar(grarep) FROM posicional WHERE class_memb=111025648;
blobtochar(grarep)
-----------------------------
00000001000000010000000606D4E833074B69EC06D4E91F074CO18406D50C58074C031E
HERES MY QUESTION,
1.how can i convert this hexadecimal coordinates so that when i query, a decimal value will appear instead of hex. this hex values are the lines in the map.heres the info about the hex value above. we need to parse or cut the hex into 8..
00000001
00000001
00000006 ==>number of coordinates(ranging from 1-F, this example means 6)
06D4E833 ==> X1
074B69EC ==> Y1
06D4E91F ==> X2
074CO184 ==> Y2
06D50C58 ==> X3
074C031E ==> Y3
connecting 4 coordinates/2points/ will make 1 line
connecting 6 coordinates/3points/ will make 2 lines
connecting 8 coordinates/4points/ will make 3 lines
connecting 10 coordinates/5points/ will make 4lines
connecting 12 coordinates/6points/ will make 5lines
connecting 14 coordinates/7points/ will make 6lines
and so on..
In the example above there are 6 coordinates
point(X1Y1), point(X2Y2), and point(X3Y3). Connecting all 3 points will make 2 lines). computing the total length by phytagorean therorem
LINE1 length=square root of X2-X1 squared + Y2-Y1 squared
LINE2 length=square root of X3-X2 squared + Y3-Y2 squared
total length = LINE1 + LINE2
how can i implement this so that when i query specific grarep and attr_posn, a computed total length in decimal value will appear instead of hex..thanks