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
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 User Defined Function is SQL
Hi
I did the following test to see how expensive it is to use user defined functions in SQL queries, and found that it is really expensive.
Calling SQRT in SQL costs less than calling a dummy function that just returns
the parameter value; this has to do with context switchings, but how can we have
a decent performance compared to Oracle provided functions?
Any comments are welcome, specially regarding the performance of UDF in sql
and for solutions.
create or replace function f(i in number) return number is
begin
return i;
end;
declare
l_start number;
l_elapsed number;
n number;
begin
select to_char(sysdate, 'sssssss')
into l_start
from dual;
for i in 1 .. 20 loop
select max(rownum)
into n
from t_tdz12_a0090;
end loop;
select to_char(sysdate, 'sssssss') - l_start
into l_elapsed
from dual;
dbms_output.put_line('first: '||l_elapsed);
select to_char(sysdate, 'sssssss')
into l_start
from dual;
for i in 1 .. 20 loop
select max(sqrt(rownum))
into n
from t_tdz12_a0090;
end loop;
select to_char(sysdate, 'sssssss') - l_start
into l_elapsed
from dual;
dbms_output.put_line('second: '||l_elapsed);
select to_char(sysdate, 'sssssss')
into l_start
from dual;
for i in 1 .. 20 loop
select max(f(rownum))
into n
from t_tdz12_a0090;
end loop;
select to_char(sysdate, 'sssssss') - l_start
into l_elapsed
from dual;
dbms_output.put_line('third: '||l_elapsed);
end;
Results:
first: 303
second: 1051
third: 1515
Kind regards
TaoufikI find that inline SQL is bad for performance but
good to simplify SQL. I keep thinking that it should
be possible somehow to use a function to improve
performance but have never seen that happen.inline SQL is only bad for performance if the database design (table structure, indexes etc.) is poor or the way the SQL is written is poor.
Context switching between SQL and PL/SQL for a User defined function is definitely a way to slow down performance.
Obviously built-in Oracle functions are going to be quicker than User-defined functions because they are written into the SQL and PL/SQL engines and are optimized for the internals of those engines.
There are a few things you can do to improve function
performance, shaving microseconds off execution time.
Consider using the NOCOPY hints for your parameters
to use pointers instead of copying values. NOCOPY
is a hint rather than a directive so it may or may
not work. Optimize any SQL in the called function.
Don't do anything in loops that does not have to be
done inside a loop.Well, yes, but it's even better to keep all processing in SQL where possible and only resort to PL/SQL when absolutely necessary.
The on-line documentation has suggested that using a
DETERMINISTIC function can improve performance but I
have not been able to demonstrate this and there are
notes in Metalink suggesting that this does not
happen. My experience is that DETERMINISTIC
functions always get executed. There's supposed to
be a feature in 11g that acually caches function
return values.Deterministic functions will work well if used in conjunction with a function based index. That can improve access times when querying data on the function results.
You can use DBMS_PROFILER to get run-time statistics
for each line of your function as it is executed to
help tune it.Or code it as SQL. ;) -
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 NHi,
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 -
How to Use Sequence Object Inside User-defined Function In SQL Server
I'm trying to call sequence object inside SQL Server user-defined function. I used
Next Value for dbo.mySequence to call the next value for my sequence created. But I'm getting an error like below.
"NEXT VALUE FOR function is not allowed in check constraints, default objects, computed columns, views, user-defined functions, user-defined aggregates, user-defined table types, sub-queries, common table expressions, or derived tables."
Is there any standard way to call sequence inside a function?
I would really appreciate your response.
Thanks!The NEXT
VALUE FOR function cannot be used for User Defined function. It's one of the limitation.
https://msdn.microsoft.com/en-us/library/ff878370.aspx
What are you trying to do? Can you give us an example and required output?
--Prashanth -
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 pass table type variable into function from SQL*PLUS ?
How to pass a table type variable from sql*plus prompt into a function ?
Thanx in advance.Krishna,
Do you mean like this?SQL> DECLARE
2 TYPE t_tbl IS TABLE OF VARCHAR2(20);
3 l_sample_tbl t_tbl;
4
5 FUNCTION print_contents ( p_tbl IN t_tbl )
6 RETURN VARCHAR2
7 IS
8 l_string VARCHAR2(1000);
9 BEGIN
10 FOR i IN 1..p_tbl.COUNT LOOP
11 IF (i = 1) THEN
12 l_string := p_tbl(i);
13 ELSE
14 l_string := l_string || ', ' || p_tbl(i);
15 END IF;
16 END LOOP;
17 RETURN (l_string);
18 END print_contents;
19
20 BEGIN
21 l_sample_tbl := t_tbl();
22 l_sample_tbl.EXTEND;
23 l_sample_tbl(1) := 'one';
24 l_sample_tbl.EXTEND;
25 l_sample_tbl(2) := 'two';
26 l_sample_tbl.EXTEND;
27 l_sample_tbl(3) := 'three';
28 l_sample_tbl.EXTEND;
29 l_sample_tbl(4) := 'four';
30 l_sample_tbl.EXTEND;
31 l_sample_tbl(5) := 'five';
32 DBMS_OUTPUT.PUT_LINE(print_contents(l_sample_tbl));
33 END;
34 /
one, two, three, four, five
PL/SQL procedure successfully completed.
SQL> HTH,
T. -
Creating user defined function in sql server 2000
I have created a udf an i want to call it in another udf. will u please help me out how to create.
thank youAnd you ask that in an ORACLE forum? Brilliant idea... ;)
-
User define function for SQL Server
Hi all,
it's possible to write an UDF for SQL Server in Java?
I know that it is possible with DB2 and Oracle.
My main goal is to write an UDF that works well with all of these DB.
Thank'sHi all,
it's possible to write an UDF for SQL Server in
Java?Okay, JDBC can talk to any database (given you have a driver implementation). Also, JDBC is like a conduit. So the real question is likely, will your database let you do this?
I know that it is possible with DB2 and Oracle.
My main goal is to write an UDF that works well with
all of these DB.I also don't know what a UDF is, but if you ARE talking about stored procedures, then no, it's not possible. All databases are different. On that note, I typically recommend NEVER using stored procedures unless absolutely necessary.
But it also sounds like you want to do this at runtime. I've seen systems that do this (bind stored procs at runtime dynamically) and it's a freakin nightmare! So be careful. -
Where are User Defined Functions and Stored Procedures kept in SQL Server?
Hi,
I have a growing list of Stored Procedures and User-Defined Functions in SQL Server, and would like to be able to list all my user SP and UDF easily.
Is it possible to write a query to list all SP and UDF?
I saw the following specimen code in an SQL book, but am not sure this is what I need because I could not make it work.
SELECT *
FROM INFORMATION_SCHEMA.ROUTINES
WHERE SPECIFIC_SCHEMA = N'CustomerDetails'
AND SPECIFIC_NAME = N'apf_CusBalances'
I tried:
SELECT *
FROM INFORMATION_SCHEMA.ROUTINES
but it does not work.
Suppose all my SP are named following this pattern:
dbo.usp_Storeproc1
How would I modify the above code? or is there a better code?
Thanks
Leon LaiHi ,
try this to get list of all stored procedures:
SELECT *
FROM sys.procedures where name like 'dbo.usp%'
Thanks,
Neetu -
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.
-
? Regarding 'SQL user-defined function' execution performance ?
Hi All,
I have an user-defined function in SQL which am using in a SQL select statement and i found that the execution time taken by the user-defined function is 9-10 minutes as a result of which my whole query execution time is affected.
How to i improvise the execution time. Should i do some sort of scheduling for executing the user-defined functions only. Am new to the database world. Your early response with a good suggestion would really be appreciated.
Thanks in Advance.Try to read SQL tuning documents along with TkProf. Then only you will be able to detect the problem.
There is no instant method by which you can solve this problem.
But, you can get idea from this samples.
Tuning:
http://www.dba-oracle.com/art_sql_tune.htm
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::NO::P11_QUESTION_ID:8764517459743
Reading TkProf:
http://www.dbspecialists.com/presentations/use_explain.html
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:920429344869
Regards.
Satyaki De. -
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 -
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. -
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]
Maybe you are looking for
-
Sales Order/Item as Account Assignment in Accounting Doc.
I have a scenario where we are selling some services. Process is to create sales order --> Create billing document in reference to sales order & then release it to accounting. I am using materials of type DIEN( service) for the purpose and have custo
-
Why no Acrobat Pro 9 trial versions for Mac
I received my upgrade box for CS5 and the instructions said to delete (uninstall) Acrobat Pro 9 and then re-install it from the included disk. No big deal, I installed CS5 then uninstalled Acrobat as instructed, popped in the DVD of the new Acrobat P
-
Edit a secure interactive PDF form without regenerating form?
I have a client who needs for me to make a minor change to a password-secured interactive PDF form we've created for her. I have the password, of course, but Adobe Acrobate won't let me know enter the password without first saving the form as a copy.
-
Hi; How to set "Keep in Dock" settings selected when installing Adobe AIR application on Mac OS? Thanks...
-
My Privacy and Security settings are set to retain cookies but for some reason this information is not being stored at all. I cannot save bookmarks or even go back on my browser. Help!