Return value from database function taking a lot more time than the query
Hi guys,
I have a Query that does a call to a database function. The function takes in a few parameters and returns a Date. Now, the query within the function takes barely .05 seconds. However, doing a select get_join_dates from dual is taking almost 6 seconds for each call.
Here is the Query:
select s.student_id, s.student_name, s.organization_code
from student s
where s.student_id = :p_student_id
and s.student_enrollment_date = get_join_dates( :p_year,
:p_month,
:p_student_id,
s.organization_code );And here is the database function. The select inside this function barely takes 0.05 seconds per call. This function gets called 3 times in my case as there are 3 records in the org_body table for this student.
create or replace function
get_join_dates( p_yyyy in org_body.fiscal_yyyy%type,
p_month in org_body.fiscal_mm%type,
p_student_id in student.student_id%type,
p_organization_code in org_body.organization_code%type) return date as
t_enrollment_date date;
cursor cur_latest_enrollment_date is
select max(enrollment_date)
from org_body
where fiscal_yyyy = p_yyyy
and fiscal_mm = p_month
and student_id = p_student_id
and organization_code = p_organization_code;
BEGIN
open cur_latest_enrollment_date ;
fetch cur_latest_enrollment_date into t_enrollment_date;
close cur_latest_enrollment_date ;
return t_enrollment_date;
exception
when others then
null;
end;owever, when I run the following statement below, it takes close to 6 seconds to retrieve a record. In turn, my Query is becoming really slow and taking almost 35 seconds. Imagine that with more records.
select get_join_dates( 2010, '01', '2167543', 'PSYCH01' ) from dual;If I run my query with this condition below, it takes 0.5 seconds.
select s.student_id, s.student_name, s.organization_code
from student s
where s.student_id = :p_student_id
and s.student_enrollment_date = '01-JAN-10'Any ideas would be greatly appreciated.
Any reason why you are doing this with the stored function?
You could just do this with SQL. Embed the query in the function as a subquery in your initial query from STUDENT.
select s.student_id, s.student_name, s.organization_code
from student s
where s.student_id = :p_student_id
and s.student_enrollment_date =
(select max(enrollment_date)
from org_body
where fiscal_yyyy = :p_year
and fiscal_mm = :p_month
and student_id = s.student_id
and organization_code = s.organization_code);Why your function is not performing: I cannot say that with the information you have provided.
Maybe sqltrace a call and see what the reason is.
Similar Messages
-
My Mac is taking a lot more time to load photos from iPhone and iPad than was taking before.What can be the reason of it ?
ThanksDO NOT INSTALL MACKEEPER or any other so called 'cleaning ' application. Please read the following user tip:
https://discussions.apple.com/docs/DOC-3036
Look for reasons in this user tip for your issues of slow operation:
https://discussions.apple.com/docs/DOC-3521
Ciao. -
I use itunes on a Dell XPS502 with W7/64. In some cases have have problems to import CD's. The sound is very disturbed and the import need a lot more time than in normal cases. Is there a problem between itunes and W7/64 or a known hardware issue?
Example-CD : "Tracy Chapman , Telling stories" is not able to import . I have more such negative cases. But in other cases it works fine and the sound is great.
The firmware at the inbuild CD/DVD DS-6E2SH is the latest version.
What can I do??hi b noir,
I don't no about virtuel drives like you mententioned. In the mean time I have rebooted the XPS and run again the iTunes diagnostics. I think the back - chance in the registry was not ready to use. Now there are another results. They are the same in case of a running CD or a not running CD. The difference in total is like before. It takes more time that iTunes reads the (bad) CD and at the there is no good sound. In both cases ( running or not running CD) iTunes diagnostics gives as a result :
(the copie from ITunes shows the result of the not running CD from Tracy Chapman)
Microsoft Windows 7 x64 Ultimate Edition Service Pack 1 (Build 7601)
Dell Inc. Dell System XPS L502X
iTunes 10.3.1.55
QuickTime 7.6.9
FairPlay 1.11.17
Apple Application Support 1.5.2
iPod Updater-Bibliothek 10.0d2
CD Driver 2.2.0.1
CD Driver DLL 2.1.1.1
Apple Mobile Device 3.4.0.25
Apple Mobile Device Treiber 1.55.0.0
Bonjour 2.0.5.0 (214.3)
Gracenote SDK 1.8.2.457
Gracenote MusicID 1.8.2.89
Gracenote Submit 1.8.2.123
Gracenote DSP 1.8.2.34
iTunes-Seriennummer 00D7B2B00CD25750
Aktueller Benutzer ist kein Administrator.
Aktuelles Datum und Uhrzeit sind 2011-06-11 19:33:22.
iTunes befindet sich nicht im abgesicherten Modus.
WebKit Accelerated Compositing ist aktiviert.
HDCP wird unterstützt.
Core Media wird unterstützt.
Info zu Video-Anzeige
NVIDIA, NVIDIA GeForce GT 540M
Intel Corporation, Intel(R) HD Graphics Family
**** Info für externe Plug-Ins ****
Keine externen Plug-Ins installiert.
iPodService 10.3.1.55 (x64) arbeitet zurzeit.
iTunesHelper 10.3.1.55 arbeitet zurzeit.
Apple Mobile Device service 3.3.0.0 arbeitet zurzeit.
**** CD/DVD-Laufwerkstests****
LowerFilters: PxHlpa64 (2.0.0.0),
UpperFilters: GEARAspiWDM (2.2.0.1),
D: PLDS DVDRWBD DS-6E2SH, Rev CD11
Audio-CD im Laufwerk
11 Titel auf der CD gefunden, Spieldauer: 42:07 auf Audio-CD
Titel 1, Startzeit: 00:02:00
Titel 2, Startzeit: 03:59:47
Titel 3, Startzeit: 07:19:27
Titel 4, Startzeit: 11:31:30
Titel 5, Startzeit: 15:31:50
Titel 6, Startzeit: 20:07:50
Titel 7, Startzeit: 24:27:15
Titel 8, Startzeit: 27:49:10
Titel 9, Startzeit: 32:41:25
Titel 10, Startzeit: 35:29:65
Titel 11, Startzeit: 38:38:00
Audio-CD erfolgreich gelesen (Suche nach alter Firmware).
Laufwerksgeschwindigkeit erfolgreich erkannt
Die CDR-Geschwindigkeiten des Laufwerks sind: 4 10 16 24
Die CDRW-Geschwindigkeiten des Laufwerks sind: 4
Die DVDR-Geschwindigkeiten des Laufwerks sind: 4
Die DVDRW-Geschwindigkeiten des Laufwerks sind: 4
After starting the import it is going slower and slower. If it is helpful I can send you a soundfile with these distortions.
best regards
tcgerd -
Getting Return values from RFC function call with visual basic
Hi,
I am creating a sample app to connect to a SAP system which call its RFC functions created with ABAP. It was known that the function will return more than 1 return values.
SAP Function name ==> "ZFMTP_RFC_GET_RESULT"
Export parameters (to SAP):
- Student Name [char 10] ==> "STUNAME"
- Student ID [char 20] ==> "STUID"
Return values (From SAP):
- Results [char 10] ==> "RESULT"
- Remarks [char 200] ==> "REMARKS"
i have managed to get sample codes for connecting and call a RFC function with vb but they only get a return value. How do i retrieve multiple return values like the above function "RESULT" and "REMARKS"?
Here's my vb code to accessing the function
Dim R3 As Object
Dim FBFunc As Object
Dim returnFunc As Boolean
Dim connected As Boolean
R3 = CreateObject("SAP.Functions")
R3.Connection.Client = "000"
R3.Connection.User = "BCUSER"
R3.Connection.Password = "minisap"
R3.Connection.Language = "DE"
R3.Connection.System = "dtsystem"
R3.Connection.Applicationserver = "xxx.xxx.xxx.xxx"
connected = R3.Connection.Logon(0, True)
If connected <> True Then
MsgBox("Unable to connect to SAP")
End If
FBFunc = R3.add("ZFMTP_RFC_GET_RESULT")
FBFunc.exports("STUNAME") = "Jonny"
FBFunc.exports("STUID") = "12345"
returnFunc = FBFunc.Call() <<== How do i get the return value? or RESULT and REMARKS of the RFC Function?
thanks alot.
Edited by: Eugene Tan on Mar 4, 2008 7:17 AMHi Gregor,
Thanks for the link....i am having some doubts with the codes, hope you can clarify them for me if you know the codes..
Below is the code snippet.
Set impReturn = CHPASS_FN.Imports("RETURN") <<=== is RETURN the standard keyword to get a return object?
expPassword.Value = currpass
expNewPass.Value = newpass
expFillRet.Value = "1"
''' Call change password function
If CHPASS_FN.Call = True Then
outFile.Write (", Called Function")
Message = impReturn("MESSAGE") <<==== So if i have 3 return values..i just replace with the return value variable names?
outFile.WriteLine " : " & Message
Else
outFile.Write (", Call to function failed")
End If
thanks alot...all your help is very appreciated. -
Hi ,
I use Oracle 10g and forms10g.
I have written a db packaged function such as:
function fnc_ipologismos_xiliometron(code_poleis_apo_var in varchar2,code_poleis_pros_var in varchar2)
return number
is
apostasi_var ref_apostaseis_poleon.apostasi%type;
onomasia_pol_apo_var ref_poleis.onomasia%type;
onomasia_pol_pros_var ref_poleis.onomasia%type;
begin
begin
select onomasia into onomasia_pol_apo_var
from ref_poleis
where code_poleis=code_poleis_apo_var;
end;
begin
select onomasia into onomasia_pol_pros_var
from ref_poleis
where code_poleis=code_poleis_pros_var;
end;
begin
select apostasi into apostasi_var
from ref_apostaseis_poleon
where code_poleis_apo=code_poleis_apo_var and code_poleis_pros=code_poleis_pros_var;
exception
when no_data_found
then
apostasi_var:=0;
return apostasi_var;
raise_application_error(-20015,'a message');
--return apostasi_var;
end; return apostasi_var;
end;The problem is that when the exception written above (in bold) returns 0 and exits the function.... whereas i want this value to be returned as well as the message in the raise_application_error....
I call this function in WHEN-VALIDATE-ITEM of a block item... such as:
if pkg_mod3_general.fnc_ipologismos_xiliometron
(:mod3_entoli_metakinisis.code_poleis_apo_type_id,:mod3_entoli_metakinisis.code_poleis_type_id)=0
and :mod3_entoli_metakinisis.seq_code_meso_metakin_type_id=2
then
raise form_trigger_failure;
end if; When the above condition is true then no message is displayed and the cursor sticks to the item(as the raise_application_error in the db packaged function is after the exit of the function) and when the condition is false then no message is displayed again ... as expected.....
How is it get the desired result.....- get the message from the raise_application_error and the function returns 0.....?????
Many thanks,
Simonyou cannot RETURN and RAISE a function.
RETURN ends the function immediately
RAISE ends the program unit and jumps in the EXCEPTION-Handler, if it exists. Else the function ends -
DB adapter not returning return variable from database function
Hi,
We are calling a function using db adapter from our BPEL Process. It worked fine in 10.1.3.3.
after we migrated to 10.1.3.4 MLR# 8 , we are not able to see the return variable which function is returing.
Function is working fine when executed standalone. Its returing the variable. But we are not able to see that variable in bpel process invoke response variable. This is causing issue.
Any idea what causing the issue.
ThanksCheck your XSD to see if it is qualified (elementFormDefault="qualified") or unqualified. The XSDs were unqualified in 10.1.3.3. They became qualified in 10.1.3.4. If you have an unqualified XSD and you're using a 10.1.3.4 runtime you will likely have namespace issues that cause problems with the generated XML. The solution is to regenerate your XSD so that it becomes qualified.
-
Returning values from JNI functions to Java
I have a JNI function which returns a "jstring" to the calling Java function.
I need also to return 2 byte values.
Can I return them all...? if so, how?I have a JNI function which returns a "jstring" to the
calling Java function.
I need also to return 2 byte values.
Can I return them all...? if so, how?"Also"? Then you do the same thing as if you were returning two different types in java only code, you wrap it in an object. -
BT billings are taking a lot more money than my ac...
I am absolutely tired of this and will be sending a complaint soon.
I've been with BT for 8-9 months now and it's been nothing but a hassle, ever since January when I moved homes, BT have been taking £65 every month because of 'average calls I made back in 2012', even though they've already taken the money to cover those bills, they're still taking £65 because it's the average use, bare in mind we no longer use the landline anymore.
Since February, BT have been taking more than what I need to pay for, so I said okay and let them take out the money because they said that any extra money will be deducted from the next quarterly bill, starting from may, they deducted the extra money from previous bills and my quarterly bill was £108.75, may first they took again £65 leaving about £43 left for the next TWO months.
I then called BT and they said that for now on there will be a set amount of money that will be due every month but for now I have to finish my current quarterly bill in order for them to proceed, I said it doesn't make sense that I have to pay off the £43 now and start paying the set amount starting from next month. I was put on hold for a few minutes and told that I won't have to clear the current bill and was CONFIRMED that the next payment will be next month.
Guess what, they took out the £43 without my permission even though we agreed that the set payment will start from June.
It's just an absolute mess, to keep this short .. my current quarterly bill from 11th April till 12th of July is 'PAID'. Why am I still being charged, going to be charged £45 next month and the month after even though my quarterly bill is cleared?
Solved!
Go to Solution.Hi
I am sorry to see you are having problems
I suggest you contact the forum mods they should be able to get this problem sorted for you this is a link to them http://bt.custhelp.com/app/contact_email/c/4951
They normally reply by email or phone directly to you within 3 working days they will take personal ownership of your problem until resolved and will keep you informed of progress
They are a UK based BT specialist team who have a good record at getting problems solved
This is a customer to customer self help forum the only BT presence here are the forum moderators
If you want to say thanks for a helpful answer,please click on the Ratings star on the left-hand side If the reply answers your question then please mark as ’Mark as Accepted Solution’ -
My mac book pro taking a little more time than usual to load up pages. what can i do?
Thanks
This helped to speed up my copy of pages.
open disk utility and click verify disk permissions and repair disk permisions.
Tyler -
Apps Taking Up Significantly More Space Than The Size of the App
I'm having an issue where the meter for my iPad registers a significantly higher hard drive usage to "Apps" than the apps file size in the list. It's showing 5.4 GB, when the total size of the apps installed is 240 MB. I do have VLC and two videos synced totallying .5 GB. I also have Kindle with four books installed. Generously that's 10 MB.
That's a 4 GB difference between what I can attribute and what iTunes says. Anyone have any ideas what could cause such a disparity?I know that some note apps still have your notes in the data files after they are deleted. Paper Desk never completely deletes a note. I can see deleted notes in the transfer section in iTunes. I wish they had a way of wiping those files clean. What I do is I delete the app and then re- install it after I save the notes I want to keep. I'm not happy with this problem. I'm sure other apps have the same problem.
-
Problem loading images from a return value of a function
hello, I write because I uin problem in loading images from a return value of a function.
I created a database with a field "image" of type string, where I put the physical address of the image. I have written like this: {__DIR__ }foto.jpg
Place the code, so you understand better
function imageViewImage(): javafx.scene.image.Image {
connetti();
lass.forName(driverName);
con = DriverManager.getConnection(url,user,"");
stmt = con.createStatement();
var richiesta:String = "SELECT image from viaggio WHERE id_viaggio=7";
rs1 = stmt.executeQuery(richiesta);
var result :String;
rs1.next();
risultato = rs1.getString("image");
JOptionPane.showMessageDialog(null, result);
var imagez = Image{
url:"{result}";
return imagez;
The image is in the source code package
First I connect to the database, run the query and I take the contents of the image.
Can anyone help me?
Is right to put in the database {__DIR__} foto.jpg or do I put only foto.jpg?Hello unkus_nob,
I would rather suggest you to save only filename of that image like "foto.jpg" in database. And just concat it with the String variable containing "{__DIR__}".
Actually the javafx compiler converts the {__DIR__} to the existing class directory path something like : "jar:file:/..../".
var currentDir ="{__DIR__}";
risultato = "{currentDir}{rs1.getString("immagine"})";
var image = Image{
url:risultato
return image;--NARAYAN G. -
Returning sql statement instead of values from database
hi am reading value from database but my problem is am get sql statement values instead of values in database
my code is
java:337)There is no doubt: you get what you want:
return s_getValue;
bye
TPD -
Error getting return value from function
Hello
I'm getting a error calling a function with ODP.NET from C#
Code:
OracleCommand oraCom = new OracleCommand("NORMALIZACION.nif",oraCon);
oraCom.CommandType = CommandType.StoredProcedure;
OracleParameter param1 = new OracleParameter("numnif",OracleDbType.Varchar2);
param1.Value= "73667866A";
param1.Direction = ParameterDirection.Input;
OracleParameter param2 = new OracleParameter("nif",OracleDbType.Varchar2);
param2.Size = 10; //FIXME line
param2.Direction = ParameterDirection.ReturnValue;
oraCom.Parameters.Add(param1);
oraCom.Parameters.Add(param2);
oraCom.ExecuteNonQuery();
nif_norm = oraCom.Parameters["nif"].Value.ToString();
if i write the FIXME line i get a error (ORA-06502) complaining about the size, no matter the value i wrote.
If i don't write the FIXME line, it works but nif_norm is always empty, although the function i call is a single return 'Hello';
Where am I wrong??
Any help, examples with varchar2 as return value???
BTW: the same code with the MS provider for Oracle works fine.Good point -- i shall do so.
What I think I'm missing, in my quest for ODP.NET competence, is a solid set of example code. I've searched around and found various fragements here and there, but when it comes to data access from .NET there must surely be some finitie set of possibilities (if we can discount bad practices like building dynamic SQL statements without bind variables).
For example, possibly in increasing order of complexity ...
* Read a single value from a SQL statement ... "select emp_name from emp where rownum < 2"
* Read a single value by passing in a parameter ... "select emp_name from emp where user_id = :?"
* read multiple values ... "select emp_name from emp where user_id in (:?,:?)"
* execute a stored procedure with no in or out parameters
* retreive a value from a function with no parameters
* pass a parameter to a stored procedure
* read an out parameter from a stored procedure
Then work with in and out ref cursors, blobs, whatever.
Thoughts? -
How to return more than one value from a function
hello everybody,
Can anyone tell me how to return more than a single value from a function, the problem is i have 4 points,
2 points form one line ,another 2 points form 2nd line ,each point is 3 dimensional(x,y,z coorinates) so i will pass these values to func(x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4), i will find the point of intersecton of two lines and i will get it as x,y,z , now how to return these 3 coordinates,usually the function returns only one value, please help me to solve it out.
Thanks.I think the easiest way or trick here is (easiest isn't always the best as we know, but atleast this one will work) to create simple data array. and pass that. Create an array with:
<code>
class justArray {
int x=0
int y=0;
int z= 0;
...somewhere
justArray[] points= new justArray[4];
points[0].x= ..
points[0].y= ..
points[0].z= ..
points[1].x= ..
return points[]
</code> -
Unable to access values from database in login page..
Hey all,
Friends I have a login.jsp page and I want if i enter username and password then it will be accessed from database and after verifying the details it will open main.jsp.I made a database as "abc" and created DSN as 1st_login having table 1st_login. But the problem is that I am unable to access values from database.
So Please help me.
Following is my code:
<HTML>
<body background="a.jpg">
<marquee>
<CENTER><font size="5" face="times" color="#993300"><b>Welcome to the"<U><I>XYZ</I></U>" of ABC</font></b></CENTER></marquee>
<br>
<br>
<br>
<br><br>
<br>
<form name="login_form">
<CENTER><font size="4" face="times new roman">
Username
<input name="username" type="text" class="inputbox" alt="username" size="20" />
<br>
<br>
Password
<input type="password" name="pwd" class="inputbox" size="20" alt="password" />
<br/>
<input type="hidden" name="option" value="login" />
<br>
<input type="SUBMIT" name="SUBMIT" class="button" value="Submit" onClick="return check();"> </CENTER>
</td>
</tr>
<tr>
<td>
</form>
</table>
<%
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connection = DriverManager.getConnection("jdbc:odbc:1st_login");
Statement statement = connection.createStatement();
String query = "SELECT username, password FROM 1st_login WHERE username='";
query += request.getParameter("username") + "' AND password='";
query += request.getParameter("password") + "';";
ResultSet resSum = statement.executeQuery(query);
//change: you gotta move the pointer to the first row of the result set.
resSum.next();
if (request.getParameter("username").equalsIgnoreCase(resSum.getString("username")) && request.getParameter("password").equalsIgnoreCase(resSum.getString("password")))
%>
//now it must connected to next page..
<%
else
%>
<h2>You better check your username and password!</h2>
<%
}catch (SQLException ex ){
System.err.println( ex);
}catch (Exception er){
er.printStackTrace();
%>
<input type="hidden" name="op2" value="login" />
<input type="hidden" name="lang" value="english" />
<input type="hidden" name="return" value="/" />
<input type="hidden" name="message" value="0" />
<br>
<br><br>
<br><br>
<br><br><br><br><br>
<font size="2" face="arial" color="#993300">
<p align="center"> <B>ABC © PQR</B>
</BODY>
</HTML>
and in this code i am getting following error
C:\Project\SRS\build\generated\src\org\apache\jsp\loginjsp.java:93: cannot find symbol_
C:\Project\SRS\build\generated\src\org\apache\jsp\loginjsp.java:93: cannot find symbol_
C:\Project\SRS\build\generated\src\org\apache\jsp\loginjsp.java:94: cannot find symbol_
C:\Project\SRS\build\generated\src\org\apache\jsp\loginjsp.java:95: cannot find symbol_
4 errors
C:\Project\SRS\nbproject\build-impl.xml:360: The following error occurred while executing this line:
C:\Project\SRS\nbproject\build-impl.xml:142: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 6 seconds)As long as you're unable to compile Java code, please use the 'New to Java' forum. This is really trival.
To ease writing, debugging and maintenance, I highly recommend you to write Java code in Java classes rather than JSP files. Start learning Servlets.
Maybe you are looking for
-
Cannot update mini displayport to vga adapter firmware 1.0
How come i cannot update the firmware,It says "The Updater could not find a Mini DisplayPort to Vga Adapter to update even though the adapter is already connected to my Philips HDTV.At first, the image in my philips hdtv is not clear as my secondary
-
How can I change my power regulator to a new one?
In august 24,2010, I bought a macbook pro 13-inch from apple on-line store. But today, my power regulator of magsafe was broken. I don't know what's wrong with it. I use my friend's magsafe, and his magsafe is good. So I want to change another. How c
-
I have applied IPsec policy on local machine(ip address:10.82.138.76) with windows server 2008 ent r2 installed,only permit local machine to comunicate with itself,one other server(ip address:10.82.138.77) and the gateway device(ip address:10.82.138.
-
Hi, I have 2 report programs that I want to combine into 1. Basically , I have created my own version of transaction SP01 ( business requirement ) , which displays spool information, but does not display the spool on the screen. I also have another p
-
Every time I attempt to place a bid on eBay I am immediately logged out
I do not notice ANY problems while on the eBay site except that ANY TIME I place a bid I am immediately logged out. This started several months ago. I have checked all add-ons I have cleared EVERYTHING re: eBay The ONLY plug-in I can suspect is McAfe