将BLOB(xml)值插入Oracle DB

时间:2022-09-23 08:43:05

I am using Oracle 11g, I have to Insert the BLOB values which are in xml form in single sql query into database, How can I can I Achive this.

我使用的是Oracle 11g,我必须将单个sql查询中的xml格式的BLOB值插入到数据库中,我怎样才能实现这一点。

Below query I am trying out:

以下查询我正在尝试:

insert into CONNECTION_ACCOUNTS (SERVICE_SPECIFIC_DATA_V) values 
( xmltype('<?xml version="1.0" encoding="UTF-8"?>
<connection-specific>
  <connection value="0">
    <chargingGroupDetails>
      <groupInfo discountPercentage="10000000" classType="1" groupId="1001"/>
    </chargingGroupDetails>
  </connection>
</connection-specific') )
where account_id_n=1462;

But for some reason this is not working? first of all is it possible to do like this?

但由于某种原因,这不起作用?首先是可以这样做吗?

some reason it is not working.. Can somebody help me.. How Can I do this ?

某些原因,它不起作用..有人可以帮助我..我怎么能这样做?

1 个解决方案

#1


0  

Change your statement to:

将您的陈述更改为:

insert into connection_accounts
   (account_id
   ,service_specific_data_v)
values
   (1462
   , '<?xml version="1.0" encoding="UTF-8"?>
<connection-specific>
  <connection value="0">
    <chargingGroupDetails>
      <groupInfo discountPercentage="10000000" classType="1" groupId="1001"/>
    </chargingGroupDetails>
  </connection>
</connection-specific')

Or if there is already a record for that specific account_id to:

或者,如果该特定account_id已有记录,则:

update connection_accounts
   set service_specific_data_v = '<?xml version="1.0" encoding="UTF-8"?>
    <connection-specific>
      <connection value="0">
        <chargingGroupDetails>
          <groupInfo discountPercentage="10000000" classType="1" groupId="1001"/>
        </chargingGroupDetails>
      </connection>
    </connection-specific'
 where account_id = 1462;

#1


0  

Change your statement to:

将您的陈述更改为:

insert into connection_accounts
   (account_id
   ,service_specific_data_v)
values
   (1462
   , '<?xml version="1.0" encoding="UTF-8"?>
<connection-specific>
  <connection value="0">
    <chargingGroupDetails>
      <groupInfo discountPercentage="10000000" classType="1" groupId="1001"/>
    </chargingGroupDetails>
  </connection>
</connection-specific')

Or if there is already a record for that specific account_id to:

或者,如果该特定account_id已有记录,则:

update connection_accounts
   set service_specific_data_v = '<?xml version="1.0" encoding="UTF-8"?>
    <connection-specific>
      <connection value="0">
        <chargingGroupDetails>
          <groupInfo discountPercentage="10000000" classType="1" groupId="1001"/>
        </chargingGroupDetails>
      </connection>
    </connection-specific'
 where account_id = 1462;