Exponent Function on a Stored Procedure
I am using an exponent function in an Oracle Stored Procedure (Oracle 7.3.4). the exponent function is causing the stored procedure to run a long time. If I take the exponent function out the procedure runs in 2 minutes to process 289000 records, when I put the statement back in the procedure runs in 17 minutes. We are running oracle in HP Unix.
The format of the statemenT is
VARIABLE = EXP((VAR1 - VAR2)/VAR3)
Does anyone have any reason why the EXP function causes the procedure to run longer?
Hello,
I think that my question was not clear enough. I did not got any reply to my question.
But after several hours of investigation (ASI: Apex Scene Investigation) I discovered a good way to the solution.
And that is: Collections!!
I will close this thread as answered.
Greetings
Carlos
Edited by: IsolraC on Jan 14, 2009 11:24 AM
Similar Messages
-
Wrapped in a function and/or stored procedure, recursive CTE stops working
This query builds an hierarchical tree from a single table with the typical
value/reports_to_value columns.
When running in SQL manager returns like 7 records (note i'm avoiding infinite
loop by blocking top level value)
WITH c
AS
SELECT deptid, reports_to_dept
FROM glo_tree
WHERE deptid = '18538'
UNION ALL
SELECT t.deptid, t.reports_to_dept
FROM glo_tree T
INNER JOIN c
ON t.deptid = c.reports_to_dept
where t.deptid <> '00001'
SELECT deptid
FROM c
However, the exact same query, if wrapped in a function and/or stored procedure,
returns 0 records (no error message whatsoever)
CREATE FUNCTION [dbo].[checkDept] (@deptid varchar(16))
RETURNS TABLE
AS
RETURN
WITH c
AS
SELECT deptid, reports_to_dept
FROM glo_tree
WHERE deptid = @deptid
UNION ALL
SELECT t.deptid, t.reports_to_dept
FROM glo_tree T
INNER JOIN c
ON t.deptid = c.reports_to_dept
SELECT deptid
FROM c
GO
CREATE PROCEDURE [dbo].[getDept] (@deptid varchar(16))
AS
SELECT deptid
FROM dbo.checkDept(@deptid)
Then call them like:
select * FROM checkDept('18538')exec getDept @deptid='18538'
Both return nothingThanks Patrick, i don't think it can do that, i call it like:
select * FROM checkDept('18538')exec getDept @deptid='18538'Just to make sure, i've changed the function like:WHERE ltrim(rtrim(deptid)) = @deptidStill the same thing -
Calling a function in a stored procedure
How to call a function in a stored procedure
Oracle 11gDeclare
varname DATATYPE ;
BEGIN
varname:= <Function Name> ;
END;
You have to understand the other bits by yourself.
Read more details at http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/overview.htm#sthref192 -
How to convert REFCursor functions to REFCursor Stored Procedure
Is it possible or not.How to want convert REFCursor functions to REFCursor Stored Procedure.For Example
function QR_1RefCurDS return pkg_sa_reprts_ref_cursr.pa_mis_sa_disp_cursr is
data_cursr pkg_sa_reprts_ref_cursr.pa_mis_sa_disp_cursr;
begin
data_cursr:= sf_sa_dispatch_reprt(:P_USER,:P_USER_TYPE,:P_AREA_CD,:P_RPT_LEVEL,:P_PARNT_GROP,:P_LOCTN_CD,:P_DATE);
return data_cursr;
end;
how to convert it.Its possible. But you need to analyse the requirement well. Post conevrsion, you need to take care of places in the code where the function call is made to invoke the new procedure.
create procedure QR_1RefCurDS_pr (out pkg_sa_reprts_ref_cursr.pa_mis_sa_disp_cursr) is
data_cursr pkg_sa_reprts_ref_cursr.pa_mis_sa_disp_cursr;
begin
data_cursr:= sf_sa_dispatch_reprt(:P_USER,:P_USER_TYPE,:P_AREA_CD,:P_RPT_LEVEL,:P_PARNT_GROP,:P_LOCTN_CD,:P_DATE);
end; -
How to execute a procedure or function from Java Stored procedure
Hi,
I am new to Java Stored Procedures. I am working on Oracle 8i and JVM 1.3.1. I want to call a PL/SQL procedure from within Java. I have tried looking at severa; cources but they are quite high level for me. Can someone provide a simple example including the Source Code for .java file and also the calling function's code?
Heres a sample of what I have been working on: I an including Java code, and Function code and how I call the function. Instead of doing "select sysdate from dual" I want to do like "create table temp1(var1 varchar2(10))" or similar... like "exec procname(var1)" etc.
Thanks in advance.
PS. The variable passed in function is just a dummy variable.
-----Begin Java code-------
import java.sql.SQLException;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.ResultSet;
//Oracle Extensions to JDBC
import oracle.jdbc.driver.OracleDriver;
public class Test2{
public static String Testing(String d) {
Connection connection = null; // Database connection object
try {
// Get a Default Database Connection using Server Side JDBC Driver.
// Note : This class will be loaded on the Database Server and hence use a
// Se[i]Long postings are being truncated to ~1 kB at this time.what your after is
Connection conn = DriverManager.getConnection
("jdbc:oracle:oci:@<hoststring>", "scott", "tiger");
CallableStatement cs = conn.prepareCall ("begin ? := foo(?); end;");
cs.registerOutParameter(1,Types.CHAR);
cs.setString(2, "aa");
cs.executeUpdate();
String result = cs.getString(1);
a more complete description can be found in the documentation at
http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/basic.htm#1001934
Dom -
Using writetext function in a stored procedure for Sybase 11.5
Hello,
I need to execute the writetext function inside a Sybase stored procedure to insert varchar data of approximately 4k size.
how to specify data parameter in writetext fot that?The split function Scott used is some variant on one of the solutions posted in the Ask Tom link I posted. More specifically, it is probably a variant on either one of the pipelined function solutions, or one based on splitting the string into a SQL table of objects.
Look at Tom's original response to the question for a working solution. If you have a reasonably new version of Oracle, then you may also want to look at the modificataion/modernization later in the thread which can be found here
HTH
John -
More function calls in stored procedure
Hi,
I would like to know if there are more function calls in a PL/SQL stored procedure, would it affect the performance of this procedure?
Or will it be more efficient to have the body of those functions inside the procedure itself.
Of course a method call is always costlier than the monolithic procedure but my question is how much would be difference in performance.
Rgds
VaradYes, avoid using UDF , means especially a scalar udf... See how you can re-write a scalar udf as table valued udf.
http://sqlblog.com/blogs/alexander_kuznetsov/archive/2008/05/23/reuse-your-code-with-cross-apply.aspx
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Can is call store function similar to stored procedures
iam trying to call a stored function written in database similar to stored procedures .Is it possible to call funtion if yes can anybody tell me how to call ,please yar.its urgent
I believe I already answered your question [url http://forum.java.sun.com/thread.jspa?threadID=645317&messageID=3801352#3801352]here
-
Executing a Function in a Stored Procedure to Return Cursor
I have a function named f_CPCRBPBR who base on the following types
CREATE Or Replace TYPE RecType_fAC
AS OBJECT ( << Structure >>);
CREATE Or Replace TYPE Tbl_fAC
AS TABLE OF RecType_fAC;
Create Or Replace
Function f_CPCRBPBR (
i_Vtp Varchar2,
i_Mnth Varchar2,
i_Location Varchar2,
i_vno integer,
i_vnoTo integer,
St_Date Varchar2,
En_Date Varchar2
Return TBL_fAC
Pipelined
Is
RetVal RecType_fAC;
Begin
Now the problem is that I want to Call this Function from Within a Procedure who would return the Recordset..
can any body suggest..
I want to use the Record Type used for the Said Function..
Please Help..This is Excellent .. This is great.. actually this is marvellous.. can u please defined a bit about Sys_RefCursor...
this is an excellent thing..
I finally Concluded the procedure as follows who not only called but also returned the cursor..
Create Or Replace Procedure p_CPCRBPBR (TstCrsr In Out Sys_RefCursor,
i_Vtp Varchar2,
i_Mnth Varchar2,
i_Location Varchar2,
i_vno integer,
i_vnoTo integer,
St_Date Varchar2,
En_Date Varchar2
as
Begin
Open TstCrsr FOr
Select * from Table(f_CPCRBPBR (i_VTP, i_Mnth, i_Location, i_VNo, i_VNoTo, '', ''));
End;
Can u please help me what will be the exact syntax to call / test this procedure in SQL Developer..
as if i try this procedure as
Execute p_CPCRBPBR null, 'CP', '01', 'L', 1, 1, null, null
it give error Invalid SQL Statement ..
2. Can u please check this code and refer me a solution for Calling this function
create or replace function NewTest (iEN Integer)
return sys_refcursor
as
rc sys_refcursor;
begin
open rc for select * from Scott.Emp Where EmpNo=iEN;
return rc;
end;
This function easily created but when i tried to execute this with the following statement
Select * from Table(NewTest (7369))
It gives error
Cannot Access Rows From a Non-Nested Table Item..
.. Thanx for ur patience... -
Saving Functions, Packages and Stored Procedures in Tool
Hi,
I'm not sure what is going on - I've imported stored procedures, funtions and packages and they seem to get lost - is there something that I'm not doing correctly.
I'm using SQL Developer Data Modeler version 3.0.0.665.
Thanks for your help.Hi David,
The following error is reported in datamodeller.log
2011-07-15 14:41:52,152 [Thread-17] ERROR XMLTransformationManager - Unable to load object from XML: M:\DEV\PS-DESIGN\DM WORKING FOLDER\DM_SP\DM_SP\rel\ADC52B64-45F301457CE2\phys\32076570-BF29817DFF70\Package\seg_0\57F361C1-F09A-637C-58CD-FF3FB69D54AC.xml
java.io.FileNotFoundException: M:\DEV\PS-DESIGN\DM WORKING FOLDER\DM_SP\DM_SP\rel\ADC52B64-45F301457CE2\phys\32076570-BF29817DFF70\Package\seg_0\57F361C1-F09A-637C-58CD-FF3FB69D54AC.xml (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at oracle.dbtools.crest.model.metadata.XMLToObjectTransformer.transformToObject(Unknown Source)
at oracle.dbtools.crest.model.metadata.XMLTransformationManager.transformFromXMLToObject(Unknown Source)
at oracle.dbtools.crest.model.metadata.XMLTransformationManager.openPhysicalModel(Unknown Source)
at oracle.dbtools.crest.swingui.browser.BrowserPanel$78.run(Unknown Source)
But actually, the said xml is available in different folder ..\Package\seg_1 where DM is searching the file in ..\Package\seg_0
Actual File path
M:\DEV\PS-DESIGN\DM WORKING FOLDER\DM_SP\DM_SP\rel\ADC52B64-45F301457CE2\phys\32076570-BF29817DFF70\Package\seg_1\57F361C1-F09A-637C-58CD-FF3FB69D54AC.xml
The path of the file name is not getting stored properly, hence there packages are not loaded properly.
Regards
Sugirtha -
Call a function inside a package from a stored procedure
Hello:
I am kind of new to the stored procedure. Does anyone know how to call a function inside a package from another stored procedure?
I have a existing function (func_b) inside a package (pack_a) and it returns a cursor. I want to call this function from a stored procedure (proc_c) so that I use the data inside the cursor.
can I do the following in proc_c:
my_cursor1 SYS_REFCURSOR;
begin
my_cursor1 := exec pack_a.func_b
end
It will be very helpful if anyone can point me to any reading or example. Thank you very much for your information.guys:
Thank you for your information so far. I need some more help here. I was able to run the function in my stored procedure. However, I was not able to print the result on the screen to view the cursor result, although I am using dbms_output.put_line statement inside my stored procedure.
I use the following statement to execute my stored procedure on sql*plus. I can tell the stored procedure is executed successfully, but I did see anything printed:
DECLARE TEMP VARCHAR2(100);
BEGIN PROC_LAWS_CAD_NAME_SEARCH('LPD', 'TEST DEVICE ID', 'TEST LAST NAME', 'TEST FIRST NAME', 'F', '11112009', TEMP); END;
I tried to use 'set serveroutput on' and got the following error:
ERROR:
ORA-06502: PL/SQL: numeric or value error: host bind array too small
ORA-06512: at line 1
I am kind of confused now. thank you for your help.
Jack
Here is my procedure:
create or replace
PROCEDURE PROC_SEARCH
( AGENCY_ID IN VARCHAR2,
DEVICE_ID IN VARCHAR2,
L_NAME IN VARCHAR2,
F_NAME IN VARCHAR2,
SEX IN VARCHAR2,
DOB IN VARCHAR2,
CAD_NAME_SCH_RESULT_STR OUT VARCHAR2)
AS
v_agy_id varchar2(10);
v_device_id varchar2(20);
v_l_name varchar2(25);
v_f_name varchar2(15);
v_sex varchar2(1);
v_dob date;
-- this cursor is going to be used to store a list of warrant matching
-- name search criteria
cad_srch_cursor sys_refcursor;
objSrch SEARCH_RESULT_TEMP%ROWTYPE;
BEGIN
cad_srch_cursor := SEARCH_PKG.SEARCH('TESTING', 'TESTER', null, null,null, null, getPhonetic('TESTING'));
LOOP
FETCH cad_srch_cursor INTO objSrch;
EXIT WHEN cad_srch_cursor%NOTFOUND;
--insert into SEARCH_RESULT_TEMP (name_last) values (objSrch.name_last);
CAD_NAME_SCH_RESULT_STR := objSrch.name_last;
dbms_output.put_line('First:'||objSrch.name_first||':Last:'||objSrch.name_last||':Middle:'||objSrch.name_middle);
end LOOP;
END PROC_LAWS_SEARCH;
----------------------------------------- -
Difference between Function and Stored Procedure
Hi guys, i don't understand the exact difference between a function and a stored procedure. I did lot of google but still. Can somebody explain in simple words. Thanks.
Hi,
Here's an example of a user-defined function:
CREATE OR REPLACE FUNCTION factorial
( in_num IN PLS_INTEGER
RETURN PLS_INTEGER
DETERMINISTIC
IS
BEGIN
IF in_num IS NULL
THEN
RETURN NULL;
ELSIF in_num <= 1
THEN
RETURN 1;
ELSE
RETURN in_num * factorial (in_num - 1);
END IF;
END factorial;
SHOW ERRORSThis function retruns an integer. You can use the function (or, more properly, the integer that it returns) anywhere an integer expression is allowed.
For example
SELECT ROWNUM
, factorial (ROWNUM) AS f
, loc
, SUBSTR ( loc
, 1
, factorial (ROWNUM)
) AS s
FROM scott.dept;Output:
` ROWNUM F LOC S
1 1 NEW YORK N
2 2 DALLAS DA
3 6 CHICAGO CHICAG
4 24 BOSTON BOSTON -
Calling a stored procedure from Reports
I am trying to call a stored procedure using oracle reports in the afterparameter code. My code is:
v_ain := sp_get_ain(:P_session_id);
Can someone help me out by telling what is wrong. I keep getting an error stating that sp_get_ain needs to be declared.?!I am creating a function and a stored procedure and calling them
in afterparameter report trigger.
-------------------Create function ----------------
create or replace function get_name( emp_id number) return varchar2 is
v_name varchar2(20);
begin
select name into v_name
from sample_table
where employ_id = emp_id ;
return(v_name); ---------This is the way to return value from function.
exception
when no_data_found then
return('Name not found.');
when others then
return('Other error found.');
end ;
==================================================================================
------------------------Create procedure ------------------------------------
create or replace procedure get_name( emp_id number, return_name out varchar2) is
v_name varchar2(20);
begin
select name into v_name
from sample_table
where employ_id = emp_id ;
return_name := v_name ; --Assign out parameter value from procedure.
exception
when no_data_found then
return_name := 'Name not found.';
when others then
return_name := 'Other error found.';
end ;
============================================================================
-----------------Call function and procedure from report ---------------------
In formula column or any report trigger you can use this code.
v_function_return_name varchar2(20);
v_procedure_return_name varchar2(20);
v_employ_id number(10);
begin
v_employ_id := 101 ;
v_function_return_name := get_name(v_employ_id ); --- call function
get_name(v_employ_id , v_procedure_return_name ); -- call procedure
end;
Here v_function_return_name has same value as v_procedure_return_name,
these are the values returned from function and procedure.
--Anita -
Calling Stored Procedure for Multiple records
Hi,
I have an use case where I have more than 2000 item and for every item I need to fetch around 70 more values as out parameters. Also i need to show all thoes values on UI.
So calling SP in loop is a problem as I can see the rendering the values and it's very slow.
Can anyone suggest better way to handle this case?
-AjitHi...
I don't know about the function you have written but...
Procedure will be created like following
Take an example: i want to create a procedure to take only first letter from the city of City column.
For this...
1). Create a physical table manually under the schema folder.
2). Give the name and select Table Type as "Stored Proc".
3). In "Default Initialization String" field, you should write the query saying "select substr(city,1,1) as Col1 from Regions". In query Col1 is the alias name i have given for the new column. (Click OK)
4). So, now this column should be part of the table newly created. So create a physical column under this newly created table with "Col1" name.
5). Double-click the column and specify the data type of that particular column. (This should be done otherwise you can't move it to BMM layer)
6). Now you can add this table to BMM layer by performing necessary joins w/o any errors or warnings. (This would be depending on your business requirement, for this some times you need to add keys also to the procedure to perform the joins and all)
7). By adding it to the presentation layer, in answers you can watch the results..
NOTE:
1). While writing the function names in Stored procedures, DB you are using is important. Because, functions will vary between the DB's.
2). Column name of newly created should match with the name you specified in the procedure as alias.
3). If you are retrieving 'n' no. of columns from the procedure then you need to create 'n' no. of columns manually.
4). For physical columns created manually, you need to specify the data type according to the type of data it's retrieving.
It may helpful to you in achieving your requirement. If not sorry... but i am sure it's helpful to you...
mark as helpful if it's helpful else mark as correct if correct ;)
Thanks & Regards
Kishore Guggilla -
Executing an Oracle Stored Procedure from Sender JDBC adapter
I could really use some help from someone who had done this before.
I've read the help about using the JDBC sender adapter, but it's not helping enough.
I found this line: "Specify an SQL EXECUTE statement to execute a stored procedure, which contains exactly one SELECT statement.
The expression must correspond to the SQL variant supported by the relevant JDBC driver. It can also contain table JOINs."
That's definately what we want to do, but we can't figure out the syntax.
The procedure in oracle looks like this:
CREATE OR REPLACE PROCEDURE test_ref_cursor
( cur_generic IN OUT result_sets.cur_generic)
as
BEGIN
Open cur_generic for
select
proposal_number,
to_char(sequence_number),
column_name,
column_value,
update_timestamp,
update_user
from
coeus.sap_test;
END test_ref_cursor;
And we have tried every kind of statement we can think of, but the file adapter always gives us an "invalid sql statement" error.
Does anyone know what syntax we need to put in the "Query SQL Statement" in the JDBC sender adapter in order to call this procedure? Or is there something wrong with the procedure that is causing the error?
<i>I will absolutely return and give points, but PLEASE read my whole post before answering and do not just link me to or quote the help for configuring a sender JDBC adapter or blogs that are about the JDBC adapter in general but do not deal with the issues I am having. Thank you.</i>Hi Vanda,
Unfortunately, the sender JDBC adapter does not support Oracle's store procedure/function. Unlike stored procedures from other database vendors, Oracle returns a cursor, not a resultset. The sender JDBC adapter must send a resultset to XI.
There are 2 possible ways you can accomplish this:
1. Use BPM and call the Oracle stored procedure using a receiver adapter via a asynch-synch bridge.
2. Develop a user-module for the adapter, which can be used with a sender adapter.
Thanks
Prasad
Maybe you are looking for
-
hi, I have to tried to use Webutil package to my forms that is mentioned in the Webutil Familiarization Manual.I wrote a section in my formsweb.cfg file.But it gave me the error in the below link: [http://img11.imageshack.us/img11/1277/err1.jpg] My s
-
New Lumia 520 won't even Start!!!!
Hi All, My roommate just received a Nokia Lumia 520 which he ordered online a couple of days ago. The thing is, the phone won't even boot up. The Nokia logo appears, stays, disappears for a few seconds and then gets back on again. This has been goin
-
Product and SWCV best practice
We have a 3rd party Product that tend to change product versions frequently as once in 3-5 month. as SAP Software logistics mechanisem is based on hierrachy of Product->product version->SWCU->SWCV My quesion is : what is the best way to maintain thi
-
How to not create File without any payload?
Hi XI Experts, I have the following integration scenario: 1. One input file 2. One or more output files (up to four files) 3. At any given time, I could have one or more files (up to four files) filled with data in the payload. Question - there ar
-
Need Materials for Enterprise portals
Hi, Hi i am new to Portals i have some hands on experience on Java and Abap webdynpros. but i have to start for portals .I need some introduction materials and some tutorials to start. if you can help i would be glad. Thank You, Mathivanan.G