How to use StreamTransformationException in user-defined function?
Hi,
I'm doing a DBLookup (using Java pgm in one of my Imported Java archives) for populating one of the fields in message mapping. If the DB connection fails, I want to terminate the mapping by throwing a StreamTransformationException from within a user-defined function.
I require urgent help in this regard.
Thanks in advance.
Regards,
Sridhar Rajan N
Hi,
I had the same problem. I failed to find the way how to throw a StreamTransformationException in my user-defined function. But I used another exception: NullPointerException. Yes, I know, this is not an elegant solution...
Best regards,
Andrzej Filusz
Similar Messages
-
How do you create a user defined functions UDF and passing a value like a ID to GEt a Value.
How do you create a user defined functions UDF and passing a
value like a ID to GEt a Value.
using a query.
are there example.
Thankstons of examples at cflib.org - good place to start, even
though many
udfs there are a bit outdated in their code...
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com -
Using a SQL user-defined function in Crystal Reports XI
Post Author: JoannKarp
CA Forum: Formula
Is it possible to use a user defined function in SQL and use this in multiple Crystal reports?
JoannKarpSELECT COALESCE(ufn_GetAddressByBusinessEntityIDandAddressTypeID(table1.BusinessEntityID,712),ufn_GetAddressByBusinessEntityIDandAddressTypeID(table1.BusinessEntityID,712)) AS Zipcode
FROM table1
Nope. This is two function calls. coalesce(a, b, c, ...) is just syntatic sugar for
CASE WHEN a IS NOT NULL THEN a
WHEN b IS NOT NULL THEN b
WHEN c IS NOT NULL THEN c
END
But if you use isnull it's a different matter. (But isnull() permits two arguments.)
Erland Sommarskog, SQL Server MVP, [email protected] -
HOW TO CREATE A GLOBAL USER DEFINED FUNCTION
Hi Expert,
I'd like to know if there is a way to globalize a user defined function?
I'd like to reuse a user defined function (e. g. DeleteLeadingCharacter) in several scenario/SWC instead of recreated it from scratch everytime - Is it possible?
ThanksNO you cannot not reuse one UDF not even in other namespace even in the same namespace in diff Mapping programme.
UDF is liminted to GraphicalMappingProgramme that you created you cannot reuse it in other MappingProgrammes.
Like your MM =A has function <b>getMyName</b>
you can use it in MM=A but if you want to use it in MM=B then u cannot.
So its not possible in XI or PI.
But it is possible in new release PI 7.1. That says you can write UDF and can reuse in any MM programme.
Thanks
Farooq.
*Rewards Points if you find it useful* -
How to use negation in user defined rules?
Hi,
Can you please show me an example to use negation in user defined rule? I created a rule like below (the rule says if a patient has a fever problem and not have penicillin hypersensitivity, then recommend medication1):
INSERT INTO mdsys.semr_myMedicineRB VALUES('rule1',
'(?p rdf:type :Patient) (?p :present ?c1) (?c1 rdf:type :Fever) (?c2 rdf:type :Penicillin_Hypersensitivity)',
'(NOT_EXISTS(p :present c2))',
'(?p :recommendation :medication1)',
SEM_ALIASES(SEM_ALIAS('','http://www.example/medicine#')));
The rule successfully inserted into the rulebase. However, I cannot pass the entailment creation phase and got the errors:
ORA-29532: Java call terminated by uncaught Java exception: java.sql.SQLException: Missing IN or OUT parameter at index:: 1
ORA-06512: at "MDSYS.SDO_SEM_INF_INTERNAL", line 16453
ORA-06512: at "MDSYS.SDO_SEM_INFERENCE", line 302
ORA-06512: at "MDSYS.SDO_SEM_INFERENCE", line 352
ORA-06512: at "MDSYS.RDF_APIS", line 118
ORA-06512: at line 2
29532. 00000 - "Java call terminated by uncaught Java exception: %s"
*Cause: A Java exception or error was signaled and could not be
resolved by the Java code.
*Action: Modify Java code, if this behavior is not intended.
According to the post built-in primitives(noValue,remove) for user defined rules, it seems negation is not supported in user defined rules. Can you please advice how to implement negation in user defined rules? Thanks a lot in advance.
HongHi Hong,
Let's look at this similar but simplified problem:
if (?p rdf:type :Patient) and (NOT_EXISTS(?p :present :c2)) ==> (?p :recommendation :medication1)
You can use something like this in the user defined inferencing:
-- First get the numeric IDs for the relevant URIs
recomID := sdo_sem_inference.oracle_orardf_add_res('http://..../recommendation');
medID := sdo_sem_inference.oracle_orardf_add_res('http://..../medication1')
rdfTypeID := sdo_sem_inference.oracle_orardf_res2vid('... full URI for rdf:type');
patientID := ...
presentID := ...
c2ID := ...
-- Now this query will find out ?p that satisfy (?p rdf:type :Patient) but not
-- (?p :present :c2)
sqlStmt := '
select ids1.sid sub
from ' || src_tab_view || ' ids1
where ids1.pid= ' || to_char(rdfTypeID,'TM9') || '
and not exists (
select 1
from ' || src_tab_view || '
where sid = ids1.sid
and pid = ' || to_char(presentID, 'TM9') || '
and oid = '|| to_char(c2ID,'TM9') || '
insertStmt := '
insert /*+ parallel append */
into ' || output_tab || '(sid, pid, oid)
select sub, '||to_char(recomID,'TM9') || ',' || to_char(medID,'TM9') || '
from (' || sqlStmt || ')'
More details can be found in
http://docs.oracle.com/cd/E16655_01/appdev.121/e17895/inference_extension.htm#CHDDBGEC
Hope it helps,
Zhe Wu -
How to call Microsoft SQL User defined function??
I am trying to call Miscrosoft SQL user defined function (not stored procedure) and experience problems. The function -- func_profile_history takes 3 inputs and returns resultSet.
Please let me know if there is any examples some where. All the examples I found are for stored procedure.
Thanks....
Siu
************ source *************
public Vector callSqlFunction(String eidTradcom, String idSku, String endDate, String idUserPost)
throws TradcomException, RemoteException
System.out.println("--------------in callSqlFunction--------------1");
Connection conn = null;
java.sql.CallableStatement cstmt = null;
ResultSet rs = null;
ForecastInfo info = null;
Vector v = new Vector();
try{
conn = TradcomUtils.getConnection();
String sql = "{call func_profile_history(?,?,?)}";
System.out.println("--------------in callSqlFunction--------sql="+sql);
cstmt = conn.prepareCall(sql);
System.out.println("--------------in callSqlFunction-------2");
cstmt.setString(1, eidTradcom);
cstmt.setString(2, idSku);
cstmt.setString(3, endDate);
System.out.println("--------------in callSqlFunction-------3");
rs = cstmt.executeQuery();
System.out.println("--------------in callSqlFunction-------4");
while (rs.next()){
info = new ForecastInfo ();
info.setEidTradcom(rs.getString("eid_tradcom"));
info.setIdSku(rs.getString("id_sku"));
info.setQtOnHand(rs.getDouble("qt_on_hand"));
info.setQtOnHold(rs.getDouble("qt_hold"));
info.setQtNetOnHand(rs.getDouble("qt_net_on_hand"));
info.setQtAlloc(rs.getDouble("qt_alloc"));
info.setQtAvailUnalloc(rs.getDouble("qt_avail_unalloc"));
info.setQtPoShip(rs.getDouble("qt_po_ship"));
info.setQtPoRcvd(rs.getDouble("qt_po_rcvd"));
info.setQtTransit(rs.getDouble("qt_transit"));
info.setQtAsn(rs.getDouble("qt_asn"));
info.setQtPo(rs.getDouble("qt_po"));
info.setQtPoBalance(rs.getDouble("qt_po_balance"));
info.setQtSoShip(rs.getDouble("qt_so_ship"));
info.setQt4Cast(rs.getDouble("qt_4cast"));
v.addElement(info);
System.out.println("--------------in callSqlFunction-------5");
System.out.println("--------------in callSqlFunction-------v="+v);
return v;
}catch(Exception ex){
System.out.println("Error in callSqlFunction:"+ ex.getMessage());
throw CachingManager.getTradcomException(ex, "Error in callSqlFunction");
}finally{
try{ if (cstmt != null) cstmt.close(); } catch(Exception ex){}
try{ if (conn != null) conn.close(); } catch(Exception ex){}
********************* error output ***************
********************* bef calling callSqlFunction
--------------in callSqlFunction--------------1
--------------in callSqlFunction--------sql={call func_profile_history(?,?,?)}
--------------in callSqlFunction-------2
--------------in callSqlFunction-------3
Error in callSqlFunction:The request for procedure 'func_profile_history' failed
because 'func_profile_history' is a function object. Severity 18, State 1, Proc
edure 'LAP_DUAL null', Line 4
ERROR=Error in callSqlFunction...The request for procedure 'func_profile_history
' failed because 'func_profile_history' is a function object. Severity 18, State
1, Procedure 'LAP_DUAL null', Line 4well, I tried the preparedStatemnet and it worked. Case closed.
-
Using a scalar user defined function in a select case statement
I have a simple select statement below and I want to have a case statement for some conditions based on the result of the udf returned value. I then want the returned value from that specific case statement to be returned where i have indicated 'DISPLAY
ZIPCODE' below.
SELECT
CASE
WHEN (SELECT Top 1 ZipCode FROM ufn_GetAddressByBusinessEntityIDandAddressTypeID(table1.BusinessEntityID,712) IS NOT NULL THEN 'DISPLAY ZIPCODE'
WHEN (SELECT Top 1 ZipCode FROM ufn_GetAddressByBusinessEntityIDandAddressTypeID(table1.BusinessEntityID,714) as r) IS NOT NULL THEN 'DISPLAY ZIPCODE'
ELSE NULL
END as Zipcode,
FROM
table1SELECT COALESCE(ufn_GetAddressByBusinessEntityIDandAddressTypeID(table1.BusinessEntityID,712),ufn_GetAddressByBusinessEntityIDandAddressTypeID(table1.BusinessEntityID,712)) AS Zipcode
FROM table1
Nope. This is two function calls. coalesce(a, b, c, ...) is just syntatic sugar for
CASE WHEN a IS NOT NULL THEN a
WHEN b IS NOT NULL THEN b
WHEN c IS NOT NULL THEN c
END
But if you use isnull it's a different matter. (But isnull() permits two arguments.)
Erland Sommarskog, SQL Server MVP, [email protected] -
How do I modify a user-defined function in SQL Plus
I have created some functions in my database. Can anybody tell me how to modify/edit those functions?
PS C:\> $Class2 = New-Object MyTest.Class1
PS C:\> $Class2
MyString Struct1Property Struct2Property
MyTest.Struct1 MyTest.Class1+Struct2
PS C:\> $Struct2 = New-Object MyTest.Class1+Struct2
PS C:\> $Struct2.Property = "X"
PS C:\> $Struct2
Property
X
PS C:\> $Class2.Struct2Property = $Struct2
PS C:\> $Class2.Struct2Property.Property
XPS C:\> $Struct2.GetType()
IsPublic IsSerial Name BaseType
False False Struct2 System.ValueType
Struct2 is a valuetype, (by value)
The classes are by reference
PS C:\> $Struct3 = $Class2.Struct2Property
PS C:\> $Struct3
Property
X
PS C:\> $Struct3.Property = "Y"
PS C:\> $Class2.Struct2Property.Property
X
PS C:\> $Class2.MyString = "A"
PS C:\> $Class3 = $Class2
PS C:\> $Class3.MyString = "B"
PS C:\> $Class2.MyString
B -
Using Xquery predefined functions in User defined functions
Hi All,
I have a requirement of calling a user defined function in osb xquery file.In that function i have to use osb predefined string functions but they are not working it shows error message in xquery file.Can you please suggest how to use them in user defined functions.
Thanks,
Srinivas.Hi Eric,
I have a Proxy service it reads mfl data and transform to some other schema.In this Transformation one element data is taken and we have to manipulate that data
based on the incoming value and return .For this process i took one function and i have to check weather it contains some symbols like ^,~ so i used contains function of
String with and with out prefix with if else condition it gives error "Unexpected token if"
declare function insp:buildReferenceRange($inRange as xs:string)
as xs:string
let $low:=""
l
if(contains($inRange,"^")) //"Unexpected token if"
name space and prefix are defined in the top of file.
Thanks,
Srinivas. -
How many types of user defined functions are there?
how many types of user defined functions are there?
Hi Ramakrishna,
A user-defined function is only visible in the message mapping in which you created it. You can insert the function in the data-flow editor as a standard function by using the User-Defined function category.
You can use the following user-defined functions:
1.Simple functions, which can process individual field input values for each function call. Simple functions therefore expect strings as input values and return a string.
2.Advanced functions, which can process several field input values for each function call. You can import either all field values of a context or the whole queue for the field in an array before calling the function. For more information, see Advanced User-Defined Functions.
go through :
http://help.sap.com/saphelp_erp2004/helpdata/en/22/e127f28b572243b4324879c6bf05a0/content.htm
Advanced user-defined functions, which can process more than just individual field values.Instead, you can import a complete context or an entire queue for a field as an array before your function is called
go through :
http://help.sap.com/saphelp_erp2004/helpdata/en/f8/2857cbc374da48993c8eb7d3c8c87a/content.htm
*Pls: Reward points if helpful*
Regards,
Jyoti -
Error while using user defined function in reports
Hi,
When I use the below user defined function in oracle reports I got the wrong number of arguments error
select test_function(id,a_number,v_date-14,b_number) from dual;
If I remove -14 from the argument it works. But iIneed to subtract 14 days from the date.
Thanks for your help.select test_function(id,a_number,v_date-14,b_number) from dual;
you have to give the command like this to_date(v_date,'dd-mon-yyyy')-14
because the v_Date you choose in the parameter form is not having the corrent date format
the format dd-mon-yyyy is the format in which v_date is passed by the user. -
USER DEFINED FUNCTION in the formula editor
How do you create a USER DEFINED FUNCTION in the formula editor using BADI
<a href="http://help.sap.com/saphelp_nw04/helpdata/en/04/f3683c05ea4464e10000000a114084/frameset.htm">This</a> may help.
-
Calling user defined functions through OBIEE
Can anyone tell me how I can call the user defined functions on database through the new BI tool.
The idea is to collect certain parameters through the prompt when launching the request, the function is supposed to pick up the parameters, make a certain calculation, and return a value.
I wrote the function, I just need help over how to call the function through the BI tool - that was pretty easy in the old Discoverer.
Thanks.
Message was edited by:
user611377Hi Kresimir ,
You can use EVALUATE function to call a user defined function.
EVALUATE('FUNCTIONNAME(%1,..)' As DATATYPE,parameter1,...)
Here DATATYPE is the returntype of function.
Hope this will help.
Thanks
Ashok -
Determine Element maxLenght in User-Defined Function
Hi,
I have the problem, that I have to fill up several fields with leading 0. I wrote a User-Defined Function for this. But the function doesn't know how long this element is, so I have to give the function the length of the element.
Is it possible to determine the length of the current element in an extended User-Defined Function
Yours
ThomasHi,
>use a simple user defined function with the desired
>source element as input and give the following code...
>int k = a.length();
>String len = Integer.toString(k);
>return len;
That function will only give me the actual lenght of the input element, what I need is the max lenght of the target element...
>You can also use the built-in FormatNumber function to
>insert leading 0s.
How can I use this function to add leading zeros?
"'000'#" ? But there I have to do this for every element
>I think an easy solution for this is, just have a
>simple function with two arguments. The first is the
>element, the second is a constant, where you put the
>length.
Well I have this function. But I am looking for way to the safe the second argument ;o)
Thank you all for your help
Thomas -
Advanced User Defined Function
Dear All,
I have a target structure as follows:
<Item>
<Record10>
<RecordType>
<BankCode>
<AccountID>
<Amount>
</Record10>
<Record50>
<RecordType>
<Segment1>
<segment2>
<segment3>
</Record50>
</Item>
I want to fill the elements in the Record50 in a special way by using some logic. Sometimes I may have to create multiple Record50 structures. So I'm using an advanced user defined function to do this.
My mapping is as follows:
Source Structure -> myFunction()->Record50
And in myFunction() I wrote the following piece of code:
result.addValue("50");
result.addValue("PayRef1");
result.addValue("Address");
result.addValue("Nil");
I expect the output to be:
<Record50>
<RecordType>50</RecordType>
<Segment1>PayRef1</Segment1>
<segment2>Address</segment2>
<segment3>Nil</segment3>
</Record50>
But the output is like this:
<Record50>50</<Record50>
<Record50>PayRef1</<Record50>
<Record50>Address</<Record50>
<Record50>Nil</<Record50>
Can somebody tell me how to proceed? I tried to insert a context change in the beginning, but then the Record50 itself is not appearing.
Thanks,
SandeepHi,
Advanced UDF will not create you like you expected.
You need to do like this
Source>myFunction1()-><RecordType>
And in myFunction() you do code:
result.addValue("50");
Source>myFunction2()-><Segment1>
And in myFunction2() you do code:
result.addValue("PayRef1");
so on..
Thanks,
Prakash
Maybe you are looking for
-
Weighted Average in Pivot View
Hi, Can you please throw some light on the below scenario based on weighted average: For Ex: Cloumn1---Column2-----Column3 R1-----------Line Item1--10 R1-----------Line Item2--20 R2-----------Line Item3--30 R2-----------Line Item4--40 Now i am trying
-
Can't send mail in IMAP accounts after installing Mavericks. Incoming messages OK.
I'm unable to send mail in IMAP accounts after installing Mavericks. Incoming is OK. Any suggestions on how to resolve, please?
-
I show 4 app updates needed on my ipad2 but none there when open App Store.
I cannot update my apps even though it shows 4 updates needed on my iPad 2. Anyone else having this issue?
-
How do I exchange downloaded Photoshop Premiere for Photoshop Elements?
Thought I downloaded PHotoshop Elements, but it seems to be Photoshop Premiere Elements. How do I exchange for what I want?
-
Directly change an objects variable
Hi everyone, I'm a bit rusty with my ABAP, and I was hoping you could help. I have my object called 'value', which has many classes in it, and each of these classes have variables. My question is, how do I directly access those variables through the