WSO2 DSS call procedure with CLOB response raise ORA-22835 error - oracle

I have a Oracle procedure
TEST_XML_PARM_CALLER
call procedure
TEST_XML_PARM_CALLEE(parm1 IN CLOB, parm2 OUT CLOB)
via WSO2 ESB, WSO2 DSS.
The parm1 is CLOB parameter, send XML content from procedure TEST_XML_PARM_CALLER,
and the parm2 is CLOB parameter that return XML content from procedure TEST_XML_PARM_CALLEE.
The call from TEST_XML_PARM_CALLER to ESB to DSS to TEST_XML_PARAM_CALLEE is correct by CLOB content (string length great than 4000),
but return parameter(parm2) will raise error when length great than 4000, like bellow
ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 6024, maximum: 4000)
In WSO2 DSS, the configuration as below
<data name="test_xml_parm">
<config id="test_db">
<property name="carbon_datasource_name">test_db</property>
</config>
<query id="qry_test_xml_parm" useConfig="test_db">
<sql>call TEST_XML_PARM_CALLEE(?,?)</sql>
<result element="rcd" rowName="row">
<element column="rtn_clob" name="rtn_clob" xsdType="string"/>
</result>
<param name="clob_xml" ordinal="1" sqlType="STRING"/>
<param name="rtn_clob" ordinal="2" sqlType="STRING" type="OUT"/>
</query>
<operation name="op_test_xml_parm">
<call-query href="qry_test_xml_parm">
<with-param name="clob_xml" query-param="clob_xml"/>
</call-query>
</operation>
</data>
anyone can tell me how to fix it ?

This is an old question and I don't know about the wso2Dss version.
I had a similar problem with wso2DSS 4.4.2
1)set parameters sqlType to "CLOB"
2) replace ojdbc5.jar with ojdbc6.jar (or you will get java.lang.AbstractMethodError: setClob is abstract error.
I still have problems with xml (I must put input in CDATA and the response is ecaped (< => < ) but I should be able to deal with it on the ESB side.

Related

Extract data from XMLTYPE variable

I have an XML below from which I am trying to extract the error tag data:
<ns1:updateStatusResponse xmlns:ns1="http://www.example.com/webservices">
<return href="#ID1"/>
</ns1:updateStatusResponse>
<ns3:OrderStatusUpdateResponse xmlns:ns3="http://www.example.com/com.example.com.ful.mod" id="ID1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns3:OrderStatusUpdateResponse">
<status xsi:type="xsd:string">ERROR</status>
<statusDetail xsi:type="xsd:string">Error occured when updating status for example</statusDetail>
</ns3:OrderStatusUpdateResponse>
I am using a logic like this, where resp is XMLTYPE and v_resp is VARCHAR2
v_resp := resp.EXTRACT (
'ns3:OrderStatusUpdateResponse/status/text()',
'xmlns:ns3="http://http://www.example.com/com.example.com.ful.mod" id="ID1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns3:OrderStatusUpdateResponse').getstringval ();
Whenever I run this in my code, I get an exception but no message.
Can someone please help me resolve this?

Freeswitch use mod_lcr with originate api

Is there a way to use mod_lcr with originate command?
I want to originate a call and have mod_lcr decide which gateway should be used based on lcr rules (cost, reliability, etc).
When mod_lcr is used in the dialplan it will populate a variable ${lcr_auto_route} with the dialstring. How can I use the same logic with originate?
Thank you.
Here is how I did it.
I connect to freeswitch via ESL and execute the command
lcr 1716 default as xml
where 1716 is the digit sequence and default is the profile name (you can replace default with your own profile name)
Note 'as xml' will return an XML response. The response looks like this:
<result>
<row id="1">
<prefix>1716</prefix>
<carrier_name>carrier1</carrier_name>
<rate>0.15000</rate>
<codec></codec>
<cid></cid>
<limit></limit>
<dialstring>[lcr_carrier=carrier1,lcr_rate=0.15000]sofia/gateway/carrier1/1716</dialstring>
<event>
<headers>
<Event-Name>REQUEST_PARAMS</Event-Name>
<Core-UUID>151c590b-cce8-4eb3-b3ae-f48bad397870</Core-UUID>
<FreeSWITCH-Hostname>freeswitch</FreeSWITCH-Hostname>
<FreeSWITCH-Switchname>freeswitch</FreeSWITCH-Switchname>
<FreeSWITCH-IPv4>172.16.124.130</FreeSWITCH-IPv4>
<FreeSWITCH-IPv6>%3A%3A1</FreeSWITCH-IPv6>
<Event-Date-Local>2018-02-20%2007%3A33%3A42</Event-Date-Local>
<Event-Date-GMT>Tue,%2020%20Feb%202018%2006%3A33%3A42%20GMT</Event-Date-GMT>
<Event-Date-Timestamp>1519108422660002</Event-Date-Timestamp>
<Event-Calling-File>mod_lcr.c</Event-Calling-File>
<Event-Calling-Function>route_add_callback</Event-Calling-Function>
<Event-Calling-Line-Number>633</Event-Calling-Line-Number>
<Event-Sequence>786</Event-Sequence>
<lcr_digits>1716</lcr_digits>
<lcr_carrier_name>carrier1</lcr_carrier_name>
<lcr_rate_field>0.15000</lcr_rate_field>
<lcr_gw_prefix>sofia/gateway/carrier1/</lcr_gw_prefix>
<lcr_lead_strip>0</lcr_lead_strip>
<lcr_trail_strip>0</lcr_trail_strip>
</headers>
</event>
</row>
<row id="2">
<prefix>1</prefix>
<carrier_name>carrier2</carrier_name>
<rate>0.12000</rate>
<codec></codec>
<cid></cid>
<limit></limit>
<dialstring>[lcr_carrier=carrier2,lcr_rate=0.12000]sofia/external/0716#proxy.carrier2.net:5060</dialstring>
<event>
<headers>
<Event-Name>REQUEST_PARAMS</Event-Name>
<Core-UUID>151c590b-cce8-4eb3-b3ae-f48bad397870</Core-UUID>
<FreeSWITCH-Hostname>freeswitch</FreeSWITCH-Hostname>
<FreeSWITCH-Switchname>freeswitch</FreeSWITCH-Switchname>
<FreeSWITCH-IPv4>172.16.124.130</FreeSWITCH-IPv4>
<FreeSWITCH-IPv6>%3A%3A1</FreeSWITCH-IPv6>
<Event-Date-Local>2018-02-20%2007%3A33%3A42</Event-Date-Local>
<Event-Date-GMT>Tue,%2020%20Feb%202018%2006%3A33%3A42%20GMT</Event-Date-GMT>
<Event-Date-Timestamp>1519108422660002</Event-Date-Timestamp>
<Event-Calling-File>mod_lcr.c</Event-Calling-File>
<Event-Calling-Function>route_add_callback</Event-Calling-Function>
<Event-Calling-Line-Number>633</Event-Calling-Line-Number>
<Event-Sequence>787</Event-Sequence>
<lcr_digits>1</lcr_digits>
<lcr_carrier_name>carrier2</lcr_carrier_name>
<lcr_rate_field>0.12000</lcr_rate_field>
<lcr_gw_prefix>sofia/external/</lcr_gw_prefix>
<lcr_gw_suffix>%40proxy.carrier2.net%3A5060</lcr_gw_suffix>
<lcr_lead_strip>1</lcr_lead_strip>
<lcr_trail_strip>0</lcr_trail_strip>
<lcr_prefix>0</lcr_prefix>
</headers>
</event>
</row>
</result>
Then I parse the XML and grab the dialstring which is in this case
<dialstring>[lcr_carrier=carrier1,lcr_rate=0.15000]sofia/gateway/carrier1/1716</dialstring>
Then I use the dialstring (with some extra variables) in my originate command.

Mule: Invoking an Oracle stored procedure which returns a table of custom type

I am using Mule CE 3.6.1. I have the following Database connector configuration calling an Oracle stored procedure.
<db:stored-procedure config-ref="Oracle_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[call get_phone_email(:userId, :tPhoneRecord)]]></db:parameterized-query>
<db:in-param name="userId" type="NUMERIC" value="#[payload]" />
<db:out-param name="tPhoneRecord" type="ARRAY" />
</db:stored-procedure>
Parameter tPhoneRecord is defined as IS TABLE OF phone_email%ROWTYPE (i.e. table of records) in the stored procedure. I have tried specifying the parameter type ARRAY but get the error:
Message : Invalid argument(s) in call (java.sql.SQLException). Message payload is of type Object[]
Code : MULE_ERROR--2
I have also tried using other out-param types or not specifying a type without success.
Please let me know what out-param type I should use for an Oracle table of records, or if I should do this in Java instead. Many thanks in advance.
You can use the below solution for out parameter.
<db:oracle-config name="Oracle_Configuration" url="jdbc:oracle:thin:#54.175.245.218:1581:xe" user="user" password="4321" >
</db:oracle-config>
<db:data-type name="INtypename" id="12"/>
<!-- VARCHAR id=12 -->
<db:data-type name="OUTtypename" id="2002"/>
<!-- STRUCT id=2002 -->
</db:data-types>
...
<db:stored-procedure config-ref="Generic_Database_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[CALL storedprocfnc(:INtypename,:OUTtypename);]]></db:parameterized-query>
<db:in-param name="INtypename" value="#[payload]"/>
<db:out-param name="OUTtypename" />
</db:stored-procedure>

camel-mybatis - issues with calling Oracle Stored procedure with multiple resultsets

I am using camel-mybatis (version 2.12) component in Fuse 6.1 environment to invoke an oracle SP with 2 resultsets. The request is a HashMap and once mybatis maps the resultsets to java beans, the List is again saved in the original HashMap itself.
Here is the snippet of SqlMap:
<select
id="searchUsers"
parameterType="java.util.HashMap"
statementType="CALLABLE">
{call ORACLE.SP_NAME_1(
#{userId,mode=IN,jdbcType=VARCHAR},
#{maxResultsCount,mode=IN,jdbcType=DECIMAL},
#{view,mode=IN,jdbcType=VARCHAR},
#{statusInfo,mode=OUT,jdbcType=CURSOR,resultMap=statusInfoRowMap},
#{memberInfo,mode=OUT,jdbcType=CURSOR,resultMap=claimInfoRowMap})}
And here is how I invoke the mybatis component:
<setBody>
<groovy>
[
userId:'ID-1234',
maxResultsCount:20,
view:'MEMBER',
]
</groovy>
</setBody>
<to uri="mybatis:searchUsers?statementType=SelectOne" />
Since there are no result object (all the results are stored in the original requested HashMap itself), MyBatisProducer is setting null to exchange OUT message. The original body which contains the results from stored procedure is lost.
The Question is: is this the expected behaviour? mybatis component already stores the result in exchange header, so why to update the body as well?
The workaround I had to do was - to store the original body to a header, invoke mybatis and reset body from the header (which has the stored procedure result now) :
<setBody>
<groovy>
[
userId:'ID1234',
maxResultsCount:20,
view:'MEMBER'
]
</groovy>
</setBody>
<setHeader headerName="originalRequest">
<simple>${body}</simple>
</setHeader>
<to uri="mybatis:searchUsers?statementType=SelectOne" />
<setBody>
<simple>${in.headers.originalRequest}</simple>
</setBody>
<log message="status: ${body[statusInfo]}" />
Any help would be appreciated.. Thanks.
Ah well spotted. Log a JIRA ticket so we can improve this and avoid setting the body to null, when you use a stored procedure.
There is a link to the issue tracker here
http://camel.apache.org/support

How in ColdFusion with in variables get a Oracle stored procedure to return values?

ORACLE 11g - COLDFUSION 9 - REF CURSOR - WITH at least one in variable.
How in ColdFusion with in variables get a Oracle stored procedure to return values?
We have tried several things, we can get a stored procedure to return a result set if we are not passing in variables but we cannot get them when we are passing in variables.
We know how to do it calling MS SQL.
Thanks for any help
P.S. we have heard this may not be possible with the current Oracle Driver is there a different Oracle driver?
From what I have been reading online I am thinking this is not just a coding issue. I hope I am wrong about that. This is just an example I was working on as a proof of concept so I can start creating all of them. I can get it work if I am not using a ref cusor.
Error Executing Database Query.
[Macromedia][Oracle JDBC Driver]The specified SQL type is not supported by this driver.
The error occurred in D:\apache\htdocs\test\index.cfm: line 86
84 :
85 :
86 :
87 :
88 :
CF Call to procedure
<cfstoredproc procedure="BWNGDBADEV.PACK_REFCURSOR.GETALL" datasource="mydatasourcename" returncode="no">
<cfprocparam type="InOut" cfsqltype="CF_SQL_INTEGER" variable="pPERSONNELID" value="4" null="No">
<cfprocparam type="Out" cfsqltype="CF_SQL_REFCURSOR" variable="AnyVarName">
<!--- *** This name ties StoredProc results to the query below *** --->
<cfprocresult name="myvar">
</cfstoredproc>
Oracle Package
CREATE OR REPLACE
PACKAGE PACK_REFCURSOR
AS
TYPE EMP_TableRows
IS
REF
CURSOR
RETURN BWNGDBADEV.PER_PERSONNEL%ROWTYPE;
PROCEDURE GETALL(
pPERSONNELID IN OUT BWNGDBADEV.PER_PERSONNEL.PERSONNELID%type,
OUTTABLE OUT EMP_TableRows);
END PACK_REFCURSOR ;
/
CREATE OR REPLACE
PACKAGE BODY PACK_REFCURSOR
AS
PROCEDURE GETALL(
pPERSONNELID IN OUT BWNGDBADEV.PER_PERSONNEL.PERSONNELID%type,
OUTTABLE OUT EMP_TableRows)
IS
BEGIN
-- implicit cursor is opened - no close needed ***
OPEN OUTTABLE FOR
SELECT *
FROM BWNGDBADEV.PER_PERSONNEL
WHERE PERSONNELID = pPERSONNELID;
END GETALL ;
END PACK_REFCURSOR ;
/
do you have the latest DataDirect JDBC drivers ?
v 3.5 drivers and release notes here: http://kb2.adobe.com/cps/000/42dcb10a.html
the release notes suggest it fixes your exact problem
There's a small note in the docs stating: "You cannot use the cfprocparam tag for Oracle 8 and 9 reference cursors. Instead, use the cfprocresult tag."
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7d52.html
Try something along these lines:
<cfstoredproc
procedure = "BWNGDBADEV.PACK_REFCURSOR.GETALL"
dataSource = "mydatasourcename"
returnCode = "Yes">
<!--- cfprocparam tags --->
<cfprocparam type="InOut" cfsqltype="CF_SQL_INTEGER" variable="pPERSONNELID" value="4" null="No">
<cfprocparam type="Out" cfsqltype="CF_SQL_REFCURSOR" variable="AnyVarName">
<!--- cfprocresult tags --->
<cfprocresult name="RS1" resultSet="1">
<cfprocresult name="RS2" resultSet="2">
</cfstoredproc>

Resources