Urgent Help Needed - Associating Statistics with User-Defined Functions
Hello,
We have an appication uses cost-based optimizer and uses a lot of TO_DATE and SYSDATE calls in FROM and WHERE clauses. For certain reasons, every call to TO_DATE and SYSDATE has been replaced by MY_TO_DATE and MY_SYSDATE respectively (which in turn call built-in functions). However, cost based optimizer is behaving strangely, which is understanble, based on the lack of user-defined functions statistics. I am under the impression that I should use something like:
ASSOCIATE STATISTICS WITH FUNCTIONS my_to_date DEFAULT SELECTIVITY ?;
ASSOCIATE STATISTICS WITH FUNCTIONS my_to_date COST (?,?,?);
ASSOCIATE STATISTICS WITH FUNCTIONS my_sysdate DEFAULT SELECTIVITY ?;
ASSOCIATE STATISTICS WITH FUNCTIONS my_sysdate COST (?,?,?);
but what should the values (?) be?. I guess I want to replicate TO_DATE and SYSDATE values, but how would I find out what they are? Thanks in advance...
P.S. I am also looking for workarounds (I cannot create a synonym for TO_DATE right?), so any help is welcome!!!
Hi emmalou69 ,
You told your actual parameter is
5, 5, 7.3 and 'z'
so change your method like
public static int test(int x, int y, double d, char ch)
because 5 - int; 7.3- float or double; z is char.
your method returns
public static int.
so you should return only int variable. but in your code you mentioned double. it's not correct.
The original code should look like
public class rubbish
public static void main(String args[]){
rubbish f = new rubbish();
f.test(5, 5, 7.3 ,'z');
public static int test(int x, int y, double d, char ch)
int value;
x = 5;
y = 5;
d= 7.3;
ch = 'z';
value =((int) d + x + y + ch);
System.out.println( x + ch + d + y);
return value;
}//here int value of z is 122.
and int(7.3) is 7
so 7+5+5+122 = 139.3
but value =((int) d + x + y + ch); returns 139. because you convert double to int that is 7.3 to 7
If it is useful, rate me duke dollars,
Thanks
Similar Messages
-
Problem with user-defined functions in XQuery String
hello
i've a problem with user-defined functions in XQuery String
details are here (the code is not Human-readable via forum's embedded editor ?? strange)
http://docs.google.com/Doc?id=ddqwddsr_21c96d9x
thanks !!See
michaels> select xmlquery('declare function local:test_function($namecmp as xs:string?, $inputtype as xs:string?) as xs:string?
return {$inputtype}
local:test_function("1","2")' returning content) o from dual
Error at line 5
ORA-19114: error during parsing the XQuery expression:
LPX-00801: XQuery syntax error at '{'
3 return {$inputtype}
- ^
michaels> select xmlquery('declare function local:test_function($namecmp as xs:string?, $inputtype as xs:string?) as xs:string?
$inputtype
local:test_function("1","2")' returning content) o from dual
O
2
1 row selected. -
Need help with user defined function
Hello SDN,
I need some help with a user-defined function. My source message contains multiple
generic records (1000 char string), and my target message is 1 header record,
then multiple generic records. See description of source and target messages below:
Source:
GenericRecordTable 1..unbounded
Row (1000 char string)
Target:
Field1 (char5)
Field2 (char5)
Field3 (char5)
IT_Data
GenericRecordTable 1..unbounded
Row (1000 char string)
Basically, what I need to do in my user defined funtion is to map the first record
in my source record to the 3 header fields, then map all of the rest of the records
(starting from line 2) into the GenericRecordTable.
Can someone please help me with the code for the user defined function(s) for this
mapping?
Thank you.hi,
Activities
1. To create a new user-defined function, in the data-flow editor, choose Create New Function (This
graphic is explained in the accompanying text), which is located on the lower left-hand side of the
screen. In the menu, choose Simple Function or Advanced Function.
2. In the window that appears, specify the attributes of the new function:
Name
Technical name of the function. The name is displayed in the function chooser and on the data-flow
object.
Description
Description of how the function is used.
Cache
Function type (see above)
Argument Count
In this table, you specify the number of input values the function can process, and name them. All
functions are of type String.
3. In the window that appears, you can create Java source code:
a. You can import Java packages to your methods from the Imports input field, by specifying them
separated by a comma or semi-colon:
You do not need to import the packages java.lang., java.util., java.io., and java.lang.reflect. since
all message mappings require these packages and therefore import them. You should be able to
access standard JDK and J2EE packages of the SAP Web Application Server by simply specifying the
package under Import. In other words, you do not have to import it as an archive into the Integration
Repository. You can also access classes of the SAP XML Toolkit, the SAP Java Connector, and the
SAP Logging Service (see also: Runtime Environment (Java-Mappings)).
In addition to the standard packages, you can also specify Java packages that you have imported as
archives and that are located in the same, or in an underlying software component version as the
message mapping.
b. Create your Java source text in the editor window or copy source text from another editor.
4. Confirm with Save and Close.
5. User-defined functions are limited to the message mapping in which you created the function. To
save the new function, save the message mapping.
6. To test the function, use the test environment.
The new function is now visible in the User-Defined function category. When you select this category,
a corresponding button is displayed in the function chooser pushbutton bar. To edit, delete, or add the
function to the data-flow editor, choose the arrow next to the button and select from the list box
displayed.
http://help.sap.com/saphelp_nw04/helpdata/en/d9/718e40496f6f1de10000000a1550b0/content.htm
http://java.sun.com/j2se/1.5.0/docs/api/
/people/krishna.moorthyp/blog/2006/07/29/documentation-html-editor-in-xi
/people/sap.user72/blog/2006/02/06/xi-mapping-tool-exports
http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm
UDF -
http://help.sap.com/saphelp_nw04/helpdata/en/22/e127f28b572243b4324879c6bf05a0/content.htm
Regards -
Help with User Defined Function
Hi
I want to code a UDF which comapres an array that contains "X" or empty values,with an array which contains only "X" and return a boolean array with boolean arguments (true/false)
I tried using the exisiting functions but I didnt find something relevant
Thx,ShaiFunc 1: public void ChkForX(String[] a,ResultList result,Container container){
int flag = 0;
int count = 0;
for (int i = 0; i<a.length; i++)
if(a<i>equals("X"))
{flag = 0; }
else
{flag = 1;
count = count + 1;
if(count > 0)
result.addValue("1");
else
{result.addValue("0");
Func 2:
public void ChkSpaces(String[] a,ResultList result,Container container){
int flag = 0;
int count = 0;
for (int i = 0; i<a.length; i++)
if(a<i>equals(" "))
{flag = 0; }
else
{flag = 1;
count = count + 1;
if(count > 0)
result.addValue("2");
else
{result.addValue("3");
Kinda use both these functions with the same input then further build your logic ... but still i dont think you will get a array as output using UDF -
Help: How to call a user defined function in a data block query?
I created a string aggregation function in the program unit, see reference:
http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
I now like to call the function in my data block query. I got the error: ORA-00904: 'concatenate_list' invalid identifier.
Please help.
Thank you in advance.
JimmyHi,
You can write UDFs in java in Graphical mapping to enhance your XI Graphical mapping functionality
The steps for doing it would be:
1. Click on Create New function Button found on Bottom left corner on your XI Mapping window.
2. Write your java code.
3. Run the Mapping Test as usual.
>>The module that is given here ...where and how it is used.
The adapters in the Adapter Framework convert XI messages to the protocols of connected external systems and the other way around. When doing so, some
functionality might need to be added specific to a situation which is possible with the use of custom modules.
Typical example would be validation of file content when using a File Adapter or modification of the message payload to a common content structure which is not supported by any of the standard SAP modules.
An Adapter module is developed as an Enterprise Java Bean and is called locally by the Adapter.
An example on modules :
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/da5675d1-0301-0010-9584-f6cb18c04805">How to develop a module for reading file name in a sender file adapter XI 3.0</a>
Cheers,
Chandra -
Problem with User-defined function
Does anyone know how to make the user-efined functionto return a object. We know how to run a java class within cal script and pass the result to that java class. However, what we need is to be able to return the result in the form of a java class within the calling class. This is because we are calling the calscript within ejb and the ejb that executes the calscript needs to be able to get the result back.In our case, we are using webLogic EJB to execute a EDS calScript function. We don't know how to have the object created by EDS to be passed back to the EJB.Any insight will be greatly appreciated.Thanks,Anne
Hi Anoop,
The query and function work fine for me. What does the line and column information in the error point to?
John -
Problem with user defined function in XQUERY
Hi,
I have a file in which I store XQUERY. My java program reads this file and executes the xquery
and output the result. I have a working XQUERY in a file, which is something like :
<feed>
let $entries := for $x in collection('/path/to/atomStore.bdbxml')/entry[matches(id,'
.entry')]
order by $x/updated descending
return <entry xmlns="http://www.w3.org/2005/Atom">{$x/id,$x/title,$x/published,$x/updated,$x/link}
</entry>
let $latest := fn:subsequence($entries, 1, 10)
for $f in $latest return $f
</feed>
After adding the following simple function(I'm not calling it anywhere for the time being),
I'm getting an error
com.sleepycat.dbxml.XmlException: Error: Error in XQuery expression:
Unrecognized character 'a' (0x61) [err:XPST0003], line 33, column 2, errcode = XPATH_PARSER_ERROR
declare function xml:convertdate($date as xs:integer) as xs:string
let $months := ("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec")
let $month := $months[$date]
return $month
I couldn't find any error with the function syntax. Anyone has any idea?
Regards,
AnoopHi Anoop,
The query and function work fine for me. What does the line and column information in the error point to?
John -
Base64 decode with user defined function called from xslt
I have an xml document which has a segment containing a b64 encoded attachment.
I would like to decode the attachment as i map it.
I would think this could be done by using a java function of some kind being called from the xslt however i have very limited experience in this and none in how to code the decoding.
Anyone have an example ?
Cheers
Jon>
Jon Vaugan wrote:
> I have an xml document which has a segment containing a b64 encoded attachment.
> I would like to decode the attachment as i map it.
>
> I would think this could be done by using a java function of some kind being called from the xslt however i have very limited experience in this and none in how to code the decoding.
>
> Anyone have an example ?
>
> Cheers
> Jon
yes SDN seems to have an example for you....it may not exactly solve your problem...but yes it not irrelevant.....you just need to do some R&D
/people/farooq.farooqui3/blog/2008/05/22/decode-base64-incoming-encoded-information-in-sap-xipi-using-java-mapping
Regards,
Abhishek -
Using decode in where clause with user defined function
Hi,
I have a below query which is failing as the function in the decode taking all cust_account_id as input parameter instead of the one which satisfies the condition in the inner query.So please provide a solution how can i pass only the selected one.
SELECT hca.cust_account_id
FROM hz_cust_accounts hca
WHERE hca.org_id=FND_PROFILE.value('ORG_ID')
AND hca.cust_account_id = (SELECT DISTINCT hcasa.cust_account_id
FROM hz_cust_acct_sites_all hcasa
WHERE hcasa.cust_account_id =hca.cust_account_id
AND hca.org_id = hcasa.org_id)
AND DECODE (hca.status , 'A', xx_ar_cust_audit_pkg.get_ship_to_order_type(hca.cust_account_id)) IS NOT NULL
Thanks,
AbhilashI'm having to guess without access to your tables, but I think changing the IN to a join should produce the same results. The JOIN should be evaluated before applying the WHERE clause, so this may resolve your problem.
SELECT hca.cust_account_id
FROM hz_cust_accounts hca
INNER JOIN hz_cust_acct_sites_all hcasa
ON hcasa.cust_account_id = hca.cust_account_id
AND hca.org_id = hcasa.org_id
WHERE hca.org_id = FND_PROFILE.value('ORG_ID')
AND DECODE (hca.status , 'A', xx_ar_cust_audit_pkg.get_ship_to_order_type(hca.cust_account_id)) IS NOT NULLAlternately, you could next part of the query and break the DECODE into the parent so it is evaluated after the inner query. This is likely uglier from a performance standpoint, though:
SELECT cust_account_id
FROM
SELECT hca.cust_account_id, hca.status
FROM hz_cust_accounts hca
WHERE hca.org_id=FND_PROFILE.value('ORG_ID')
AND hca.cust_account_id = (SELECT DISTINCT hcasa.cust_account_id
FROM hz_cust_acct_sites_all hcasa
WHERE hcasa.cust_account_id =hca.cust_account_id
AND hca.org_id = hcasa.org_id)
WHERE DECODE (status , 'A', xx_ar_cust_audit_pkg.get_ship_to_order_type(cust_account_id)) IS NOT NULL; -
User-Defined Function and Context Manipulation
Hi Mapping Gurus, I need your help.
I have a user-defined function and one of my input parameter (c) is in a loop (EDI segment). So one, if I execute my function I get:
Exception:[java.lang.ArrayIndexOutOfBoundsException: 0]
If I change the context or use the remove context node function its working but its always taking the first row in consideration since I'm using c[0] . Here is the logic:
String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[0]"'";
So since c is an array [], I have tried different logic to get to the right row.
1- I tried using another parameter (e) to pass a counter or an index to my function. So each time it's looping, it's passing a new value to the function but Im still getting the first row and Im not to sure why?
int G = Integer.parseInt(e[0]); // e[] = My counter field
String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
2- I tried using a parameter stored in the container:
String Num;
Num = (String)getParameter(counter);
if (Num == null) G = 0;
else
G = Integer.parseInt(Num);
G = G + 1;
String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
Num = "" + G;
setParameter(e[0], Num);
and Im still getting the first one, look like its using a different container each time its looping so the Value is always the same?
4- I created a new user-defined function with the container logic, then its working but Im back to the same problem in my main function, its only looking at e[0] for my counter all the time.
5- I tried using the Seeburger Java Variables and guess what in the main fonction, as new UDF,... and guess what, same result!
So anybody out there that was able to get UDF's working into a multiple context scenario?
Am I missing something?
I will reward points and beer for any help!This is one of the text with passing a counter to the function to try to go to the right row in the array since I'm doing a remove context and I'm getting all the d_234's:
public void ReadTable(String[] a,String[] b,String[] c,String[] d,String[] e,ResultList result,Container container){
int G = Integer.parseInt(e[0]); // My counter
String var;
String DBTABLE = a[0];
String lookUpField = d[0];
String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
Now this one was with the internal container logic:
int G;
String DBTABLE = a[0];
String lookUpField = d[0];
String Num;
Num = (String)getParameter(e[0]);
if (Num == null) G = 0;
else
G = Integer.parseInt(Num);
G = G + 1;
Num = "" + G;
setParameter(e[0], Num);
String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
And now with the Seeburger Variables:
int G;
try {
VariableBean be=VariableFactory.getVariableInstance("");
G = Integer.parseInt(String.valueOf(be.getStringVariable("yves")));
} catch (Exception f) {
throw new RuntimeException(f);
String DBTABLE = a[0];
String lookUpField = d[0];
String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
try {
G = G + 1;
Num = "" + G;
VariableBean be=VariableFactory.getVariableInstance("");
be.setStringVariable("yves",Num);
catch (Exception f) {
throw new RuntimeException(f);
All 3 logics were returning always the first row or a counter of 1 if the logic is in the main ReadTable function. -
Are Sql functions different from user defined functions ?
Hello,
SQL functions are built into Oracle Database and are available for use in various appropriate SQL statements. Do not >confuse SQL functions with user-defined functions written in PL/SQL.according to first paragraph of this document Sql functions are different from user defined functions . How is that ?
Is they really differ from each other ?bootstrap wrote:
If you don't know what compilation is, please use Wikipedia or other online resources.I know what is compilation . But i was confused whether those sql functions are compiled in my machine when i install Oracle Database in my machine or they are pre-compiled .
As you said these Sql functions are pre-compiled , it is clear now that they are pre-compiled platform dependent code .
Can you provide actual source code of any SQL function , say SUM function .
I want to see it, how they have defined . Eagerly waiting for any reply. please help .
Edited by: bootstrap on Aug 19, 2011 11:50 AMYou can ask oracle if they give you their code. I doubt they will. However if you want to write you own user-defined aggregation function, there are examples in the documentation how to do that.
http://download.oracle.com/docs/cd/E11882_01/appdev.112/e17125/adfns_packages.htm#i1008575
Edited by: Sven W. on Aug 19, 2011 9:24 AM -
User defined function in a cursor
Hi All,
I need to use a user defined function(which returns a value based on my Procedure's input parameter) in my explicit cursor. Something like
create or replace procedure test(pi_input number)
cursor c1
is
select col1,
col2,
func(pi_input),
col4
from table;
begin
end;
Is this possible? IHi,
User-defined functions can appear in SQL statements, including cursors, if they follow certain rules (e.g., all arguments are IN arguments, in one of the SQL data types).
You really need to post your code. You don't need to post the compete code; a simplified version that gets the same error would serve just as well (actually better). Include CREATE TABLE and INSERT statements for any tables used, the function code, the code that calls the function, and the results you want from that code, given the sample data you posted.
Explain, using specific examples, how you get those results from that data.
Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002
Does your function work the way you want when it is not in a cursor? -
How to use a user defined function in where cluase condition
Hi,
I have designed a query by selecting some columns in the tables and some columns are retrieved directly from table and some columns are passing to a user defined function. Now my requirement is i need to use that user defined function result in oracle where condition clause.
Ex : select marketing_user_id,get_name(marketing_user_id),item_id,get_item_name(item_id),get_country_name(country_id),
from
where get_item_name(item_id) in ('x','y','z')
and get_country_name(country_id) in ('India','America','China');
When am i trying the query by above format i am getting the wrong resultset.
BR,
umaI am not sure why your getting the wrong results but you should seriously reconsider the approach your are taking. Using functions like this is very ineffecient and should be avoided at all cost.
-
Urgent help needed with un-removable junk mail that froze Mail!!
Urgent help needed with un-removable junk mail that froze Mail?
I had 7 junk mails come in this morning, 5 went straight to junk and 2 more I junked.
When I clicked on the Junk folder to empty it, it froze Mail and I can't click on anything, I had to force quit Mail and re-open it. When it re-opens the Junk folder is selected and it is froze, I can't do anything.
I repaired permissions, it did nothing.
I re-booted my computer, on opening Mail the In folder was selected, when I selected Junk, again, it locks up Mail and I can't select them to delete them?
Anyone know how I can delete these Junk mails from my Junk folder without having to open Mail to do it as it would appear this will be the only solution to the problem.Hi Nigel
If you hold the Shift key when opening the mail app, it will start up without any folders selected & no emails showing. Hopefully this will enable you to start Mail ok.
Then from the Mail menus - choose Mailbox-Erase Junk Mail . The problem mail should now be in the trash. If there's nothing you want to retain from the Trash, you should now choose Mailbox- Erase Deleted Messages....
If you need to double-check the Trash for anything you might want to retain, then view the Trash folder first, before using Erase Junk Mail & move anything you wish to keep to another folder.
The shift key starts Mail in a sort of Safe mode. -
User Defined Function (UDF) help required. Pls advice urgent.
Hi ,
CRM -- XI (UDF) -- Socket Connection
Now in User Defined Function (UDF) of Message Mapping I will open Socket Connection.
Send CRM XML request to socket and get XML response from Socket and then map to some system.
Can I write Java Class code in User Defined Function (UDF) of Message Mapping instead of Java Mapping in blog below?
/people/saravanakumar.kuppusamy2/blog/2005/12/15/socket-integration-with-xi
RegardsHenry,
Do you have a structure for your response...if you do then you can do extended reciever det with sync/async..shouldent matter, i just tried it and i dont get any error.
in your reciever determination..Check the box for standard rec det then add your first condition..of the value of a field to true..then send to A..
then you select add condition..and add for second reciever..that should be it, you shouldent need a bpm for such a simple scenario..it definetly is an overkill.
Regards
Ravi Raman
Maybe you are looking for
-
Wish to map network drives on the iMac. Any thoughts?
-
How can I find out if someone has stolen my Apple ID?
Hi there, I have updated my Iphone with the latest version of the Itunes. I tried to log on using my Apple Account and it didn't recognised my password. Then I used my computer to rset the password. I answered all the security questions and I receive
-
Poor quality when importing SVG graphics to FrameMaker
Hi! I have run into some problems using svg-files in FrameMaker. My ex colleague has created several pictures in Illustrator, that he has used in our FrameMaker files. They all displayed nicely and printed well both on paper and pdf, when using his c
-
Cannot Move iTunes Library To External HD
Hey Guys, It just comes up with that one or more things are in use. I haven't got my iTunes open and nothing is using any of the songs, or anything. I have also restarted my machine several times, any ideas? Thanks.
-
Business Rules Web Launcher error
All, EAS version : 9.3.1.3 Business Rules version: 9.3.1.1 Accessing EAS web is working fine. Getting the following error when I am trying to use Business Rules Web launcher An error occurred: Login Failed. Please login again. Error Message:Error log