Problem calling function inside a procedure
I have a procedure that simply calls a function, but I'm not sure how to declare it.
When I run my script oracle returns an error:
CREATE OR REPLACE PROCEDURE pr_entrada_close(
var_id_entrada int)
AS
BEGIN
fn_criaJobAnalise(var_id_entrada);
END;
ERROR at line 5: PL/SQL: Statement ignored3. AS
4. BEGIN
5. fn_criaJobAnalise(var_id_entrada);
6. END;
As far as I know, that structure worked in at least 8.0 and possibly earlier. I actually saw something similar in production code on that version of Oracle. The actual function took several parameters, and using those paramters did a series of statements along the lines of:
BEGIN
SELECT 1 INTO l_var
FROM table1
WHERE <predicates>
EXCEPTION
WHEN NO_DATA_FOUND THEN
RAISE APPLICATION_ERROR (-20001, 'Error');
WHEN TOO_MANY_ROWS THEN
RAISE APPLICATION_ERROR (-20002, 'Error');
END;
BEGIN
SELECT 1 INTO l_var
FROM table2
WHERE <predicates>
EXCEPTION
WHEN NO_DATA_FOUND THEN
RAISE APPLICATION_ERROR (-20003, 'Error');
WHEN TOO_MANY_ROWS THEN
RAISE APPLICATION_ERROR (-20004, 'Error');
END;
-- About 4 or 5 more tables checked
RETURN 1;and the caller looked kind of like:
DECLARE
NO_ROWS_TABLE1 EXCEPTION;
DUP_ROWS_TABLE1 EXCEPTION;
NO_ROWS_TABLE2 EXCEPTION;
DUP_ROWS_TABLE2 EXCEPTION;
PRAGMA EXCEPTION_INIT (NO_ROWS_TABLE1, -20001);
PRAGMA EXCEPTION_INIT (DUP_ROWS_TABLE1, -20002);
PRAGMA EXCEPTION_INIT (NO_ROWS_TABLE2, -20003);
PRAGMA EXCEPTION_INIT (DUP_ROWS_TABLE2, -20004);
l_v NUMBER;
BEGIN
BEGIN
l_v := test_tables(<parameters>);
EXCEPTION
WHEN NO_ROWS_TABLE1 THEN
<do something about it>
WHEN DUP_ROWS_TABLE1 THEN
<do something about it>
WHEN NO_ROWS_TABLE2 THEN
<do something about it>
WHEN DUP_ROWS_TABLE2 THEN
<do something about it>
END;
<Continue normal processing>
END;and, yes, <Continue normal processing> occasionally failed for mysterious reasons when more than one of the checks would have failed had the function got to them, and l_v was never ever used.
This was one of the clevererbits of code in that app.
John
Similar Messages
-
Calling a Function inside a procedure
Can you call a function inside a procedure?...if so....how?
Not all built-in functions can be used directly in an assignment.
SQL> CREATE PROCEDURE p (p_val IN VARCHAR2) AS
2 l_v VARCHAR2(10);
3 BEGIN
4 l_v := DECODE(p_val,'YES','TRUE','FALSE');
5 END;
6 /
Warning: Procedure created with compilation errors.
SQL> show error
Errors for PROCEDURE P:
LINE/COL ERROR
4/4 PL/SQL: Statement ignored
4/11 PLS-00204: function or pseudo-column 'DECODE' may be used inside
a SQL statement onlyTTFN
John -
Executing function inside a procedure
I have a function like fun_a(a varchar) which returns a number
I execute the function in sql prompt by select fun_a('hello') from dual;
Now i have to execute that function inside a procedure and return the output of the function to a variable like the following
create or replace procedure x is
a number;
vsql varchar2(255);
i varchar2(40):='hello';
begin
vsql :='select fun_a('||i||') from dual';
execute immediate VSQL INTO a;
dbms_output.put_line(a);
end;
I am not getting the output . Please help me in thisOr even:
CREATE OR REPLACE PROCEDURE x
IS
vsql VARCHAR2(255);
i VARCHAR2(40) := 'EMP';
i1 VARCHAR2(40) := 'EMPNO';
a NUMBER := primary_check_fun(i, i1);
BEGIN
dbms_output.put_line(a);
END;or just for fun,
CREATE OR REPLACE PROCEDURE x
IS
vsql VARCHAR2(255);
i VARCHAR2(40) := 'EMP';
i1 VARCHAR2(40) := 'EMPNO';
BEGIN
dbms_output.put_line(primary_check_fun(i, i1));
END;
Well if we're going to extremes Will we could look at it and say that the parameters are pre-defined and just have...
exec dbms_output.put_line(primary_check_fun('EMP','EMPNO'));
;) -
Creating function inside a procedure.
Hi all I am on data base 10g,
is it possible to create a function inside a procedure I don't want to use package.
thanks in advance.Like
SQL> ed
Wrote file afiedt.buf
1 create or replace procedure demo1
2 as
3 dd number;
4 function demo2( a number, b number ) return number
5 as
6 begin
7 return a+b;
8 end;
9 begin
10 dd := demo2(10,30);
11 dbms_output.put_line(dd);
12* end;
SQL> /
Procedure created.
SQL> exec demo1;
PL/SQL procedure successfully completed.
SQL> set serveroutput on
SQL> /
Procedure created.
SQL> exec demo1;
40
PL/SQL procedure successfully completed.
SQL> -
Call function inside running class
Hey All,
i have a two question in classes.
1- i have class and i called its before and its running on runtime. i need to call function inside this class from another class, but without call the first one again, because if i called it, it will run default class function again
is this doable ?
2- What super() mean ?
Thanks a lot.this is the default call, and when i call the method by this way its will run the default class function before call the method.
here my example:
i need to call checkboxes function in ChannelsMain class without pass by the grey script.
Note: the call_cb is working and the trace is working
so i now the class is running, i need to call the checkboxes without ( var ci:YourClass = new YourClass(); )
package com.link
import fl.controls.CheckBox;
import flash.events.*;
public class ChannelsMain
var cbLength:uint = Main.PV.channel_id.length;
public function ChannelsMain()
// constructor code
for (var i:int = 0; i < cbLength; i++)
var cb:CheckBox = new CheckBox;
cb.name = Main.PV.channel_id[i];
cb.label = Main.PV.channel_name[i];
cb.x = 50;
cb.y = 50 + i * 30;
cb.addEventListener(Event.CHANGE,call_cb);
Main.MS.addChild(cb);
//call xml function
if(i == cbLength - 1)
new ChannelsXML();
private function call_cb(evt:Event)
trace(evt.currentTarget.name,evt.currentTarget.selected);
public function checkboxes(evt)
trace(evt); -
Performance issue: CALL FUNCTION inside a Loop.
Hi Friends
I have a Performance Issue. That is, inside a loop...endloop a CALL FUNCTION has been used which gets data from another database table. Finally it's appended into another internal table. Please see this :
LOOP AT i_mdkp.
REFRESH lt_mdtbx.
CLEAR lt_mdtbx.
CALL FUNCTION 'READ_MRP_LIST'
EXPORTING
idtnum = i_mdkp-dtnum
icflag = 'X'
tables
mdtbx = lt_mdtbx
APPEND LINES OF lt_mdtbx TO i_mdtb.
ENDLOOP.
It happens for each record available in i_mdkp. Suppose, i_mdkp have around 50000 records, it needs to call the function module till that much time.
So, I want to split it. Can I?
Please give me your valueable suggestions.
Regards
SenthilIf internal table i_mdkp has 50,000 records it does not mean that you need to run 50,000 iterations. You just need dtnum from internal table i_mdkp so you number of iterations should be eqaul to the unique number of dtnum in the internal table. Sort the internal table by dtnum and delete adjacent duplicates from the internal table comparing dtnum before looping. Look at the code below.
DATA i_mdkp_tmp LIKE TABLE OF i_mdkp.
IF NOT i_mdkp[] IS INITIAL.
i_mdkp_tmp[] = i_mdkp[].
SORT i_mdkp BY dtnum.
DELETE ADJACENT DUPLICATES FROM i_mdkp COMPARING dtnum.
REFRESH i_mdtb.
LOOP AT i_mdkp.
CALL FUNCTION 'READ_MRP_LIST'
EXPORTING
idtnum = i_mdkp-dtnum
icflag = 'X'
TABLES
mdtbx = lt_mdtbx.
APPEND LINES OF lt_mdtbx TO i_mdtb.
REFRESH lt_mdtbx.
ENDLOOP.
i_mdkp[] = i_mdkp_tmp[]
ENDIF. -
Calling function in to procedure
how can i call a function in a procedure?
i m calculating average in function and i want to display that avg in dbms output of
procedure.how can i do that?u want to claculate the avg value for entire records
create a function with in parameter.
and call that function in procedure.in this case u have to use cursor
and call that function in loop.
regards -
Hi,
i have creted a function module which read stock quantity using BAPI_MATERIAL_AVAILABILITY.
Import - MFRPN
Export - QNTY
If i execute function module from SAP the result it's OK but when i call function from PHP it does not output nothing.
$sap = new saprfc(array(
"logindata"=>array(
"ASHOST"=>"192.168.3.1" // application server
,"SYSNR"=>"00" // system number
,"CLIENT"=>"200" // client
,"USER"=>"rfc" // user
,"PASSWD"=>"123456789" // password
,"show_errors"=>true // let class printout errors
,"debug"=>false)) ; // detailed debugging information
// Call-Function
// Call-Function
$result=$sap->callFunction("Z_READ_QNTY",
array(
array("IMPORT","MFRPN",$_POST['cod']),
array("EXPORT","QNTY",$quantity),
// Call successfull?
if ($sap->getStatus() == SAPRFC_OK)
echo $quantity;
else
// No, print long Version of last Error
$sap->printStatus();
// or print your own error-message with the strings received from
// $sap->getStatusText() or $sap->getStatusTextLong()
Please someone help me.
Thank you.hi Dan,
i will send you an working code sample. The Fuba ZGET_MAKTX is easy MATNR as import parameter and MAKTX as export parameter.
you will receive the material short description.
hope this will help you a little bit.
in your code i thing you forgot to fill the $quantity like this $quantity = saprfc_export($fce,"QNTY"); before echo $quantity;
regards
Tony
<?php
//Login to SAP R/3
$login = array ("ASHOST"=>"vsap3", "SYSNR"=>"2", "CLIENT"=>"200","USER"=>"vsrfc", "PASSWD"=>"********", "CODEPAGE"=>"1100");
$rfc = saprfc_open($login);
if (!$rfc) {
echo "RFC connection failed";
exit;
$fce = saprfc_function_discover($rfc,"ZGET_MAKTX");
if (!$fce) {
echo "Discovering interface of function module failed";
exit;
saprfc_import($fce,"MATNR","200200");
$rc = saprfc_call_and_receive ($fce);
if ($rfc_rc != SAPRFC_OK) { if ($rfc == SAPRFC_EXCEPTION ) echo ("Exception raised: ".saprfc_exception($fce)); else echo (saprfc_error($fce)); exit; }
$maktx = saprfc_export($fce,"MAKTX");
echo $maktx;
saprfc_function_free($fce);
saprfc_close($rfc);
?>
Edited by: Tony Wienhold on Oct 7, 2008 11:19 AM
Edited by: Tony Wienhold on Oct 7, 2008 11:22 AM -
Problem call Dll C from procedure
Hi all, I have dll write by C and with function A(String[] param). I want call this is function from procedure on Oracle. Please help me step to step do it.
Thank you so much.MobizCOM jsc wrote:
The pszParams is an array of pointers to 4 strings (char **), and it is an IN/OUT parameter. It means we need to pass an array of string to external function in the dll, then the external update the array as an output parameter. After return to PL/SQL, we need to extract the updated values in the array to continue process.
In my understanding, the most appropriate datatype with this in PL/SQL is "TABLE OF VARCHAR2". But it is a kind of collection. Does Oracle support to pass this datatype to external function?No.
It is a mistake in thinking that an Oracle array will be a byte copy of how C represents an array in memory.
We have tried to create a dll with simple function, simple parameters and it works. It seems that our configure for listener.ora are correctly.Correct. Which means it is now much simpler to focus on the actual challenge - passing data between the PL engine and a DLL using compatible data structures.
I have done some basic testing with array types and PL and C do not seem to match at all in this respect. Which meant I defaulted to using scalar data types and variables only.
You can point your browser to [http://tahiti.oracle.com|http://tahiti.oracle.com] and do some research yourself. There should be documentation describing the compatibility between PL and C data types.
You can also use Pro*C to see what Oracle's precompiler does. It does a 2 step compilation - so Pro*C compiles the Pro*C code (C + SQL) into C source and then that gets compiled with the normal C compiler. Peeking at the C source code generated by Pro*C may provide better insights in how SQL and PL/SQL data types and mapped to C data types and vice versa.
As for performance - in this case optimal performance is staying inside the PL engine and not stepping (context switching) to an external process interfacing with an external DLL. Therefore it would be best to replicate the functionality provided by that DLL into PL/SQL as far as possible. -
Calling Function in Stored Procedure
Hi all,
I've created table below,
CREATE TABLE TEST
ID NUMBER(3) NOT NULL,
selectcode VARCHAR2(10),
value_use VARCHAR2(10),
bin_no NUMBER(10),
markup VARCHAR2(40),
descr VARCHAR2(100),
value_imp VARCHAR2(90)
create sequence idseq;
insert into test values (idseq.nextval,'rel','C1',1,'master','test1');
insert into test values (idseq.nextval,'rel','C1',1,'masterdir','test2');
insert into test values (idseq.nextval,'rel','C1',2,'master','test3');
insert into test values (idseq.nextval,'rel','C2',2,'masterdir','test4');
insert into test values (idseq.nextval,'rel','C2',2,'master','test5');
insert into test values (idseq.nextval,'rel1','C2',1,'master','test6');
insert into test values (idseq.nextval,'rel1','C2',1,'masterdir','test7');
select * from test;
ID SELECTCODE VALUE_USE BIN_NO MARKUP DESCR
1 rel C1 1 master test1
2 rel C1 1 masterdir test2
3 rel C1 2 master test3
4 rel C2 2 masterdir test4
5 rel C2 2 master test5
6 rel1 C2 1 master test6
7 rel1 C2 1 masterdir test6There is an existing function called valcon which returns data for value_imp based on value_use and markup in the table.
SQL>select valcon ('C1','master',' ','VALUE',' ') output from dual;
OUTPUT
Value In County
I created a stored procedure, to insert values to this table using this function.. But I'm not sure how to pass the value inside the function..
CREATE OR REPLACE PROCEDURE test_sp
( in_selectcode IN varchar2,
in_valueuse IN varchar2
AS
cursor val_cur is
select *
from test
where ....;
TYPE val_typ IS TABLE OF val_cur%ROWTYPE;
val_arr val_typ;
begin
open cursor..
fetch cursor into val_arr;
FOR ..
LOOP
insert into test (id, selectcode, value_use, selectval,value_imp)
select id_seq.nextval, in_selectcode, 'C1', Nvl2(Trim(in_selectcode),'Y','N'),
valcon ('val_arr.value_use','val_arr.markup',' ','VALUE',' ')
from dual;
end loop;
close cursor;
end;
end test_sp
/ Since i'm using an array, can you please tell me how I can pass 'val_arr.value_use' as a string in the function? I researched a lot to find this, but I couldnt find how I can do this.
Thank youI've used an update query to update test.bin_no in a sequence for the same selectcode and value_use. But I'm trying to see if I can do this within the insert query so I dont have to duplicate the work with one insert and one update.
The procedure below works with update query:
CREATE TABLE TEST
ID NUMBER(3) NOT NULL,
selectcode VARCHAR2(10),
value_use VARCHAR2(10),
bin_no NUMBER(10),
markup VARCHAR2(40),
descr VARCHAR2(100),
value_imp VARCHAR2(90)
create sequence idseq;
insert into test (id,selectcode,value_use,bin_no,value_imp) values (idseq.nextval,'rel','C1',1,'Y');
insert into test (id,selectcode,value_use,bin_no,value_imp) values (idseq.nextval,'rel','C1',1,'Y');
insert into test (id,selectcode,value_use,bin_no,value_imp) values (idseq.nextval,'rel','C1',2,'Y');
insert into test (id,selectcode,value_use,bin_no,value_imp) values (idseq.nextval,'rel','C2',2,'Y');
insert into test (id,selectcode,value_use,bin_no,value_imp) values (idseq.nextval,'rel','C2',2,'Y');
insert into test (id,selectcode,value_use,bin_no,value_imp) values (idseq.nextval,'rel1','C2',1,'Y');
insert into test (id,selectcode,value_use,bin_no,value_imp) values (idseq.nextval,'rel1','C2',1,'Y');
select * from test;
ID SELECTCODE VALUE_USE BIN_NO VALUE_IMP
1 rel C1 1 Y
2 rel C1 2 Y
3 rel C1 2 Y
4 rel C2 2 Y
5 rel C2 2 Y
6 rel1 C2 1 Y
7 rel1 C2 1 Y
CREATE OR REPLACE PROCEDURE test_sp (in_selectcode IN VARCHAR2,
in_valueuse IN VARCHAR2
) AS
msg VARCHAR2 (4000);
BEGIN
INSERT INTO test (id, selectcode, value_use, bin_no, selectval, value_imp
SELECT id_seq.NEXTVAL,
in_selectcode,
'C1',
bin_no,
NVL2 (TRIM (in_selectcode), 'Y', 'N'),
valcon (value_use, markup, ' ', 'VALUE', ' ')
FROM kn_job
WHERE scode= in_selectcode;
update test t
set t.bin_no = (select t1.r from
(select rowid, ROW_NUMBER() OVER(PARTITION BY in_selectcode, in_valueuse ORDER BY id asc) r from test) t1
where t.rowid=t1.rowid);
end test_sp
select * from test;
ID SELECTCODE VALUE_USE BIN_NO VALUE_IMP
1 rel C1 1 Y
2 rel C1 2 Y
3 rel C1 3 Y
4 rel C2 1 Y
5 rel C2 2 Y
6 rel1 C2 1 Y
7 rel1 C2 2 Y But is it possible to do this without an update query? Updating bin_no in a sequence for selectcode,value_use?
Thanks -
Call function inside of call function in back ground task
Hi Friends,
I am calling one function in back ground task. that is executing after save of the transaction. And inside of that transaction i am calling one more function but in debugging the cursor is not going inside of that function. What could be the reason. Please help me.
Thanks a lot in advance.Hi,
Inside of the first function any way i will come after save
using update task debugging. Once it reach inside of firt function and if i press f5 then second function is coming and if i press f5 there then it is coming out of the function and it is not going inside. The second function is called directly not in back ground.
Thanks.. -
Help Please ... with calling functions inside listener events
I need the window to update itself before another method inside my listener is called. When I make the call to updateUI() it preforms it's function once my listener event is compelete while I would like to to happend.
paw.updateHasMoved();
temp.updateUI();// -->Want the update to occure before the next line is called
piece.CB.board = ComputersMove(piece.CB.board);okidoi Mr Helpy!
let me try with this
just one more question, the button should be created at
runtime or inside my
movieclip?
Regards
Rick
"Mr Helpy mcHelpson" <[email protected]>
escribió en el mensaje
news:f46tjk$lg1$[email protected]..
> flooring.onLoad = function(success) {
> if (flooring.firstChild.hasChildNodes()) {
>
> you can just do
>
> flooring.onLoad = function(success) {
> if (success) {
>
> you'll need to create a button on top of your image.
This for me is most
> easily done with a predefined custom class, and on the
instantiation of
> your
> image(movieclip) you can define the button actions
contained in the movie
> clip.
>
> make sense?
>
> HmcH
> -
Problem calling function in FireFox
Anything wrong with this code? It works for IE but FireFox throws: "thisMovie("Untitled-2").playF is not a function" error
function thisMovie(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName];
} else {
return document[movieName];
function sendToActionScript(archivo) {
thisMovie("Untitled-2").playF(archivo);
EDIT: this is JS code in an HTML fileFixed it, the HTML code generated by flash was not working. I republished and used the newly generated HTML file (wish it was not that big and filled with comented stuff) But it's now working on FF as well.
EDIT: Heh, I keep editing my own stuff. Problem with firefox was having a separate AC_RunActiveContent.js file with most of the code originally generated in the HTML site upon publishing. Worked ok in IE but FF didn't like to have all the js code in a separate file. Strange cause it worked fine on FF too when files were on kglad's server. Server security issue most likely. -
Problem calling function in attached movie
In my main timeline I'm attaching a movieclip from the
library & then trying to call a function defined in frame one
of the attached movieclip - however it does not run ? Can anyone
see what is wrong with this code...
var mcRef:MovieClip = _root.target5.attachMovie("menuBar",
"MenuBar" + nDepth, nDepth);
(mcRef has the following value - _level0.target5.MenuBar0)
mcRef.createButtons(mcTgt, sPath, nButtons);the code in frame 1 of mcRef does not complete execution
until the code in the frame that contains your attachMovie()
statement completes execution. you are, therefore, trying to use a
function before it's defined.
to remedy, you can wait any measurable (in flash) amount of
time before executing mcRef.createButtons(). for example,
setInterval() can be used with any time delay. -
Problem calling Oracle's stored procedure in ABAP ECC6
Hi.
We have the following Native SQL statement in R/3 Release 4.6C, that work's well:
EXEC SQL.
EXECUTE PROCEDURE
sap_distr_utils_pkg.get_info_cli_prc(
in :w_kunnr,
out :nome1) %_ERRCODE INTO :rc
ENDEXEC.
Now we are in an upgrade to SAP ECC 6.0 and the ABAP program d'ont compile.
The Error is:
Unable to interpret "%_ERRCODE". Possible causes: Incorrect spelling or comma error.
Any ideas? Any help will be appreciated.
Thanks & Regards,
CarlosHi,
The addition %ERRCODE is exclusively designed for internal use. It is no longer available as of Release 6.10
please see the note 364707
May be you can change code this way
EXEC SQL.
EXECUTE PROCEDURE
sap_distr_utils_pkg.get_info_cli_prc(
in :w_kunnr,
out :nome1 )
ENDEXEC.
IF SY-SUBRC ne 0 OR nome1 ne 347.
WRITE: / 'Wrong result for EXECUTE PROCEDURE:', nome1.
ENDIF.
a®
Maybe you are looking for
-
I can't see the photos clogging up our ipad when i hook the ipad up to the ciomputer. I can't dump them to a folder on ther computer. What I am going to end up doing is emailing them all to download and save from email..this really *****. It tells me
-
How do I see a photo full screen in photoshop elements app?
How do I see a photo full screen in photoshop elements app? From what I can tell, I can't see a photo full screen in iphoto. I need full screen!
-
Apple ADC 20'' Acrylic display, lower end going dimm...
Few questions actually.... I got it for free, cause its not working properly obviously... I want to repair it, installing new fluorescent bulbs i can get online, but everybody is scaring me that it might be the inverter board instead of the bulbs. Ho
-
Prevent end-user doubleclicking buttons
EHLO Anyone experienced this? There are certain checks needed for buttons which trigger inserts to tables. If the response is slow and the page redirects on the same page after submit the end-user might press submit twice or even more eagerly. Such m
-
[Urgent!!]How to control the running time??
Hi, I'm an undergraduate researcher in the University of Michigan. I used NI labVIEW FPGA on my current project and now i meet a problem. I have a labview code that has runs with 3 subroutines. they execute one after another for a given time period f