I am having problems with parsing XML containing name-space.
This is my XML structure (snipped, with modified data):
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:camt.053.001.02 ./camt.053.001.02.xsd">
<BkToCstmrStmt>
<Stmt>
<Ntry>
<Amt Ccy="EUR">0.0</Amt>
<CdtDbtInd>CCCC</CdtDbtInd>
<Sts>BBBB</Sts>
<BookgDt>
<Dt>2011-01-01</Dt>
</BookgDt>
<ValDt>
<Dt>2011-01-01</Dt>
</ValDt>
<AcctSvcrRef>325569685ASDAS</AcctSvcrRef>
<BkTxCd>
<Prtry>
<Cd>NOTPROVIDED</Cd>
</Prtry>
</BkTxCd>
<NtryDtls>
<TxDtls>
<Refs>
<EndToEndId>DD545454545-54545-54</EndToEndId>
<TxId>46545445G5GG54DD5S</TxId>
</Refs>
<RltdPties>
<Dbtr>
<Nm>TEST</Nm>
<PstlAdr>
<Ctry>JJ</Ctry>
<AdrLine>TEST ADD</AdrLine>
<AdrLine>TEST ADD2</AdrLine>
</PstlAdr>
</Dbtr>
<DbtrAcct>
<Id>
<IBAN>000000000000000</IBAN>
</Id>
</DbtrAcct>
<Cdtr>
<Nm>TEST NAME</Nm>
<PstlAdr>
<Ctry>JJ</Ctry>
<AdrLine>TEST ADD3</AdrLine>
<AdrLine>TEST ADD4</AdrLine>
</PstlAdr>
</Cdtr>
<CdtrAcct>
<Id>
<IBAN>22222222222222</IBAN>
</Id>
</CdtrAcct>
</RltdPties>
<Purp>
<Cd>IIII</Cd>
</Purp>
<RmtInf>
<Strd>
<CdtrRefInf>
<Ref>GG56565656565656</Ref>
</CdtrRefInf>
<AddtlRmtInf>TEST TEST 123</AddtlRmtInf>
</Strd>
</RmtInf>
<RltdDts>
<IntrBkSttlmDt>2011-01-01</IntrBkSttlmDt>
</RltdDts>
</TxDtls>
</NtryDtls>
</Ntry>
</Stmt>
</BkToCstmrStmt>
</Document>
This is the code i use that works if root element is without namespace ():
DECLARE
l_clob CLOB;
l_bfile BFILE := BFILENAME('XML_IMPORT', 'test_import.xml');
l_dest_offset INTEGER := 1;
l_src_offset INTEGER := 1;
l_bfile_csid NUMBER := 0;
l_lang_context INTEGER := 0;
l_warning INTEGER := 0;
l_xml xmltype;
BEGIN
DBMS_LOB.createtemporary (l_clob, TRUE);
DBMS_LOB.fileopen(l_bfile, DBMS_LOB.file_readonly);
DBMS_LOB.loadclobfromfile (
dest_lob => l_clob,
src_bfile => l_bfile,
amount => DBMS_LOB.lobmaxsize,
dest_offset => l_dest_offset,
src_offset => l_src_offset,
bfile_csid => l_bfile_csid ,
lang_context => l_lang_context,
warning => l_warning);
DBMS_LOB.fileclose(l_bfile);
l_xml := xmltype(l_clob);
BEGIN
FOR r IN (
SELECT ExtractValue(Value(p),'/Ntry/Amt/text()') as TEMP_COL1
,ExtractValue(Value(p),'/Ntry/Amt/#Ccy/text()') as TEMP_COL2
,ExtractValue(Value(p),'/Ntry/ValDt/Dt/text()') as TEMP_COL3
,ExtractValue(Value(p),'/Ntry/BookgDt/Dt/text()') as TEMP_COL4
FROM TABLE(XMLSequence(Extract(l_xml,'/Document/BkToCstmrStmt/Stmt/Ntry'))) p
)
LOOP
dbms_output.put_line('Some value 1: ' || r.TEMP_COL1);
dbms_output.put_line('Some value 2: ' || r.TEMP_COL2);
dbms_output.put_line('Some value 3: ' || r.TEMP_COL3);
dbms_output.put_line('Some value 4: ' || r.TEMP_COL4);
END LOOP;
END;
END;
I would like to know how to modify my code to work with name space.
Google provided few examples but so far i had no luck implementing them into my solution.
I believe you need to pass the namespace to both the Extract() and ExtractValue() functions e.g.
FOR r IN (
SELECT ExtractValue(Value(p),'/Ntry/Amt/text()', 'xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.02"') as TEMP_COL1
,ExtractValue(Value(p),'/Ntry/Amt/#Ccy','xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.02"') as TEMP_COL2
,ExtractValue(Value(p),'/Ntry/ValDt/Dt/text()','xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.02"') as TEMP_COL3
,ExtractValue(Value(p),'/Ntry/BookgDt/Dt/text()','xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.02"') as TEMP_COL4
FROM TABLE(XMLSequence(Extract(l_xml,'/Document/BkToCstmrStmt/Stmt/Ntry', 'xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.02"'))) p
)
LOOP
dbms_output.put_line('Some value 1: ' || r.TEMP_COL1);
dbms_output.put_line('Some value 2: ' || r.TEMP_COL2);
dbms_output.put_line('Some value 3: ' || r.TEMP_COL3);
dbms_output.put_line('Some value 4: ' || r.TEMP_COL4);
END LOOP;
I don't think there is a way to specify a default namespace for the ExtractValue function, so my personal preference would be to do something like this instead which avoids repeatedly declaring the namespace:
FOR r IN (
SELECT p.temp_col1,
p.temp_col2,
p.temp_col3,
p.temp_col4
FROM xmltable(
--define a default namespace to be used for all values
xmlnamespaces(
DEFAULT 'urn:iso:std:iso:20022:tech:xsd:camt.053.001.02'
),
--define an xpath expression for the values you want to extract
'/Document/BkToCstmrStmt/Stmt/Ntry'
--pass the xml type in here
PASSING l_xml
--declare the columns you would like to extract and the formats they are expected to be in
COLUMNS
temp_col1 VARCHAR2(128) path '/Ntry/Amt/text()',
temp_col2 VARCHAR2(128) path '/Ntry/Amt/#Ccy',
temp_col3 VARCHAR2(128) path '/Ntry/ValDt/Dt/text()',
temp_col4 VARCHAR2(128) path '/Ntry/BookgDt/Dt/text()'
) p
)
LOOP
dbms_output.put_line('Some value 1: ' || r.temp_col1);
dbms_output.put_line('Some value 2: ' || r.temp_col2);
dbms_output.put_line('Some value 3: ' || r.temp_col3);
dbms_output.put_line('Some value 4: ' || r.temp_col4);
END LOOP;
Related
I'm only passingly familiar with XML. I need to parse a response from a SOAP request. From a lot of searching, I've developed the following query to try to extract the status. Ultimately, I'd like to get the status, cntr and cntr_status fields from the response. My query gives no error, but also no results. What noob error am I making?
SELECT *
FROM XMLTABLE (
XMLNAMESPACES('http://schemas.xmlsoap.org/soap/envelope/' as "soapenv",
'http://www.w3.org/2001/XMLSchema' as "xsd",
'http://www.w3.org/2001/XMLSchema-instance' as "xsi",
'http://service.xxx.com/' AS "xxx"),
'/soapenv:Envelope/soapenv:Body/xxx:sendDataResponse/xxx:sendDataReturn/xxx:result'
PASSING XMLTYPE('<?xml version="1.0" encoding="UTF-8"?>' ||
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ' ||
' xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' ||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' ||
' <soapenv:Body>' ||
' <sendDataResponse xmlns="http://service.xxx.com">' ||
' <sendDataReturn>' ||
' <result>' ||
' <build>Build 1</build>' ||
' <status>SUCCESS</status>' ||
' <cntr_statuses>' ||
' <cntr_result>' ||
' <cntr>1234567890A</cntr><cntr_status>SUCCESS</cntr_status>' ||
' </cntr_result>' ||
' <cntr_result>' ||
' <cntr>1234567890B</cntr><cntr_status>SUCCESS</cntr_status>' ||
' </cntr_result>' ||
' </cntr_statuses>' ||
' </result>' ||
' </sendDataReturn>' ||
' </sendDataResponse>' ||
' </soapenv:Body>' ||
'</soapenv:Envelope>')
COLUMNS status VARCHAR2(20) PATH 'xxx:status') xmlstuff ;
A sample response from the service is hard-coded into the XMLTYPE function.
I've tried any number of query strings and column paths involving the xxx namespace, all yielding no results.
There could be hundreds of cntr and cntr_status pairs.
Thanks for looking!
Using the DEFAULT namespace (since you don't define a prefix for http://service.xxx.com) and removing the references to xxx: appears to work:
SELECT *
FROM XMLTABLE (
XMLNAMESPACES(
'http://schemas.xmlsoap.org/soap/envelope/' as "soapenv",
'http://www.w3.org/2001/XMLSchema' as "xsd",
'http://www.w3.org/2001/XMLSchema-instance' as "xsi",
DEFAULT 'http://service.xxx.com'
),
'/soapenv:Envelope/soapenv:Body/sendDataResponse/sendDataReturn/result'
PASSING XMLTYPE(
'<?xml version="1.0" encoding="UTF-8"?>' ||
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ' ||
' xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' ||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' ||
' <soapenv:Body>' ||
' <sendDataResponse xmlns="http://service.xxx.com">' ||
' <sendDataReturn>' ||
' <result>' ||
' <build>Build 1</build>' ||
' <status>SUCCESS</status>' ||
' <cntr_statuses>' ||
' <cntr_result>' ||
' <cntr>1234567890A</cntr><cntr_status>SUCCESS</cntr_status>' ||
' <cntr>1234567890B</cntr><cntr_status>SUCCESS</cntr_status>' ||
' </cntr_result>' ||
' </cntr_statuses>' ||
' </result>' ||
' </sendDataReturn>' ||
' </sendDataResponse>' ||
' </soapenv:Body>' ||
'</soapenv:Envelope>'
)
sqlfiddle here
Then to get the first cntr and cntr_status:
SELECT *
FROM XMLTABLE (
XMLNAMESPACES(
'http://schemas.xmlsoap.org/soap/envelope/' as "soapenv",
'http://www.w3.org/2001/XMLSchema' as "xsd",
'http://www.w3.org/2001/XMLSchema-instance' as "xsi",
DEFAULT 'http://service.xxx.com'
),
'/soapenv:Envelope/soapenv:Body/sendDataResponse/sendDataReturn/result'
PASSING XMLTYPE(
'<?xml version="1.0" encoding="UTF-8"?>' ||
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ' ||
' xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' ||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' ||
' <soapenv:Body>' ||
' <sendDataResponse xmlns="http://service.xxx.com">' ||
' <sendDataReturn>' ||
' <result>' ||
' <build>Build 1</build>' ||
' <status>SUCCESS</status>' ||
' <cntr_statuses>' ||
' <cntr_result>' ||
' <cntr>1234567890A</cntr><cntr_status>SUCCESS</cntr_status>' ||
' <cntr>1234567890B</cntr><cntr_status>SUCCESS</cntr_status>' ||
' </cntr_result>' ||
' </cntr_statuses>' ||
' </result>' ||
' </sendDataReturn>' ||
' </sendDataResponse>' ||
' </soapenv:Body>' ||
'</soapenv:Envelope>'
)
COLUMNS
status VARCHAR2(20) PATH 'status',
cntr VARCHAR2(20) PATH 'cntr_statuses/cntr_result/cntr[1]',
cntr_status VARCHAR2(20) PATH 'cntr_statuses/cntr_result/cntr_status[1]'
) xmlstuff;
sqlfiddle here
Update for revised XML format
Ideally, you should be able to use the XPATH '/soapenv:Envelope/soapenv:Body/sendDataResponse/sendDataReturn/result/cntr_status/cntr_result' in the XMLTABLE and then get the status with the path ./../../status; however, I keep getting null values when trying to traverse to a parent element and couldn't find a working solution.
SELECT x.*
FROM table_name t
CROSS JOIN
XMLTABLE(
XMLNAMESPACES(
'http://schemas.xmlsoap.org/soap/envelope/' as "soapenv",
'http://www.w3.org/2001/XMLSchema' as "xsd",
'http://www.w3.org/2001/XMLSchema-instance' as "xsi",
DEFAULT 'http://service.xxx.com'
),
'/soapenv:Envelope/soapenv:Body/sendDataResponse/sendDataReturn/result/cntr_statuses/cntr_result'
PASSING XMLTYPE(t.xml)
COLUMNS
status VARCHAR2(20) PATH './../../status',
cntr VARCHAR2(20) PATH 'cntr',
cntr_status VARCHAR2(20) PATH 'cntr_status'
) x;
sqlfiddle here
According to this comment, it will work in Oracle 11.2.0.4 but if you try it in Oracle 11.2.0.2 then status will be NULL (which is the result seen on SQLFiddle).
Instead, with multiple cntr_result elements you can use two XMLTABLE:
SELECT x.status,
c.cntr,
c.cntr_status
FROM table_name t
CROSS JOIN
XMLTABLE(
XMLNAMESPACES(
'http://schemas.xmlsoap.org/soap/envelope/' as "soapenv",
'http://www.w3.org/2001/XMLSchema' as "xsd",
'http://www.w3.org/2001/XMLSchema-instance' as "xsi",
DEFAULT 'http://service.xxx.com'
),
'/soapenv:Envelope/soapenv:Body/sendDataResponse/sendDataReturn/result'
PASSING XMLTYPE(t.xml)
COLUMNS
status VARCHAR2(20) PATH 'status',
cntr_statuses XMLTYPE PATH 'cntr_statuses'
) x
CROSS JOIN
XMLTABLE(
XMLNAMESPACES(
'http://schemas.xmlsoap.org/soap/envelope/' as "soapenv",
'http://www.w3.org/2001/XMLSchema' as "xsd",
'http://www.w3.org/2001/XMLSchema-instance' as "xsi",
DEFAULT 'http://service.xxx.com'
),
'/cntr_statuses/cntr_result'
PASSING x.cntr_statuses
COLUMNS
cntr VARCHAR2(20) PATH 'cntr',
cntr_status VARCHAR2(20) PATH 'cntr_status'
) c;
Assuming your data is in the xml column of the table_name table.
Then the output is:
STATUS
CNTR
CNTR_STATUS
SUCCESS
1234567890A
SUCCESS
SUCCESS
1234567890B
SUCCESS
sqlfiddle here
I am getting very fed up of APEX in recent days, i am trying to run a interactive report within application express and cannot seem to use variables i declare within my sql queries. Below is the error, i also included the code that works. the get_longlat() function is tested and works it returns a SDO_GEOMETRY data type.
ORA-06550: line 7, column 12: PLS-00306: wrong number or types of
arguments in call to '||' ORA-06550: line 7, column 1: PL/SQL:
Statement ignored
DECLARE
l_query VARCHAR2(4096);
l_location SDO_GEOMETRY := get_longlat(v('P2_POSTCODE'));
BEGIN
l_query := '
SELECT
"VENUE_ID",
"VENUE_NAME",
"CITY",
"VENUE_NO",
"POSTCODE",
dbms_lob.getlength("THUMBNAIL") "THUMBNAIL",
"DESCRIPTION",
SDO_GEOM.SDO_DISTANCE(G_LOCATION, ' || l_location || ',0.005,''unit=mile'') "G_LOCATION"
FROM "GAMEVENUE"
WHERE (SDO_WITHIN_DISTANCE(G_LOCATION,' || l_location || ',''distance=250 unit=mile'') = ''TRUE'');';
RETURN l_query;
This works
l_query := '
SELECT
"VENUE_ID",
"VENUE_NAME",
"CITY",
"VENUE_NO",
"POSTCODE",
dbms_lob.getlength("THUMBNAIL") "THUMBNAIL",
"DESCRIPTION",
SDO_GEOM.SDO_DISTANCE(G_LOCATION, MDSYS.SDO_GEOMETRY(2001,4326,SDO_POINT_TYPE(-4.1530439,50.371089,NULL),NULL,NULL),0.005,''unit=mile'') "G_LOCATION"
FROM "GAMEVENUE"
WHERE (SDO_WITHIN_DISTANCE(G_LOCATION,SDO_GEOMETRY(2001,4326,SDO_POINT_TYPE(-4.1530439,50.371089,null),null,null),''distance=250 unit=mile'') = ''TRUE'')';
Because SDO_GEOMETRY is not of type char or number( implicitly considerable as char ), you can't use it in direct concetenation.
Try this instead :
l_query := '
SELECT
"VENUE_ID",
"VENUE_NAME",
"CITY",
"VENUE_NO",
"POSTCODE",
dbms_lob.getlength("THUMBNAIL") "THUMBNAIL",
"DESCRIPTION",
SDO_GEOM.SDO_DISTANCE(G_LOCATION, MDSYS.SDO_GEOMETRY('||l_sdo_gtype||','||l_sdo_srid||',MDSYS.SDO_POINT_TYPE('||l_longitude||','||l_latitude||',NULL),NULL,NULL),0.005,''unit=mile'') "G_LOCATION"
FROM "GAMEVENUE"
WHERE (SDO_WITHIN_DISTANCE(G_LOCATION,SDO_GEOMETRY('||l_sdo_gtype||','||l_sdo_srid||',SDO_POINT_TYPE('||l_longitude||','||l_latitude||',null),null,null),''distance=250 unit=mile'') = ''TRUE'')';
where l_sdo_gtype,l_sdo_srid, l_longitude, l_latitude are of type number;
Sample XML as below:
<Root>
...
<XMLNSC>
...
<SOAP-ENV:Envelope>
...
<SOAP-ENV:Body>
<typesNS0:getABCD xmlns:typesNS0="http://xxx.xx/xxxxxx/xxxxxxxxx/x/" xmlns:xalan="http://xml.apache.org/xslt">
last tag typesNS0:getABCD want to select
select xmltype(a).extract('//typesNS0:getABCD','xmlns:typesNS0="http://xxx.xx/xxxxxx/xxxxxxxxx/x/"')
from (
select
'<Root xmlns:SOAP-ENV="http://a.b.org/">
<XMLNSC />
<SOAP-ENV:Envelope/>
<SOAP-ENV:Body/>
<typesNS0:getABCD xmlns:typesNS0="http://xxx.xx/xxxxxx/xxxxxxxxx/x/" xmlns:xalan="http://xml.apache.org/xslt">123</typesNS0:getABCD>
</Root>' a from dual
)
You may run below script if you want get exact tag value;
DECLARE
vs_Xml VARCHAR2(32000):= '<Root xmlns:SOAP-ENV="http://a.b.org/">
<XMLNSC />
<SOAP-ENV:Envelope/>
<SOAP-ENV:Body/>
<typesNS0:getABCD xmlns:typesNS0="http://xxx.xx/xxxxxx/xxxxxxxxx/x/" xmlns:xalan="http://xml.apache.org/xslt">123</typesNS0:getABCD>
</Root>';
vx_ParameterList XMLTYPE;
vx_Parameter XMLTYPE;
vn_ParameterIndex NUMBER;
vs_Key VARCHAR2(64);
vs_XPath VARCHAR2(255);
vs_Value VARCHAR2(10000);
BEGIN
vx_ParameterList := xmltype(vs_Xml);
vn_ParameterIndex := 1;
vs_XPath := '/Root';
WHILE vx_ParameterList.existsNode(vs_XPath || '[' || vn_ParameterIndex || ']') = 1 LOOP
vx_Parameter := vx_ParameterList.extract(vs_XPath || '[' || vn_ParameterIndex || ']');
vs_Value := vx_Parameter.extract('//typesNS0:getABCD/text()','xmlns:typesNS0="http://xxx.xx/xxxxxx/xxxxxxxxx/x/"').GetStringVal();
vn_ParameterIndex := vn_ParameterIndex + 1;
dbms_output.put_line(vs_Value);
END LOOP;
END;
Here is my Code:
I need to upload a file from the local machine to the file system
Also, i got an error when opening the file attached in the oracle application (ORA-01403: no data found
FRM-40735: WHEN-BUTTON-PRESSED trigger raised unhandled exception
ORA-01403.)
CREATE OR REPLACE DIRECTORY in_file_loc AS '/oracle/TEST';
CREATE TABLE test_files (p_id NUMBER,
pl_name VARCHAR2(100),
pl_pict BLOB);
DECLARE
x_blob BLOB;
fils BFILE := BFILENAME ('IN_FILE_LOC', 'aa.pdf');
blob_length INTEGER;
BEGIN
-- Obtain the size of the blob file
DBMS_LOB.fileopen (fils, DBMS_LOB.file_readonly);
blob_length := DBMS_LOB.getlength (fils);
DBMS_LOB.fileclose (fils);
-- Insert a new record into the table containing the
-- filename you have specified and a LOB LOCATOR.
-- Return the LOB LOCATOR and assign it to x_blob.
INSERT INTO test_files (p_id,pl_name,pl_pict)
VALUES (7, 'aa.pdf', EMPTY_BLOB ())
RETURNING pl_pict
INTO x_blob;
-- Load the file into the database as a BLOB
DBMS_LOB.OPEN (fils, DBMS_LOB.lob_readonly);
DBMS_LOB.OPEN (x_blob, DBMS_LOB.lob_readwrite);
DBMS_LOB.loadfromfile (x_blob, fils, blob_length);
-- Close handles to blob and file
DBMS_LOB.CLOSE (x_blob);
DBMS_LOB.CLOSE (fils);
COMMIT;
-- Confirm insert by querying the database
-- for LOB length information and output results
blob_length := 0;
SELECT DBMS_LOB.getlength (pl_pict)
INTO blob_length
FROM test_files
WHERE pl_name = 'aa.pdf';
DBMS_OUTPUT.put_line ('Successfully inserted BLOB ''' ||'aa.pdf' || ''' of size ' || blob_length || ' bytes.');
END;
DECLARE
TYPE result_set_type IS REF CURSOR;
l_name VARCHAR2 (100);
l_doc_size NUMBER;
l_result_set_curr result_set_type;
x_access_id NUMBER;
x_file_id NUMBER;
p_file_name VARCHAR2 (100) := 'aa.pdf';
PROCEDURE load_file_details (p_name IN VARCHAR2, result_set_curr OUT result_set_type)
AS
l_error VARCHAR2 (2000);
BEGIN
INSERT INTO fnd_lobs_document
(NAME, mime_type, doc_size, content_type, blob_content)
SELECT pl_name, 'application/pdf', DBMS_LOB.getlength (pl_pict), 'BINARY', '(BLOB)'
FROM test_files
WHERE pl_name = 'aa.pdf';
OPEN result_set_curr FOR
SELECT blob_content
FROM fnd_lobs_document
WHERE NAME = p_name;
EXCEPTION
WHEN OTHERS
THEN
NULL;
l_error := 'LOAD_FILE_DETAILS - OTHERS' || SUBSTR (SQLERRM, 2000);
DBMS_OUTPUT.put_line (l_error);
END load_file_details;
PROCEDURE upload_file (v_filename IN VARCHAR2, x_access_id OUT NUMBER, x_file_id OUT NUMBER)
AS
v_access_id NUMBER;
v_file_id NUMBER;
x_errbuf VARCHAR2 (200);
BEGIN
v_access_id := fnd_gfm.authorize (NULL);
x_access_id := v_access_id;
DBMS_OUTPUT.put_line ('Access id :' || v_access_id);
-- The function fnd_gfm.confirm_upload return the file id
v_file_id :=
fnd_gfm.confirm_upload (access_id => v_access_id
, file_name => v_filename
, program_name => 'TEST'
, program_tag => 'TEST'
, expiration_date => NULL
, LANGUAGE => 'US'
, wakeup => TRUE
);
x_file_id := v_file_id;
DBMS_OUTPUT.put_line ('File id :' || x_file_id);
EXCEPTION
WHEN OTHERS
THEN
x_errbuf := 'Procedure upload_file errored out with the following error : ' || SQLERRM;
DBMS_OUTPUT.put_line (x_errbuf);
END upload_file;
BEGIN
fnd_global.apps_initialize (0, 20634, 401);
load_file_details (p_name => p_file_name, result_set_curr => l_result_set_curr);
upload_file (v_filename => p_file_name, x_access_id => x_access_id, x_file_id => x_file_id);
COMMIT;
END;
DECLARE
TYPE result_set_type IS REF CURSOR;
l_name VARCHAR2 (100);
l_doc_size NUMBER;
l_result_set_curr result_set_type;
x_access_id NUMBER;
x_file_id NUMBER;
p_file_name VARCHAR2 (100) := 'aa.pdf';
PROCEDURE attach_file (p_access_id IN NUMBER, p_file_Id in number, p_filename IN VARCHAR2)
IS
BEGIN
fnd_webattch.add_attachment (seq_num => 900
,category_id => 1
,document_description => 'Test1'
,datatype_id => 5
,text => NULL
,file_name => p_filename
,url => NULL
,function_name => 'INVIDITM'
,entity_name => 'MTL_SYSTEM_ITEMS'
,pk1_value => 85 --organization_id
,pk2_value => 10 --Inventory_item_Id
,pk3_value => NULL
,pk4_value => NULL
,pk5_value => NULL
,media_id => p_file_id
,user_id => 0
,usage_type => 'O'
);
DBMS_OUTPUT.put_line ('File Attached!');
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('error in loading the attachement');
END attach_file;
BEGIN
fnd_global.apps_initialize (0, 20634, 401);
attach_file (p_access_id => x_access_id, p_file_id=>x_file_id,p_filename => p_file_name);
COMMIT;
END;
I believe we are mixing context here. I assume Local machine here means the machine that you build the PL/SQL - only issue here is when you run it runs within the server context. So i would either FTP the file to the server or load your file content to an oracle table in a different way.
i am using the oracle apex and 10g database i use the following code to call the web service it gives me the folowing error
ORA-06503: PL/SQL: Function returned without value
any one can help me thnx
the code i use is
{
declare
l_envelope CLOB;
l_xml XMLTYPE;
l_movie VARCHAR2(4000);
BEGIN
l_envelope := ' <?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tns="http://www.ignyte.com/whatsshowing"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<tns:GetTheatersAndMovies>
<tns:zipCode>43221</tns:zipCode>
<tns:radius>5</tns:radius>
</tns:GetTheatersAndMovies>
</soap:Body>
</soap:Envelope>';
l_xml := apex_web_service.make_request(
p_url => ' http://www.ignyte.com/webservices/ignyte.whatsshowing.webservice \/moviefunctions.asmx',
p_action => ' http://www.ignyte.com/whatsshowing/GetTheatersAndMovies',
p_envelope => l_envelope );
l_movie := apex_web_service.parse_xml(
p_xml => l_xml,
p_xpath => ' //GetTheatersAndMoviesResponse/GetTheatersAndMoviesResult/Theater/Movies/Movie/Name[1]',
p_ns => ' xmlns="http://www.ignyte.com/whatsshowing"' );
END;}