2017-11-07 9 views
0

XMLファイルを含むBlob列のデータベースがあります。 このデータベースのBlobに格納されているXMLタグの値を取得して、別のデータベースのそれぞれの列でXMLタグの値を詳細に調べたいとします。列からXML値を抽出して別のデータベースに挿入する

だから、どのように私はxタグの値を取得する(以下のSQLクエリに示すように)と私の他のデータベースのx列に挿入することができますか?

enter image description here

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

ハロー、それが誰かを助けることができる場合、私は私の問題への解決策を見つけた誰も:

> ** 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; 
関連する問題