<legend id='dHxQk'><style id='dHxQk'><dir id='dHxQk'><q id='dHxQk'></q></dir></style></legend>
  • <i id='dHxQk'><tr id='dHxQk'><dt id='dHxQk'><q id='dHxQk'><span id='dHxQk'><b id='dHxQk'><form id='dHxQk'><ins id='dHxQk'></ins><ul id='dHxQk'></ul><sub id='dHxQk'></sub></form><legend id='dHxQk'></legend><bdo id='dHxQk'><pre id='dHxQk'><center id='dHxQk'></center></pre></bdo></b><th id='dHxQk'></th></span></q></dt></tr></i><div id='dHxQk'><tfoot id='dHxQk'></tfoot><dl id='dHxQk'><fieldset id='dHxQk'></fieldset></dl></div>

      1. <small id='dHxQk'></small><noframes id='dHxQk'>

        <tfoot id='dHxQk'></tfoot>
          <bdo id='dHxQk'></bdo><ul id='dHxQk'></ul>

        在 PLSQL 中转义单引号

        时间:2023-09-17

                <small id='fZuHK'></small><noframes id='fZuHK'>

                  <tbody id='fZuHK'></tbody>
                <tfoot id='fZuHK'></tfoot>

                <i id='fZuHK'><tr id='fZuHK'><dt id='fZuHK'><q id='fZuHK'><span id='fZuHK'><b id='fZuHK'><form id='fZuHK'><ins id='fZuHK'></ins><ul id='fZuHK'></ul><sub id='fZuHK'></sub></form><legend id='fZuHK'></legend><bdo id='fZuHK'><pre id='fZuHK'><center id='fZuHK'></center></pre></bdo></b><th id='fZuHK'></th></span></q></dt></tr></i><div id='fZuHK'><tfoot id='fZuHK'></tfoot><dl id='fZuHK'><fieldset id='fZuHK'></fieldset></dl></div>
                  <bdo id='fZuHK'></bdo><ul id='fZuHK'></ul>

                • <legend id='fZuHK'><style id='fZuHK'><dir id='fZuHK'><q id='fZuHK'></q></dir></style></legend>
                  本文介绍了在 PLSQL 中转义单引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我希望 PLSQL 生成如下字符串:

                  I want PLSQL to generate strings like:

                  COMMENT ON COLUMN TABLE.COLUMN IS 'comment from database';
                  

                  我的解决方案是:

                  declare
                    str_comment varchar2(4000);
                  begin
                    for rec in (select table_name, column_name, description from description_table)
                    loop
                      str_comment:='COMMENT ON COLUMN '||rec.table_name||'.'||rec.column_name||'  IS '''||rec.description||'''; ' ;
                      dbms_output.put_line(str_comment);
                    end loop;
                  end;
                  

                  rec.description 中不包含单个 qout 时,输出是可以的.否则需要转义信.我应该如何实施?

                  Output is OK when it doesn't contain single qoutes in rec.description. Otherwise there is need for escape letter. How should I implement it?

                  OK 输出行(它有转义字母以保留单个 qoute):

                  OK output line (It's has escape letter to preserve single qoute):

                  COMMENT ON COLUMN TABLE1.COLUMN1_LV  IS 'It''s secret';
                  

                  NOT NOK 输出行,因为没有添加单引号的转义字母并且不会编译:

                  NOT NOK output line because no escape letter for single quote added and doesn't compile:

                  COMMENT ON COLUMN TABLE1.COLUMN1_LV  IS 'It's secret';
                  

                  我的解决方案是不检查描述是否包含单引号.我只是在生成 COMMENT ON 字符串之前用两个单引号替换源(描述)列的单引号,然后我 ROLLBACK.

                  My solution is not to check if description contains single quotes. I just replace source (description) column's single quote by two single quotes before generating COMMENT ON strings and then I ROLLBACK.

                  有更好的解决方案吗?

                  推荐答案

                  我经常做这类事情(通常生成插入/更新语句).

                  I do this sort stuff a fair bit (usually generating insert/update statements).

                  你只需要使用replace函数把所有的'变成''.即更改为:

                  You just need to use the replace function to turn all the ' into ''. i.e. Change it to:

                  str_comment:='COMMENT ON COLUMN '||rec.table_name||'.'||rec.column_name
                              ||' IS '''||REPLACE( rec.description,'''','''''')||'''; ' ;
                  

                  这篇关于在 PLSQL 中转义单引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:当我在 JDBC 应用程序中调用 PreparedStatement.cancel() 时,它是否真的在 Oracle 下一篇:获取oracle db中最后插入记录的ID

                  相关文章

                  <i id='lsKVo'><tr id='lsKVo'><dt id='lsKVo'><q id='lsKVo'><span id='lsKVo'><b id='lsKVo'><form id='lsKVo'><ins id='lsKVo'></ins><ul id='lsKVo'></ul><sub id='lsKVo'></sub></form><legend id='lsKVo'></legend><bdo id='lsKVo'><pre id='lsKVo'><center id='lsKVo'></center></pre></bdo></b><th id='lsKVo'></th></span></q></dt></tr></i><div id='lsKVo'><tfoot id='lsKVo'></tfoot><dl id='lsKVo'><fieldset id='lsKVo'></fieldset></dl></div>

                    1. <tfoot id='lsKVo'></tfoot>
                    2. <legend id='lsKVo'><style id='lsKVo'><dir id='lsKVo'><q id='lsKVo'></q></dir></style></legend>
                    3. <small id='lsKVo'></small><noframes id='lsKVo'>

                        <bdo id='lsKVo'></bdo><ul id='lsKVo'></ul>