如何更新包含 HTML 代码的 Oracle 中的 BLOB 列

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18997468/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 01:57:00  来源:igfitidea点击:

How to update BLOB column in Oracle which contains HTML code

oracleoracle11g

提问by Java Beginner

I want to update a BLOB column in Oracle DB with HTML. I am using Oracle Oracle Database 11g Release 11.2.0.3.0

我想用 HTML 更新 Oracle DB 中的 BLOB 列。我使用的是 Oracle Oracle Database 11g 版本 11.2.0.3.0

The column contains HTML code which would be used in front end in JSP Servlets. The content of cell should be updated with below code

该列包含将在 JSP Servlet 的前端使用的 HTML 代码。应使用以下代码更新单元格的内容

<table width="100%" border="0" cellspacing="0">
 <tbody>
     <tr>
       <td height="130">&nbsp;</td>
     </tr>
     <tr>
       <td height="130">&copy; 2013</td>
     </tr>
 </tbody>
</table>

The above code is formatted.The whole thing is single line.Now when I run a update query as below its showing the message

上面的代码是格式化的。整个事情是单行的。现在当我运行更新查询时,如下所示,它显示了消息

  UPDATE TemplateTbl
     SET TemplateConetent = (RAWTOHEX (UTL_RAW.cast_to_raw ('<table width="100%" border="0" cellspacing="0"><tbody><tr><td height="130">&nbsp;</td></tr><tr><td height="130">&copy; 2013</td></tr></tbody></table>')))
   WHERE TemplateId = TL2600

Now oracle is asking for variable values because of © and   as below

现在 oracle 要求变量值,因为 © 和如下

enter image description here

在此处输入图片说明

I have tried using underscore, Backslash and percentage in front of &copy and &nbsp. But nothing worked. How do I solve this issue?

我曾尝试在 © 和   前面使用下划线、反斜杠和百分比。但没有任何效果。我该如何解决这个问题?

回答by sunysen

1、sql plus or plsql command window

1、sql plus或plsql命令窗口

set define off;

UPDATE TemplateTbl
     SET TemplateConetent = (RAWTOHEX (UTL_RAW.cast_to_raw ('<table width="100%" border="0" cellspacing="0"><tbody><tr><td height="130">&nbsp;</td></tr><tr><td height="130">&copy; 2013</td></tr></tbody></table>')))
   WHERE TemplateId = TL2600

回答by Michael-O

HTML ist plain text, use an (N)CLOB for that.

HTML ist 纯文本,为此使用 (N)CLOB。