原文:http://blog.sina.com.cn/s/blog_8333cf8f0100z68t.html
1.ROWIDTOCHAR
语法: ROWIDTOCHAR(rowid)
功能: 将ROWID类型的数值rowid转换为其外部的18字符的字符串表示,在oracle7和oracle8之间有些不一样的地方. ROWIDTOCHAR和CHARTOROWID是两个相反的函数.
SAMPLE:
SQL> select rowid,rowidtochar(rowid) from emp;
ROWID ROWIDTOCHAR(ROWID)
------------------ ------------------
AAAMgzAAEAAAAAgAAO AAAMgzAAEAAAAAgAAO
AAAMgzAAEAAAAAgAAA AAAMgzAAEAAAAAgAAA
AAAMgzAAEAAAAAgAAB AAAMgzAAEAAAAAgAAB
AAAMgzAAEAAAAAgAAC AAAMgzAAEAAAAAgAAC
AAAMgzAAEAAAAAgAAD AAAMgzAAEAAAAAgAAD
AAAMgzAAEAAAAAgAAE AAAMgzAAEAAAAAgAAE
2.CHARTOROWID
语法:CHARTOROWID(string)
功能描述:把包含外部格式的ROWID的CHAR或VARCHAR2数值转换为内部的二进制格式.参数string必须是包含外部格式的ROWID的18字符的字符串.oracle7和 oracle8中的外部格式是不同的.CHARTOROWID是ROWIDTOCHAR的反函数.
SAMPLE:
SQL> select rowid,chartorowid('ssssffffgggghhhhrr'),ename from emp;
ROWID CHARTOROWID('SSSSF..) ENAME
------------------ ------------------ ----------
AAAMgzAAEAAAAAgAAA AsssffABiAAAhhhBrr SMITH
AAAMgzAAEAAAAAgAAB AsssffABiAAAhhhBrr ALLEN
AAAMgzAAEAAAAAgAAC AsssffABiAAAhhhBrr WARD
AAAMgzAAEAAAAAgAAD AsssffABiAAAhhhBrr JONES
AAAMgzAAEAAAAAgAAE AsssffABiAAAhhhBrr MARTIN
AAAMgzAAEAAAAAgAAF AsssffABiAAAhhhBrr BLAKE
AAAMgzAAEAAAAAgAAG AsssffABiAAAhhhBrr CLARK
3.应用--根据查询出的ROWID更新删除表记录
--查询
SELECT ROWIDTOCHAR (wocardinfo.ROWID) rowidnum, wocardinfo.*
FROM info.t_ci_wocardinfo wocardinfo
WHERE wocardinfo.svcnum = '15611312368'
AND wocardinfo.preferencetype = '120027'
AND wocardinfo.cardnum IS NULL
AND ROWNUM = 1;
--更新
UPDATE info.t_ci_wocardinfo
SET remark = '发送成功'
WHERE ROWIDTOCHAR (ROWID) = 'AAA4JOAE6AAALyCAAA';
--删除
DELETE FROM info.t_ci_wocardinfo
WHERE ROWIDTOCHAR (ROWID) = 'AAA4JOAE6AAALyCAAA';