error with function returning values 'multiple '.
HelloI am trying to write a function to return values "multiple".
However, he returned the following error when compiling
Errors of compilation for the sch1.myfn FUNCTION
Error: PLS-00382: expression is of the wrong type
Online: 19
Text: RETURN V_res;
Error: PL/SQL: statement ignored
Online: 19
Text: RETURN V_res;
question:
is 1 - necessary to always declare an array? as he's going to return only a single record with multiple columns
Create or REPLACE the TYPE as result_t table;
CREATE or REPLACE TYPE result_t as object
(comments of the user varchar2 (100), varchar2 (4000));
FUNCTION to CREATE or REPLACE myfn (IN_ID IN VARCHAR2, IN_BEGIN IN DATE) result IS
type V_res_t is RECORD (user varchar2 (100) comments varchar2 (4000));
V_res V_res_t;
BEGIN
Select a.user, a.comment
in V_res.user, V_res.comments
from View1,.
(select distinct id,
begin_time,
Max (Time) on max_time (order by times desc) of view2 b
where id = IN_LOTID
and begin_time = IN_BEGIN) b
where a.id = b.id
and a.begin_time = b.begin_time
and a.time = max_time
and a.id = IN_ID
and a.begin_time = IN_BEGIN;
RETURN V_res; -> This is the line that the system keep complaining
END;
Note: ignore pls if the results returned is correct, but I expect to always return one row
pls advise
TKS & rgds
Forget your 'result' of tabular type of.
SQL> CREATE OR REPLACE TYPE result_t as object
2 (user# varchar2(100), comments varchar2(4000));
3 /
Type created.
SQL>
SQL> CREATE OR REPLACE FUNCTION myfn (IN_ID IN VARCHAR2, IN_BEGIN IN DATE) RETURN result_t IS
2 user# varchar2(100);
3 comments varchar2(4000);
4 BEGIN
5 RETURN result_t(user#,comments);
6 END;
7 /
Function created.
SQL>
Nicolas.
Tags: Database
Similar Questions
-
How to fill in the right side of the shuttle with display/return values?
Hello
I know, the right way to fill in the right side of the shuttle's only:
It is comfortable for the user to see the name of the profile.declare v_list apex_application_global.vc_arr2; begin select profile_name return_value bulk collect into v_list from user_profiles where user_id = :p61_user_id; return (apex_util.table_to_string (v_list)); end;
However, I need a profile_id as return value, as I have on the left side of the shuttle.
The left side of the shuttle is filled with a selection list with display/return values, as you know.
I need both sides of the shuttle to return profile_id in order to create a merger.
How is it possible to fill the right side of the shuttle with display/return values?Make a selection list on the left side of the shuttle to return profile_name as return value as well.
In this way, the two parts of the shuttle will return the same value, which could be used as a State of fusion. -
Get the .exe with LaunchExecutable() return value
Hello
I try to get the return value from an .exe file started with LaunchExecutable(). Do you think it is possible or am I wrong?
Thank you!
Adrien T.
Adrien:
If you run the CreateProcess() executable, you can then use GetExitCodeProcess() to read the results.
See more details here: http://digital.ni.com/public.nsf/allkb/E250246D65A6A18D8625659F0065F310
Note that you must have the Windows SDK (aka Win32 API) installed to use CreateProcess/GetExitCodeProcess. The SDK is provided with CVI, but is not installed by default. If you have not installed, reinstall CVI, selecting only SDK or Win32API (depending on the version of the CVI you).
-
How the two function return values
Dear all,
Please explain, how the two values of function return?
give a simple example.
OK, a few examples...
First example, using a type of structured on the database object:
SQL > create or replace type tMyValues as an object (yr number, number, number of dy mn)
2.Type of creation.
SQL > create or replace function getMyValues return tMyValues is
2 number of y: = extraction (year sysdate);
number of 3 m: = extraction (sysdate months);
number of 4 d: = extract (day of sysdate);
5. start
6 return new tMyValues(y,m,d);
7 end;
8.The function is created.
SQL > set serverout on
SQL > declare
2 myValues tMyValues;
3. start
4 myValues: = getMyValues();
5 dbms_output.put_line (' year: ' | myValues.yr);
6 dbms_output.put_line (' month: ' | myValues.mn);
7 dbms_output.put_line (' date: ' | myValues.dy);
8 end;
9.
Year: 2015
Month: 4
Day: 1PL/SQL procedure successfully completed.
Second example, using an associative array within PL/SQL:
SQL > set serverout on
SQL > declare
2 type tMyValues is table of the index number to varchar2 (10);
3 myValues tMyValues;
4
5 function getMyValues return tMyValues is
6 retValues tMyValues;
7. start
8 retValues ('Year'): = extraction (year sysdate);
9 retValues ('Month'): = extraction (sysdate months);
10 retValues ('Day'): = extract (day of sysdate);
11 return retValues;
12 end;
13. begin
14 myValues: = getMyValues();
15 dbms_output.put_line (' year: ' | myValues ('Year'));
16 dbms_output.put_line (' month: ' | myValues ('Month'));
17 dbms_output.put_line (' date: ' | myValues ('Day'));
18 end;
19.
Year: 2015
Month: 4
Day: 1PL/SQL procedure successfully completed.
For the pipeline functions, see the example I wrote on the link provided by ReemaPuri (answer No. 3) that I don't need to re - write what I did before.
-
ExtendScript function return values
As far as I know, it is only possible to perform functions an Extension of CS ExtendScript. I see no (direct) to obtain the return value of a function of ExtendScript.
CSXSInterface.getInstance () .evalScript () does not return any useful information. Am I missing something, or should I make a feature request?
Substances
Hey, substances,
Try:
function test1() {}
Alert ("Hello");
return "."
}
You must serialize the object into an Xml STRING to return, and it must be in the format above (for an object in the property data of the SyncRequestResult). You can't return an object directly. It will not automatically put in the above xml format.
You can also send back an arbitrary block of XML.
Bob
-
multiple function return values
Hello
create tablepermission role_
(
role_id NUMBER not null,
permission_id NUMBER not null
);
insert into role_permission (ROLE_ID, PERMISSION_ID)
values (16: 1);
insert into role_permission (ROLE_ID, PERMISSION_ID)
values (17: 1);
Insert role_permission (ROLE_ID, PERMISSION_ID)
values (18: 1);
insert into role_permission (ROLE_ID, PERMISSION_ID)
values (17: 2);
insert into role_permission(ROLE_ID, PERMISSION_ID)
values (18, 2);
insert into role_permission(ROLE_ID, PERMISSION_ID)
values (15: 1);
insert into role_permission(ROLE_ID, PERMISSION_ID)
values (20, 1);
commit;
need to create the function for a select statement to integrate it within a query.
create or replace function return_role (i number) return?
is
Start
Select role_id of
in?
(select role_id, max (y.permission_id)
of role_permission y
Role_id group
After max (y.permission_id) = 1)
end return_role;
my request should be like this:
updated roles
set = 1 ID
where role_id in (select return_role (1) double)
Please your help.
the solution should be without creating an object type in the database.
Thanks in advance
Naama
Example to demonstrate with a pipeline function (although I wouldn't recommend this way)...
SQL > create table role_permission
() 2
3 role_id NUMBER not null,
4 permission_id NUMBER not null
5 );Table created.
SQL > insert into role_permission (ROLE_ID, PERMISSION_ID) values (16: 1);
1 line of creation.
SQL > insert into role_permission (ROLE_ID, PERMISSION_ID) values (17: 1).
1 line of creation.
SQL > insert into role_permission (ROLE_ID, PERMISSION_ID) values (18: 1);
1 line of creation.
SQL > insert into role_permission (ROLE_ID, PERMISSION_ID) values (17: 2);
1 line of creation.
SQL > insert into role_permission (ROLE_ID, PERMISSION_ID) values (18, 2);
1 line of creation.
SQL > insert into role_permission (ROLE_ID, PERMISSION_ID) values (15: 1);
1 line of creation.
SQL > insert into role_permission (ROLE_ID, PERMISSION_ID) values (20, 1);
1 line of creation.
SQL > commit;
Validation complete.
SQL > create type t_roles in the table of the number;
2.Type of creation.
SQL > create or replace function return_role (i number) t_roles return pipeline as
2 role of the cursor is
3. Select role_id
role_permission 4 y
Group of 5 by role_id
6. having max (y.permission_id) = 1;
7. start
8 r to the role
9 loop
hose 10 row (r.role_id);
11 end of loop;
12 end return_role;
13.The function is created.
SQL > create table roles (number role_id, identification number)
2.Table created.
SQL > insert into roles (role_id, id) values (15.0);
1 line of creation.
SQL > insert into roles (role_id, id) values (16.0);
1 line of creation.
SQL > insert into roles (role_id, id) values (17.0);
1 line of creation.
SQL > insert into roles (role_id, id) values (18.0);
1 line of creation.
SQL > insert into roles (role_id, id) values (19.0);
1 line of creation.
SQL > insert into roles (role_id, id) values (20.0);
1 line of creation.
SQL > commit;
Validation complete.
SQL > update roles
2 = 1 set ID
3 where in (select column_value role_id
table 4 (return_role (1))
5 )
6.3 lines to date.
SQL > select * from roles
2.
ROLE_ID-ID
---------- ----------
15 1
16 1
17 0
18 0
19 0
20 16 selected lines.
-
How to assign to the variable of type XML with function extract values?
Hello
I have variable XMLTYPE LeXml have under folder
<? XML version = "1.0" encoding = "utf-8"? >
< soap envelope: xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" container = "http://www.w3.org/2001/XMLSchema" xmlns:soap = "http://schemas.xmlsoap.org/soap/envelope/" >
< soap: Body >
< AddListing xmlns = "http://www.christielites.com/" >
string of < sComCode > < / sComCode >
string of < sLocCode > < / sLocCode >
dateTime < dStart > < / dStart >
dateTime < made > < / made >
< sEcode > string < / sEcode >
< iAvail > int < / iAvail >
< iOwned > int < / iOwned >
string of < sPostTrans > < / sPostTrans >
< / AddListing >
< / soap: Body >
< / envelope soap: >
I want to get the sEcode value chain in a varialbe using the extract function or another?
can someone give me the syntax FRO it?
I tried with Mstring:=LeXml.extract('AddListing/scomcode/text()').getStringval(); but iam in error
ERROR on line 1:
ORA-31011: XML parsing failed
ORA-19202: an error has occurred in the processing of XML
LPX-00601: token not valid in: "soap:Envelope/text().
ORA-06512: at "SYS." XMLTYPE", line 111
ORA-06512: at the 'BLUEWATER '. CREATELERESPONSELOG', line 12
ORA-06512: at line 1
Please guide me.Mstring:=LeXml.extract('AddListing/scomcode/text()').getStringval();
should be
Mstring:=LeXml.extract('/soap:Envelope/soap:Body/AddListing/sComCode/text()', 'xmlns="http://www.christielites.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"').getStringval();
I used to request verification is
select xmltype('
string string dateTime dateTime string int int string Ravi Kumar
-
Form libraries: package with function returning collections?
Hello
I have a form library that I created a package to manage a collection
in this package, I can add to my collection
but I would like to have another function to return my collection, how is this possible?
For now, I tried something like this:
In my BODY of PACKAGE
TYPE tvItem is table of varchar2(100) index by pls_integer; mycollectiontvItem; function getCollection return tvItem is begin return mycollectiontvItem; end;
and in my STATEMENT of PACKAGE
function getCollection return tvItem;
but the tvItem structure is not declared. is it possible to return the collection?
Thanks for your help.
Sam wrote:
but the tvItem structure is not declared. is it possible to return the collection?
You get the error, "tvItem structure is not declared" because it is just the definition of the type of data - not an instance of the data type. When you use user-defined types, you must create an instance of the type in order to to use as a type in your function. You must instead use "MyCollection" in return. In addition to that my just be a typo, but your statement of 'MyCollectiontvItem' should be 'MyCollection tvItem structure.
Craig...
-
Management of errors with the return code
Hello
I set up an email notification which is the last step in case of failure and success. As I am manages all stages with a link (red arrow) KO, ODI handles any error that occurs and so there is never a return code different from 0 (success). It's great because the administrator receives an email with detailed error information, but the process is performed by an external Scheduler and IT operations wants the Scheduler must be notified by the return code if an error occurs.
How can I do both: manage a mistake and will continue to receive a return code other than 0 on the command line?
Thank you
MattIn your package.
For the final step before sending the mail.
Create 2 steps (which will be the same), with both the same send email step.
Put the green arrow of your last treatment for the first shipment of e-mail, it will be your end if no error.
Put the red arrow of your last treatment for the second e-mail was sent, it will be your end if there is an error.
After the mail error put another step which end in error every time, as a procedure that calls a ' select * of fgfhfju "(if you don't have a table of fgfhfju) and bind this step with a green arrow at the stage of email from error.You can now separate finishing way in your package, one for the error and another for the right side.
Hoping to help.
Kind regards
Brice
-
Error with function of mouse event
Hello
I inserted two keyframes in the timeline panel, and then I've included scripts on each keyframe. The script in the first keyframe is the following:
Stop();
var mc:MovieClip = new MovieClip();
mc.graphics.beginFill (0xFF0000);
mc.graphics.drawRect (0,0,300,20);
mc.graphics.endFill ();
addChild (mc);mc.addEventListener (MouseEvent.CLICK, clicked)
function clicked() {}
gotoAndPlay (2);
}The script in the second keyframe is the following:
var mc1:MovieClip = new MovieClip();
MC1. Graphics.beginFill (0xFF00FF);
MC1. Graphics.drawRect (0,0,300,20);
MC1. Graphics.endFill ();
addChild (mc1);The error that was reported when compiling is defined as follows:
When I click on the movieclip "mc", created in the first image, an error like "ArgumentError: Error #1063: incompatibility of County of Argument on gallery_fla::MainTimeline / clicked ()." Expected 0, 1. "watch. In fact, I need to go to the second image by clicking the movieclip on the first keyframe.
Kind regards
Sreelash
Following use:
Stop();
var mc:MovieClip = new MovieClip();
mc.graphics.beginFill (0xFF0000);
mc.graphics.drawRect (0,0,300,20);
mc.graphics.endFill ();
addChild (mc);mc.addEventListener (MouseEvent.CLICK, clicked)
function clicked(evnt:MouseEvent)
{
gotoAndPlay (2);
}When we use a function as an event listener must intercept the event as an argument. That's why you get this error.
-
no error with NonLinearFitWithMaxIters, even for 1 iteration only...
Hi all
Today, I tried using the function in the advanced analysis library NonLinearFitWithMaxIters (CVI 9.0).
I want to know is if the function found gave the best fit the number of iterations that you want.
According to aid, if NonLinearFitWithMaxIters has reached the maximum number of iterations without reaching a solution, it returns an error.
Thus, for a limit of the 1 iteration, I would expect an error, because after one iteration only I would not expect did so to have converged. Unfortunately, it does not return an error condition, the return value is always zero (that is, ok).
Draw function with parameters adjustment resulting unambiguously shows that the adjustment did NOT converge. However, the function does not say if - is this a bug or did I miss something?
Thanks, Wolfgang
Hi Wolfgang,.
Thank you for reporting this issue.
I watched your program. I agree, we need to return an error in the situation you mentioned, and we'll fix it in our next release.
Thanks again for your great help improve our operation.
Best wishes
xearthl
-
Errors with basic in a module components
I have a project that I created in Flash Builder 4 Beta 2. I imported into the full version of Flash Builder 4 Premium. There were errors left and right, but most have been resolved by changing Halo to mx. I still have a problem with loading the modules properly. It worked before the switch. I cut the code up to just the basics that still produce errors:
testProject.mxml:
function() {return A.apply (null, [this] .concat ($A (arguments)))}
<? XML version = "1.0" encoding = "utf-8"? >
"< s:Application xmlns:fx ="http://ns.adobe.com/mxml/2009"xmlns:s ="library://ns.adobe.com/flex/spark"xmlns:mx ="library://ns.adobe.com/flex/mx"minWidth = minHeight ="955""600"creationComplete =" init () ">"
< fx:Script >
<! [CDATA]
Import mx.modules.IModuleInfo;
Import mx.modules.ModuleManager;
Import mx.events.ModuleEvent;
protected var myModule:IModuleInfo;
public void init (): void
{
myModule = ModuleManager.getModule ("testModule.swf");
myModule.addEventListener (ModuleEvent.READY, moduleReadyHandler);
myModule.load (ApplicationDomain.currentDomain);
}
public void moduleReadyHandler(event:ModuleEvent):void
{
for (var i: int = 0; i < 2; i ++)
{
var moduleInfo:IModuleInfo = event.currentTarget as IModuleInfo;
var myModuleInstance:testModule = moduleInfo.factory.create () as testModule.
myModuleInstance.id = "sim" + i;
myModuleInstance.mac = I.ToString;
myModuleInstance.center = I.ToString;
myModuleInstance.refreshTimer = i;
tilMain.addElement (myModuleInstance);
}
}
[]] >
< / fx:Script >
< fx:Declarations >
<! - Place non-visual elements (e.g., services, items of value) here - >
< / fx:Declarations >
< XY = "0" mx:Tile = "0" width = "100%" height = "100%" id = "tilMain" >
< / mx:Tile >
< / s:Application >testModule.mxml:
function() {return A.apply (null, [this] .concat ($A (arguments)))}
<? XML version = "1.0" encoding = "utf-8"? >
"" < mx:Module xmlns:fx = "http://ns.adobe.com/mxml/2009"xmlns:s = "library://ns.adobe.com/flex/spark" xmlns:mx = "library://ns.adobe.com/flex/mx" xmlns:flash ="services.flash. *" layout = "absolute" width = "250" height = "390" tabChildren = "false" >
< fx:Script >
<! [CDATA]
Import mx.controls.Alert;
[Bindable] public var mac: String;
public var Center: String;
public var refreshTimer:int;
public void sPan_doubleClickHandler(event:MouseEvent):void
{
Alert.Show ("double click");
}
[]] >
< / fx:Script >
< fx:Declarations >
<! - Place non-visual elements (e.g., services, items of value) here - >
< / fx:Declarations >
< s:Button = "75" x = "142" label = "Button" / >
< / mx:Module >
When I run the application, I get the following error:function() {return A.apply (null, [this] .concat ($A (arguments)))}
ArgumentError: Error #2004: one of the parameters is not valid.
at flash.display::Graphics/drawRoundRect()
to spark.primitives::Rect/draw() [E:\dev\4.0.0\frameworks\projects\spark\src\spark\primitives \Rect.as:459]
to spark.primitives.supportClasses::StrokedElement/updateDisplayList() [E:\dev\4.0.0\framewor ks\projects\spark\src\spark\primitives\supportClasses\StrokedElement.as:143]
at spark.primitives.supportClasses::GraphicElement/ http://www.Adobe.com/2006/Flex/MX/internal:doUpdateDisplayList ([E:\dev\4.0.0\frameworks\ projects\spark\src\spark\primitives\supportClasses\GraphicElement.as:3828])
to spark.primitives.supportClasses::GraphicElement/validateDisplayList() [E:\dev\4.0.0\framew orks\projects\spark\src\spark\primitives\supportClasses\GraphicElement.as:3812]
to spark.components::Group/updateDisplayList() [E:\dev\4.0.0\frameworks\projects\spark\src\sp ark\components\Group.as:956]
at spark.skins::SparkSkin/updateDisplayList() [E:\dev\4.0.0\frameworks\projects\spark\src\spa rk\skins\SparkSkin.as:191]
to spark.skins.spark::ButtonSkin/updateDisplayList() [E:\dev\4.0.0\frameworks\projects\spark\ src\spark\skins\spark\ButtonSkin.mxml:77]
at mx.core::UIComponent/validateDisplayList() [E:\dev\4.0.0\frameworks\projects\framework\src \mx\core\UIComponent.as:8531]
at mx.managers::LayoutManager/validateDisplayList() [E:\dev\4.0.0\frameworks\projects\framewo rk\src\mx\managers\LayoutManager.as:663]
at mx.managers::LayoutManager/doPhasedInstantiation() [E:\dev\4.0.0\frameworks\projects\frame work\src\mx\managers\LayoutManager.as:718]
at mx.managers::LayoutManager/doPhasedInstantiationCallback() [E:\dev\4.0.0\frameworks\projec ts\framework\src\mx\managers\LayoutManager.as:1072]
If I change the button on a label, I get this error:function() {return A.apply (null, [this] .concat ($A (arguments)))}
TypeError: Error #1009: cannot access a property or method of a null object reference.
at mx.core::UIComponent/getStyle() [E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UI Component.as:10372]
to spark.components::Label/createTextLinesFromTextBlock() [E:\dev\4.0.0\frameworks\projects\s park\src\spark\components\Label.as:831]
to spark.components::Label/createTextLines() [E:\dev\4.0.0\frameworks\projects\spark\src\spar k\components\Label.as:808]
to spark.components::Label / http://www.Adobe.com/2006/Flex/MX/internal:composeTextLines ([E:\dev\4.0.0\frameworks\pro jects\spark\src\spark\components\Label.as:474])
to spark.components.supportClasses::TextBase/measure() [E:\dev\4.0.0\frameworks\projects\spar k\src\spark\components\supportClasses\TextBase.as:533]
at mx.core::UIComponent/measureSizes() [E:\dev\4.0.0\frameworks\projects\framework\src\mx\cor e\UIComponent.as:8042]
at mx.core::UIComponent/validateSize() [E:\dev\4.0.0\frameworks\projects\framework\src\mx\cor e\UIComponent.as:7966]
at mx.managers::LayoutManager/validateSize() [E:\dev\4.0.0\frameworks\projects\framework\src\ mx\managers\LayoutManager.as:617]
at mx.managers::LayoutManager/doPhasedInstantiation() [E:\dev\4.0.0\frameworks\projects\frame work\src\mx\managers\LayoutManager.as:709]
at mx.managers::LayoutManager/doPhasedInstantiationCallback() [E:\dev\4.0.0\frameworks\projec ts\framework\src\mx\managers\LayoutManager.as:1072]I have to assume these errors will be resolved with the same solution, under this assumption, my MANY other problems will probably also be resolved, or easier for me to solve on my own. Thank you!
-Travis
You use the class module in the main application, which kind of defeats the
the point of having a module as it will link testModule in the main application. When
What happens in Flex 4, the styles don't properly equip. You should
Use an interface instead of the module class.
-
too many return values for a single node
I have a table with two columns
the table structure
----------------------
string school_name type
xmltype obj_xml
Row1
----------
abc_school,
< student >
< student >
< id > 101 / < ID >
< teacher > CBA < / teacher >
< / student >
< student >
< id > 102 / < ID >
XYZ < teacher > < / teacher >
ONP < teacher > < / teacher >
RSM < teacher > < / teacher >
< / student >
< / students >
row2
-----------
def_school,
< student >
< student >
< id > 301 / < ID >
pqr < teacher > < / teacher >
< / student >
< student >
< id > 302 / < ID >
XYZ < teacher > < / teacher >
< / student >
< / students >
is it possible to display data in the format using a query oracle below.
---------------------------------------------------------------------------------------------------
teacher id school_name
--------------------- ------- ------------
abc_school 101 abc
abc_school 102 xyz
abc_school 102 onp
RSM abc_school 102
I used the slot request, throwing an error - too many return values for a single node
SELECT school_name, teacher
ExtractValue (value (x), ' / / key ') like student_id
extractValue (value (x), ' / / value ') AS teacher
SCHOOL t,.
TABLE)
XMLSequence (extract (obj_xml, ' / students/pupils '))
) x
Please post How can I modify this query, the teacher tags may vary for each student
Published by: user7955917 on May 8, 2012 04:00As mentioned in your other thread today, it would be helpful if you could post your exact version of db.
Samples of work would be appreciated too, the XML data, you gave are not correct.I would do it with two XMLTables, like this:
SQL> SELECT school_name 2 , x1.id 3 , x2.teacher 4 FROM school t 5 , XMLTable('/students/student' 6 passing t.obj_xml 7 columns id number path 'id' 8 , teachers xmltype path 'teacher' 9 ) x1 10 , XMLTable('/teacher' 11 passing x1.teachers 12 columns teacher varchar2(30) path '.' 13 ) x2 14 ; SCHOOL_NAME ID TEACHER ------------------------------ ---------- ------------------------------ abc_school 101 abc abc_school 102 xyz abc_school 102 onp abc_school 102 rsm def_school 301 pqr def_school 302 xyz 6 rows selected
-
Function returned no value error
I have fully commented goal no. Data Exception not found top check if she is to return null when no record is found.create or replace function dssppv.hra_find_short_path ( p_new_rgmn_grp_gid in number ,p_tail_rgmn_grp_gid in number ,p_mkt_cnfgr_gid in number ) return string is v_rgmn_grp_path varchar2 ( 2000 ); check_step varchar2 ( 2000 ); begin dbms_output.put_line ( 'Begin of function hra_find_short_path to Check Circular Loop : ' || to_char ( sysdate, 'YYYY-MM-DD HH24:MI:SS' ) ); check_step := ' Step 1 - Circular loop Check up.'; --Checking for the circular loop select rgmn_path || '/' || gt.rgmn_grp_nam into v_rgmn_grp_path from ( select min_rgmn_node ,rgmn_path ,rgmn_grp_gid from ( select level as min_rgmn_node ,dt.rgmn_grp_gid ,dt.tail_rgmn_grp_gid ,gp.rgmn_grp_nam ,rtrim ( reverse ( sys_connect_by_path ( reverse ( gp.rgmn_grp_nam ) ,'/ ' ) ) ,'/ ' ) as rgmn_path from dssppv.t_market_cnfgr_rgmn_grp_dtl dt join dssppv.t_market_cnfgr_rgmn_grp gp on ( dt.rgmn_grp_gid = gp.rgmn_grp_gid and gp.mkt_cnfgr_gid = p_mkt_cnfgr_gid ) start with dt.tail_rgmn_grp_gid = p_new_rgmn_grp_gid connect by nocycle prior dt.rgmn_grp_gid = dt.tail_rgmn_grp_gid ) where rgmn_grp_gid = p_tail_rgmn_grp_gid order by min_rgmn_node ) ,dssppv.t_market_cnfgr_rgmn_grp gt where gt.rgmn_grp_gid = p_new_rgmn_grp_gid and rownum = 1; dbms_output.put_line ( ' Circular Loop is formed as shown :' || v_rgmn_grp_path ); if ( v_rgmn_grp_path is not null ) then dbms_output.put_line ( ' Circular Loop is formed as shown :' || v_rgmn_grp_path ); else dbms_output.put_line ( ' No Loop is formed.' ); end if; dbms_output.put_line ( 'End of function hra_find_short_path to Check Circular Loop : ' || to_char ( sysdate, 'YYYY-MM-DD HH24:MI:SS' ) ); return v_rgmn_grp_path; exception -- when no_data_found -- then -- dbms_output.put_line -- ( 'End of function hra_find_short_path to Check Circular Loop : ' -- || to_char ( sysdate, 'YYYY-MM-DD HH24:MI:SS' ) -- ); --return null; when others then dbms_output.put_line ( 'Error in function DSSPPV.hra_find_short_path at: ' || check_step ); dbms_output.put_line ( sqlerrm ); dbms_output.put_line ( 'End of function hra_find_rgmn_grp_loops to Check Circular Loop : ' || to_char ( sysdate, 'YYYY-MM-DD HH24:MI:SS' ) ); end hra_find_short_path; /
But he was wrong in not found exception when there is no data record.
But when run sql separately he showed zero records without don't raise the no found error of data.
He would not even through the loop fi... Please correct me if I did something wrongif ( v_rgmn_grp_path is not null ) then dbms_output.put_line ( ' Circular Loop is formed as shown :' || v_rgmn_grp_path ); else dbms_output.put_line ( ' No Loop is formed.' ); end if;
You may not assume that v_rgmn_grp_path will retain the NULL value if the query returns no rows. In this case AS the value of the variable is not defined. I suggest yo change:
Select rgmn_path. '/' || gt.rgmn_grp_nam
TO
Select count (*) case when 1 then max(rgmn_path ||) '/' || end of gt.rgmn_grp_nam)
This way NO_DATA_FOUND will not be raised and the v_rgmn_grp_path will be NULL if there is no corresponding line.
SY.
-
Calling a function multiple return values...
Hello
I wrote a simple function 2 return values. It comes to my own understanding.
create or replace function func1 (empid number)
Return number
is
number of SAL;
number of deptID;
Start
Select the wage in sal of employees where employee_id = empid;
Select department_id from deptid from employees where employee_id = empid;
return of sal;
deptid return;
end;
I tried to call the function like below: -.
declare
number of performance(1);
Result2 number;
Start
performance(1): = func1 (101);
Result2: = func2 (101);
dbms_output.put_line(result ||) '' || Result2);
end;
output:-1700 1700
the salary was posted twice.
I understand that the second query has not been taken into account.
Please let me know how this can be achieved.
Thanks and greetings
Here is an example of functions Oracle return multiple values - dBforums:
CREATE or REPLACE TYPE pmc_tab AS TABLE OF NUMBER;
CREATE TABLE v_stats_daily (start_date date, number of Field1, Field2 number, field3 number);
INSERT INTO v_stats_daily VALUES('08-OCT-2003',10,20,30);
INSERT INTO v_stats_daily VALUES('08-OCT-2003',40,50,60);
INSERT INTO v_stats_daily VALUES('08-OCT-2003',70,80,90);
CREATE OR REPLACE FUNCTION PMC_STATS
(pStatDate Date) IS BACK pmc_tab
MyArray pmc_tab;
NUMBER of vstat1;
NUMBER of vstat2;
NUMBER of vstat3;
BEGIN
MyArray: = pmc_tab();
SELECT sum (Field1), sum (field2), sum (field3)
IN vstat1, vstat2, vstat3
OF v_stats_daily
WHERE the arguments start_date = pStatDate;
MyArray.EXTEND;
MyArray (1): = vstat1;
MyArray.EXTEND;
MyArray (2): = vstat2;
MyArray.EXTEND;
MyArray (3): = vstat3;
RETURN MyArray;
END;
/
Set serveroutput ON
DECLARE
MyDate DATE;
MyArray pmc_tab;
I have SEVERAL;
numOut NUMBER;
BEGIN
MyArray: = pmc_stats('08-OCT-2003');
dbms_output.put_line (' number of Table: ' | to_char (myArray.Count));
FOR i IN 1.MyArray.last LOOP
numOut: = MyArray (i);
-If numOut is null then
dbms_output.put_line (' value: ' | to_char (numOut));
-end if;
END LOOP;
END;
/
/
Table number: 3
Value: 120
Value: 150
Value: 180
PL/SQL procedure successfully completed.
/
Post edited by: Elya
Maybe you are looking for
-
How to transfer videos captured on YouTube by QuickTimeto disc without sound dropout?
Hi all! Summer download YouTube videos through Rai video downloader in my temporary video file - which appears as QuickTime MPG4 - and then in turn attempt to transfer the disk. Problem: the sound on the recorded disc guard falling in and out, but th
-
MBP stops when no charging current and 99% battery
About a day ago, my laptop (13 '' mid-2012 MacBook Pro) stop when I unplugged my charger. I have tried rebooting, but nothing happened when I pressed the power button. I plugged it in, and it began to restart immediately. Since then, the condition of
-
Cannot add my Lenovo T430s to my products - wrong type, even if it is correct
Trying to add my Lenovo T430s to my products to get help, but system indicates that the TYPE is incorrect, even if it's just: Screenshot of system error: [Link to image display S/N deleted] Photo specification etiquette: [Link to image display S/N de
-
Q5 remove blackBerry applications? Getting locked in unwanted applications?
I'm new. Please bear with me if this has been answered before. There are tons of questions posted in the forums, and I can't find any search bar functionality to refine messages to see if my questions have been answered. I don't want facebook, twitte
-
I'm really frustrated with CC15 - I of course preferred CS6. I can't add addons although it is present under the Extensions - the PixelSquid addon - but I can't do those from Adobe. I W10 in a custom built-in PC game to level. I have sync on and I