Oracle
 sql >> Base de Dados >  >> RDS >> Oracle

Substituir ou remover várias linhas de texto no procedimento armazenado oracle


Se for texto simples e não XML , então você pode simplesmente usar REPLACE .

Por exemplo,
SQL> WITH DATA AS
  2    (SELECT '
  3  <COLLECT_PARALLELGRAMMAR1>global.grxml</COLLECT_PARALLELGRAMMAR1>
  4  <COLLECT_INPUTMODES>voice dtmf</COLLECT_INPUTMODES>
  5  <CONF_INPUTMODES>dtmf</CONF_INPUTMODES>
  6  </ROW>
  7  </properties>
  8  <?xml version="1.0"?>
  9  <properties>
 10  <ROW>
 11  <MODULE_NAME>main_menu_phone</MODULE_NAME>
 12  <MODULE_DESCRIPTION>Main Menu for Customers with silver membership</MODULE_DESCRIPTION>
 13  <MODULE_TYPE>phone</MODULE_TYPE>' str
 14    FROM dual
 15    )
 16  SELECT REPLACE(str, '</properties>
 17  <?xml version="1.0"?>
 18  <properties>', '') new_str
 19  FROM data;

NEW_STR
--------------------------------------------------------------------------------------------

<COLLECT_PARALLELGRAMMAR1>global.grxml</COLLECT_PARALLELGRAMMAR1>
<COLLECT_INPUTMODES>voice dtmf</COLLECT_INPUTMODES>
<CONF_INPUTMODES>dtmf</CONF_INPUTMODES>
</ROW>

<ROW>
<MODULE_NAME>main_menu_phone</MODULE_NAME>
<MODULE_DESCRIPTION>Main Menu for Customers with silver membership</MODULE_DESCRIPTION>
<MODULE_TYPE>phone</MODULE_TYPE>