I am using a sql http request to retrieve issues from JIRA , so far I can retrieve chosen number of issues according to the assignee name or reporter.
My problem now that I can not retrieve issues according to the creation field (date when the issues has been created) or othe custom field, I am receiving error :
Unrecognized field !
My approach was to play around with this part of the code :
**lv_json_request := '{'
||'"jql": "assignee='||:P9_ASSIGNEE||'",'
||'"startAt": '||NVL(:P9_STARTAT,0)||','
||'"maxResults": '||:P9_MAXRESULTS
||'}';**
You can find below the whole pl/sql block , it works fine with the current situation .
DECLARE
http_req utl_http.req;
http_resp utl_http.resp;
lv_json_request VARCHAR2(32767);
lc_response CLOB;
lv_response VARCHAR2(32767);
BEGIN
lv_json_request := '{'
||'"jql": "assignee='||:P9_ASSIGNEE||'",'
||'"startAt": '||NVL(:P9_STARTAT,0)||','
||'"maxResults": '||:P9_MAXRESULTS
||'}';
UTL_HTTP.set_wallet('file:/oracle/ora11/owm/wallets/oracle', 'apex4wallet');
http_req:= utl_http.begin_request
( url => 'https://rb-wam.bosch.com/tracker/rest/api/2/search'
, method => 'POST'
);
utl_http.set_header(http_req, 'Authorization', 'Basic '||:F_JIRA_TOKEN_REST);
utl_http.set_header(http_req, 'Content-Type', 'application/json');
utl_http.set_header(http_req, 'Content-Length', LENGTH(lv_json_request));
utl_http.write_text(http_req, lv_json_request);
http_resp:= utl_http.get_response(http_req);
-- read data from response
BEGIN
LOOP
utl_http.read_text(http_resp, lv_response);
HTP.PRN(lv_response);
lc_response := lc_response || TO_CLOB(lv_response);
END LOOP;
EXCEPTION
WHEN UTL_HTTP.END_OF_BODY THEN
utl_http.end_response(http_resp);
END;
-- log details
--DELETE webservice_log;
INSERT INTO webservice_log (seq_id,clob_response,clob_request) VALUES (sqe_Webservice_Log.NEXTVAL,lc_response,TO_CLOB(lv_json_request));
--HTP.P(lc_response);
EXCEPTION
WHEN OTHERS THEN
RAISE;
END;
You can add something like this to your lv_json_request statement:
"createdDate<='||:P9_CREATED||'"
using any valid operator instead of "<=", depending on your needs.
Related
How can I ignore the errors below?
create_co - errc=-20104 errm=ORA-20104: create_collection_from_query_b Error:ORA-20101: Application collection exists
create_co - errc=-20104 errm=ORA-20104: create_collection_from_queryb2 Error:ORA-00001: Schending van UNIQUE-beperking (APEX_180200.WWV_FLOW_COLLECTIONS_UK).
This error is confusing for users.
declare
pl_query varchar2(4000);
cl_collectie constant varchar2(255) := 'MY_COLLECTION';
begin
--
if apex_collection.collection_exists( p_collection_name => cl_collectie )
then
apex_collection.delete_collection( p_collection_name => cl_collectie );
end if;
--
pl_query := q'[select QUERY]' ;
--
apex_collection.create_collection_from_queryb2( p_collection_name => cl_collectie
, p_query => pl_query );
end;
We're using Application Express 18.2.0.00.12.
if you run the dynamic action for example on button click then you have to disable the button until the dynamic action is finished. generally you need to find a way to prevent your users from running the dynamic action a second time if the first time isn't finished yet.
I am trying to invoke a webservice from PL/SQL code which will accept itemnumber as input parameter and will return about 8 output parameters, some are string while couple of will be in base64binay encoded PDF files.
When I am testing same WSDL from SoapUI it returns proper response.
But in my PL/SQL code I get 415 Unsupported Media Type Error. could you please help me to fix this, I am stuck in this error from last 5 days. thanks in advance.
Below is my dummy code, once it works fine, then I need to convert into a proper function.
declare
soap_request varchar2(30000);
soap_respond CLOB;
soap_respond_temp CLOB;
http_req utl_http.req;
http_resp utl_http.resp;
l_resp XMLType;
i integer;
instr_start integer;
instr_end integer;
l_orgname varchar2(30000);
l_description VARCHAR2(250);
l_long_description VARCHAR2(1000);
l_segment1 VARCHAR2(250);
l_item_type VARCHAR2(100);
l_isbn VARCHAR2(100);
l_match_score NUMBER;
l_pdh_id NUMBER;
l_cross_reference_id NUMBER;
l_soap_request CLOB;
l_soap_response CLOB;
l_soap_resp_raw LONG RAW;
l_buffer_size NUMBER (10) := 512;
l_substring_msg VARCHAR2 (512);
l_string_request VARCHAR2 (512);
l_raw_data RAW (512);
buffer VARCHAR2 (32767);
i NUMBER;
eob BOOLEAN := FALSE;
resultvar VARCHAR2 (30000);
begin
--Item number 104PT is I/p parameter below to the SOAP webservice
soap_request:= '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:grad="http://grades.web.spec.quality.asmorg.com/">
<soap:Header/>
<soap:Body>
<grad:getGradeInfoForRM>
<strRMItem>104PT</strRMItem>
</grad:getGradeInfoForRM>
</soap:Body>
</soap:Envelope>';
http_req:= utl_http.begin_request
( 'http://112.18.28.38:81/Itemspec/ItemGradeWSPort'
, 'POST'
, 'HTTP/1.1'
);
utl_http.set_header(http_req, 'Content-Type', 'text/xml');
utl_http.set_header(http_req, 'Content-Length', length(soap_request));
utl_http.set_header(http_req, 'SOAPAction', '');
utl_http.write_text(http_req, soap_request);
http_resp:= utl_http.get_response(http_req);
--dbms_output.put_line('got the soap response');
dbms_output.put_line('Response> status_code: "' ||http_resp.status_code || '"');
dbms_output.put_line('Response> reason_phrase: "' ||http_resp.reason_phrase || '"');
dbms_output.put_line('Response> http_version: "' ||http_resp.http_version || '"');
DBMS_LOB.createtemporary (l_soap_response, TRUE);
fnd_file.put_line(fnd_file.log,'After create temporary');
WHILE NOT (eob)
LOOP
BEGIN
dbms_output.put_line ('before read_text');
UTL_HTTP.read_text (http_resp, buffer, 32767);
fnd_file.put_line( fnd_file.log,'Printing Buffer '||buffer);
dbms_output.put_line( 'Printing Buffer '||buffer);
IF buffer IS NOT NULL AND LENGTH (buffer) > 0
THEN
fnd_file.put_line( fnd_file.log,'Appending to l_soap_response using DBMS writeappend');
dbms_output.put_line (' Appending to l_soap_response using DBMS writeappend');
DBMS_LOB.writeappend (l_soap_response, LENGTH (buffer), buffer);
END IF;
EXCEPTION
WHEN UTL_HTTP.end_of_body
THEN
fnd_file.put_line( fnd_file.log,'end of body');
eob := TRUE;
END;
END LOOP;
UTL_HTTP.end_response (http_resp);
fnd_file.put_line (fnd_file.log,'before XMLTYPE Call');
dbms_output.put_line ('before XMLTYPE Call');
l_resp := XMLTYPE.createxml (l_soap_response);
DBMS_LOB.freetemporary (l_soap_response);
fnd_file.put_line(fnd_file.log,'--after XMLTYPE Call');
dbms_output.put_line ('after XMLTYPE Call');
resultvar := l_resp.getstringval();
fnd_file.put_line(fnd_file.log,'--after getstringval Call');
fnd_file.put_line (fnd_file.log,resultvar);
fnd_file.put_line ( fnd_file.log,'End DateTime:- ' || SYSTIMESTAMP);
EXCEPTION
WHEN UTL_HTTP.end_of_body THEN
dbms_output.put_line('end of body');
UTL_HTTP.end_response(http_resp);
WHEN UTL_HTTP.TOO_MANY_REQUESTS THEN
UTL_HTTP.END_RESPONSE(http_resp);
WHEN OTHERS THEN
dbms_output.put_line('others eception '||SQLERRM);
end;
Here is printed log messages:
Response> status_code: "415"
Response> reason_phrase: "Unsupported Media Type"
before read_text
before XMLTYPE Call
others eception ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00229: input source is empty
This issue is resolved now, problem was setting the header was not proper as per SOAP webservice type.
sys.UTL_HTTP.SET_HEADER(http_req, 'Content-Type', 'application/soap+xml;charset=UTF-8');
utl_http.set_header(http_req, 'Content-Length', length(soap_request));
utl_http.set_header (http_req, 'Transfer-Encoding', 'chunked');
sys.utl_http.set_header(http_req, 'User-Agent', 'Apache-HttpClient/4.1.1 (java 1.5)');
utl_http.set_header(http_req, 'SOAPAction', '');
this clue about correct header type i.e. 'Content-type' and 'User-Agent', I got from SoapUI while looking at Raw tab.
Thanks,
Pradeep
Can anybody explain why we need pragma exception init. we have user defined exception which does the same job as pragma. Your answer will be appreciated.
pragma exception_init is used to provide a name to an exception so that you can reference the exception by that name in the exception handler. Only a few of the several thousand Oracle exceptions have predefined names. You can use exception_init to create names for these other exceptions.
see https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/errors.htm#BABGIIBI
I am editing my previous answer because I can insert formatted text here.
In your example, you are defining an exception that you are throwing, but what if you want to catch an existing exception that the system is throwing, but is unnamed? In the example that follows, I handle two specific errors 'DATA_NOT_FOUND', and ORA-600, which is a system error (and yes, I have some code that gets these).
CREATE OR REPLACE PROCEDURE exception_init_demo
AS
l_routine VARCHAR2 (30) := $$plsql_unit;
severe_system_error EXCEPTION;
PRAGMA EXCEPTION_INIT (severe_system_error, -600);
BEGIN
-- Execution code goes here
NULL;
EXCEPTION
WHEN severe_system_error
THEN
-- Severe error, log it, notify the dba, re-raise the exception
log_error (
p_application => $$plsql_unit
, p_routine => l_routine
, p_message => SQLERRM || UTL_TCP.crlf || DBMS_UTILITY.format_error_backtrace ()
);
notify_dba;
RAISE;
WHEN NO_DATA_FOUND
THEN
-- No data was found, this is OK, ignore error and return
return;
WHEN OTHERS
THEN
-- all other errors we will log and re-raise
log_error (
p_application => $$plsql_unit
, p_routine => l_routine
, p_message => SQLERRM || UTL_TCP.crlf || DBMS_UTILITY.format_error_backtrace ()
);
RAISE;
END;
create or replace procedure zivtest is
utl_mail.send_attach_varchar2 varchar2(100) :=utl_mail;
mail_subject varchar2(255) := 'zivtest'||sysdate;
mail_message varchar2(1000):='zivtest'
||'<br>'||'User count of all active users in all Realms';
recipients_list varchar2(255) :='user#user.com';
p_sender varchar2(50) := 'user#user.com';
data clob;
data_header varchar2(255);
--E_too_much_values exception;
begin
for item IN ( select decode(r.irl_id,1,'UPSEC',2,'PC',3,'CSM',6,'DMROAM',7,'WORKFLOW',8,'CSS_DEALER',10,'CCBATCH',14,'CSS',61,'COL',81,'CRM'
,82,'FIU',83,'OCM',84,'BOA',127,'SAPI') realm,
count (a.user_id) users
from sec_idm_user a , SEC_IDM_REALM_A r
where a.iu_rlid=r.irl_id
and a.iu_lock='N'
and a.iu_last_login >= sysdate -90
group by r.irl_id) LOOP
if data is not null then
utl_mail.send_attach_varchar2(
sender => p_sender,
recipients => recipients_list,
subject => mail_subject,
message => mail_message,
mime_type => 'text/html; charset=WINDOWS-1255',
attachment => data_header || data ,
att_filename => 'USER_COUNT.csv');
end if ;
END LOOP;
END;
How can I fix this?
I got the following error when I try to compile it:
PLS-00103: Encountered the symbol "." when expecting one of the following:
<an identifier> <a double-quoted delimited-identifier> current
You are seeing this error because second line
utl_mail.send_attach_varchar2 varchar2(100) :=utl_mail;
doesn't make sense. you are trying to declare variable named utl_mail.send_attach_varchar2.
What you need is to install utl_mail package, to be able to use procedure utl_mail.send_attach_varchar2
I am teaching myself to use SQLite and FireDAC together in Delphi. I am not very experienced with the latest incarnations of databases and tools so after writing a very simple application to display a single table from an SQLite file, I decided that I would put together a simple viewer 'frame' that would help me learn and maybe give me (eventually) a debugging tool to put in my Application for engineering use.
So, I've used a simple TTreeView and I wish to populate it with a hierarchy of 'databases' (catalogues?), 'tables', 'field names' and 'field types'. So far it has been remarkably easy to list the catalogues, tables and fields (using TFDConnection.Getxxxxx) but I cant see how to go deeper to get field definitions. Is this possible to do from a TFDConnection? Or do I need to open a temporary query?
My existing code is shown below and my 'field types' would be a further nested loop when shown as '// xxxxxxxxxxxxxxxxxxx'
procedure TForm1.Button1Click(Sender: TObject);
procedure DatabaseToTreeView( AConnection : TFDConnection; ATreeView : TTreeView );
procedure ProcessConnection;
procedure ProcessCatalogueName( const ACatalogueName : string; ARoot : TTreeNode );
procedure ProcessTableName( const ATableName : string; ARoot : TTreeNode );
var
List : TStrings;
{Node : TTreeNode;}
I : integer;
begin
List := TStringList.Create;
try
AConnection.GetFieldNames( ACatalogueName, '', ATableName, '', List );
for I := 0 to List.Count-1 do
begin
{Node := }ATreeView.Items.AddChild( ARoot, List[I] );
// xxxxxxxxxxxxxxxxxxx
end;
finally
List.Free;
end;
end;
var
List : TStrings;
Node : TTreeNode;
I : integer;
begin
List := TStringList.Create;
try
AConnection.GetTableNames( ACatalogueName, '', '', List );
for I := 0 to List.Count-1 do
begin
Node := ATreeView.Items.AddChild( ARoot, List[I] );
ProcessTableName( List[I], Node );
end;
finally
List.Free;
end;
end;
var
List : TStrings;
Node : TTreeNode;
I : integer;
begin
List := TStringList.Create;
try
AConnection.GetCatalogNames( '', List );
if List.Count = 0 then
ProcessCatalogueName( '', nil )
else
for I := 0 to List.Count-1 do
begin
Node := ATreeView.Items.AddChild( nil, List[I] );
ProcessCatalogueName( List[I], Node );
end;
finally
List.Free;
end;
end;
begin
ATreeView.Items.Clear;
ATreeView.Items.BeginUpdate;
try
ProcessConnection;
finally
ATreeView.Items.EndUpdate;
end;
end;
begin
FDConnection1.Open;
FDQuery1.Active := true;
DatabaseToTreeView( FDConnection1, TreeView1 );
end;
Many thanks, Brian.
One solution is to instantiate a TFDTable, connect it to AConnection and call FieldDefs.Update. This won't fetch any data.
Use the TFDMetaInfoQuery component. It is unified for getting metadata information, so it's usable with any kind of supported DBMS. It populates metadata resultsets by the requested MetaInfoKind and given DBMS object description.
Instead of using a temporary query with a false condition to get table schema without any data (such as "select * from tablename where 1=0" - I assume that is what you meant), depending on your database, you could also use a query to get table information. Like;
For MySQL:
show columns from tablename;
For SQLite:
PRAGMA table_info(tablename)
For MS SQL Server:
select column_name, data_type, character_maximum_length from INFORMATION_SCHEMA.COLUMNS where table_name = 'tablename';
I believe PostgreSQL also has such a function, however I dont have a pgsql installation handy at this time.