oracle 插入问题   使用 PL/SQL 开发人员

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8790336/
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 00:32:04  来源:igfitidea点击:

Problems inserting   with PL/SQL Developer

oraclexsltplsqlwhitespacehtml-entities

提问by Herter

I have the following script that I want to insert into a table, but I'm having some issues with it.

我有以下脚本要插入到表格中,但我遇到了一些问题。

declare
    v_xslt9 varchar2(32767) := '<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="UTF-8" indent="yes"/> <xsl:template name="Template"> <xsl:text>K?re </xsl:text> <xsl:value-of select="/nameValueMap/entry[string=''FIRST_NAME'']/string[2]"/> <xsl:text>&nbsp;</xsl:text> <xsl:value-of select="/nameValueMap/entry[string=''LAST_NAME'']/string[2]"/></xsl:template> </xsl:stylesheet>'
begin
    insert into XSLT values ('','Note',sysdate,v_xslt9,sysdate,'T','')
end;

The part of interest is the following

感兴趣的部分如下

<xsl:text>&nbsp;</xsl:text>

I'm using PL/SQL Developer and when I run the script above it recognises

我正在使用 PL/SQL Developer,当我运行上面的脚本时,它会识别

&nbsp;

as an entity and I then have to type in what value I want in it. What I want is a simple whitespace within the XSL such that the first and last name will be separated. I've tried all suggestions from the following link: orafaq- I just cant get it to work. Either it fails when I try to insert or it fails when I extract the data.

作为一个实体,然后我必须输入我想要的值。我想要的是 XSL 中的一个简单空格,以便将名字和姓氏分开。我已经尝试了以下链接中的所有建议:orafaq- 我只是无法让它工作。要么在我尝试插入时失败,要么在我提取数据时失败。

Is there some easy way of inserting a whitespace in the XSL?

是否有一些简单的方法可以在 XSL 中插入空格?

回答by Vincent Malgrat

Use a command windowinstead of a SQL window to run scripts in PL/SQL Developer. To transform one kind of window into another type, just right-click anywhere in the window and select "Change Window to" => "Command Window".

在 PL/SQL Developer 中使用命令窗口而不是 SQL 窗口来运行脚本。要将一种窗口转换为另一种类型,只需右键单击窗口中的任意位置并选择“将窗口更改为”=>“命令窗口”。

Then run your script as in SQL*Plus -- in this case with SET DEFINE OFFas the first line.

然后像在 SQL*Plus 中一样运行您的脚本——在本例中SET DEFINE OFF作为第一行。

回答by smnbbrv

use

'<xsl:text>'||'&'||'nbsp;</xsl:text>'

it will solve problem everywhere and forever, and as well as for you - for every future user.

它将永远解决任何地方的问题,并且为您 - 为每个未来的用户解决问题。

Just isolate the symbol

只需隔离符号

回答by Jon Heller

<xsl:text>&&nbsp;</xsl:text>

From the PL/SQL Developer manual:

来自 PL/SQL Developer 手册:

If you wish to use an ampersand in the SQL text that should not be interpreted as a substitution variable, use a double ampersand instead.

如果您希望在不应被解释为替换变量的 SQL 文本中使用与号,请改用双与号。

回答by Devon_C_Miller

Give this a try:

试试这个:

'<xsl:text>'||unistr('
'<xsl:text>'||chr(38)||'nbsp;</xsl:text>'
A0')||'</xsl:text>'

This unistr('\00A0')function returns the Unicode NO-BREAK SPACE

unistr('\00A0')函数返回 UnicodeNO-BREAK SPACE

Or, if you want the entity itself, you can try this:

或者,如果你想要实体本身,你可以试试这个:

##代码##

The chr(38)returns a literal ampersand without trying to prompt for input.

chr(38)不尝试提示输入返回一个文字符号。