我有一个包含XML文件的Blob
列的数据库。
我想检索存储在Blob中的XML标记的值,以便在另一个数据库的各自列中详细说明它们。
那么,如何获取x
标记的值(,如下面的SQL查询中所示)并将其插入到我的其他数据库的x
列中?
SELECT id,
EXTRACTVALUE(Value(p), 'activites/categorieProjet/text()') As categorieProjet,
EXTRACTVALUE(Value(p), 'activites/coutParBeneficiaire/text()') As coutParBeneficiaire,
EXTRACTVALUE(Value(p), 'activites/etat/text()') As etat,
EXTRACTVALUE(Value(p), 'activites/idActivite/text()') As IdActivite,
EXTRACTVALUE(Value(p), 'activites/nbreDeBeneficiaires/text()') As nbreDeBeneficiaires,
EXTRACTVALUE(Value(p), 'activites/nbsession/text()') As nbsession,
EXTRACTVALUE(Value(p), 'activites/nom/text()') As nom,
EXTRACTVALUE(Value(p), 'activites/objectifSpecifique/text()') As objectifSpecifique,
EXTRACTVALUE(Value(p), 'activites/participation/text()') As participation,
EXTRACTVALUE(Value(p), 'activites/publicConcerne/text()') As publicConcerne,
EXTRACTVALUE(Value(p), 'activites/thematique/text()') As thematique,
EXTRACTVALUE(Value(p), 'activites/typeActivite/text()') As typeActivite,
EXTRACTVALUE(Value(p), 'activites/zoneGeographiques[1]') As zoneGeographiques,
EXTRACTVALUE(Value(p), 'activites/zoneGeographiques[2]') As zoneGeographiques,
EXTRACTVALUE(Value(p), 'activites/zoneGeographiques[3]') As zoneGeographiques,
EXTRACTVALUE(Value(p), 'activites/zoneGeographiques[4]') As zoneGeographiques,
EXTRACTVALUE(Value(p), 'activites/zoneGeographiques[5]') As zoneGeographiques,
EXTRACTVALUE(Value(p), 'activites/zoneGeographiques[6]') As zoneGeographiques,
EXTRACTVALUE(Value(p), 'activites/zoneGeographiques[7]') As zoneGeographiques
FROM
artpiece x,
TABLE(XMLSEQUENCE(
EXTRACT(XMLTYPE(blob2clob(x.blob_piece)),'/instructionAC/activites')
))p
where rf_pieg = 'PIEG0034';
答案 0 :(得分:0)
大家好,如果可以帮助某人,我找到了问题的解决方案:
> ** creation of new table
------------------------
create table TestSipac(
categorieProjet varchar2(100),
coutParBeneficiaire varchar2(100),
etat varchar2(100),
IdActivite varchar2(100),
nbreDeBeneficiaires varchar2(100),
nbsession varchar2(100),
objectifSpecifique varchar2(100),
participation varchar2(100),
publicConcerne varchar2(100),
thematique varchar2(100),
typeActivite varchar2(100),
zoneGeographiques1 varchar2(100),
zoneGeographiques2 varchar2(100),
zoneGeographiques3 varchar2(100),
zoneGeographiques4 varchar2(100),
zoneGeographiques5 varchar2(100)
)
***
DECLARE
categorieProjet varchar2(100);
coutParBeneficiaire varchar2(100);
etat varchar2(100);
IdActivite varchar2(100);
nbreDeBeneficiaires varchar2(100);
nbsession varchar2(100);
objectifSpecifique varchar2(300);
participation varchar2(100);
publicConcerne varchar2(100);
thematique varchar2(100);
typeActivite varchar2(100);
zoneGeographiques1 varchar2(100);
zoneGeographiques2 varchar2(100);
zoneGeographiques3 varchar2(100);
zoneGeographiques4 varchar2(100);
zoneGeographiques5 varchar2(100);
BEGIN
for i in (select
EXTRACTVALUE(Value(p), 'activites/categorieProjet/text()') As categorieProjet,
EXTRACTVALUE(Value(p), 'activites/coutParBeneficiaire/text()') As coutParBeneficiaire,
EXTRACTVALUE(Value(p), 'activites/etat/text()') As etat,
EXTRACTVALUE(Value(p), 'activites/idActivite/text()') As IdActivite,
EXTRACTVALUE(Value(p), 'activites/nbreDeBeneficiaires/text()') As nbreDeBeneficiaires,
EXTRACTVALUE(Value(p), 'activites/nbsession/text()') As nbsession,
EXTRACTVALUE(Value(p), 'activites/nom/text()') As nom,
EXTRACTVALUE(Value(p), 'activites/objectifSpecifique/text()') As objectifSpecifique,
EXTRACTVALUE(Value(p), 'activites/participation/text()') As participation,
EXTRACTVALUE(Value(p), 'activites/publicConcerne/text()') As publicConcerne,
EXTRACTVALUE(Value(p), 'activites/thematique/text()') As thematique,
EXTRACTVALUE(Value(p), 'activites/typeActivite/text()') As typeActivite,
EXTRACTVALUE(Value(p), 'activites/zoneGeographiques[1]') As zoneGeographiques1,
EXTRACTVALUE(Value(p), 'activites/zoneGeographiques[2]') As zoneGeographiques2,
EXTRACTVALUE(Value(p), 'activites/zoneGeographiques[3]') As zoneGeographiques3,
EXTRACTVALUE(Value(p), 'activites/zoneGeographiques[4]') As zoneGeographiques4,
EXTRACTVALUE(Value(p), 'activites/zoneGeographiques[5]') As zoneGeographiques5
FROM
artpiece x,
TABLE(XMLSEQUENCE(
EXTRACT(XMLTYPE(blob2clob(x.blob_piece)),'/instructionAC/activites')
))p
where rf_pieg = 'PIEG0034') loop
insert into TestSipac(
categorieProjet,
coutParBeneficiaire,
etat,
IdActivite,
nbreDeBeneficiaires,
nbsession,
objectifSpecifique,
participation,
publicConcerne,
thematique,
typeActivite,
zoneGeographiques1,
zoneGeographiques2,
zoneGeographiques3,
zoneGeographiques4,
zoneGeographiques5)
values ( i.categorieProjet,
i.coutParBeneficiaire,
i.etat,
i.IdActivite,
i.nbreDeBeneficiaires,
i.nbsession,
i.objectifSpecifique,
i.participation,
i.publicConcerne,
i.thematique,
i.typeActivite,
i.zoneGeographiques1,
i.zoneGeographiques2,
i.zoneGeographiques3,
i.zoneGeographiques4,
i.zoneGeographiques5);
end loop;
end;