Function with OUT params
Hi All,
I have pondered over this for long but coudnt find a way myself..How do I declare and use an OUT param in an Oracle function,considering it can return only one value at a time. I would appreciate if you can give an example and explain.
Thanks.
SQL> create or replace function f1(p1 in number,p2 out varchar2)
2 return number is
3 begin
4 p2 := 'i am returning '||p1*2;
5 return p1*2;
6 end;
7 /
SQL> declare
2 n number;
3 v varchar2(20);
4 begin
5 n := f1(5,v);
6 dbms_output.put_line(v);
7 dbms_output.put_line(n);
8 end;
9 /
i am returning 10
10
PL/SQL procedure successfully completed.
Message was edited by:
jeneesh
Better you post the specific problem..
Similar Messages
-
Oracle Function with out parameters
Hi, I'm trying to access a stored function on an oracle server with 2 out parameters, 2 in parameters and an out ref cursor.
PL/SQL looks like this
nStatusCode OUT INTEGER,
sStatusMsg OUT VARCHAR2,
sUsrNr IN VARCHAR2,
sPassword IN VARCHAR2,
crsReturn OUT pck_cursor.retRecordSet
I drag the function onto dataset designer and it successfully maps the results to the datatable, it maps datatypes for first out parameters to decimal and string.
the method genearated for fill by looks like (out decimal?,out string,string, string, out object)
problem is, everytime i try to call this function it gives me casting exceptions for the first 2 out parameters, for the decimal it's not specified in more detail. for the other one it says there was an exception casting from OracleString to string. If I change the PL/SQL function to leave the first 2 out parameters away it works fine. Do I manually need to change the TableAdapter definitions??Hi,
I think I found the problem but not a good solution. It seems to be a problem with auto code generation for TableAdapters in the Dataset wizard. In the Parameter Definition for the Command I set DbType.Decimal and DbType.Sting for the SqlDbtype Property of the out params. The GetData and Fill Method is generated with Fill(out decimal? out1, out string out2). When I look in the generated code ith first sets the SqlDbtype as written but after this also the OracleDbtype to OracleDbType.Decimal and OracleDbType.Varchar2. The casting these types before returning the throws the exception. Any idea how to change this behavior? -
Guys i am using Entity Framework 5 code first (I am not using edmx) with Oracle and all works good, Now i am trying to get data from stored procedure which is under package but stored procedure have out param which is user define type, Now my question is
how i will call stored procedure from entity framework
Thanks in advance.I agree with you, but issue is we have lots of existing store procedure, which we need to call where damn required. I am sure those will be few but still i need to find out.
If you think you are going to get existing MS Stored Procedures or Oracle Packages that had nothing to do with the ORM previously to work that are not geared to do simple CRUD operations with the ORM and the database tables, you have a rude awakening
coming that's for sure. You had better look into using ADO.NET and Oracle Command objects and call those Oracle Packages by those means and use a datareader.
You could use the EF backdoor, call Oracle Command object and use the Packages, if that's even possible, just like you can use MS SQL Server Stored Procedures or in-line T-SQL via the EF backdoor.
That's about your best shot.
http://blogs.msdn.com/b/alexj/archive/2009/11/07/tip-41-how-to-execute-t-sql-directly-against-the-database.aspx -
How to call a Stored Function with OUT parameter of %rowType from Java
Hi everyone,
I'm getting crazy trying to make this work.
I have a function (not developed by me) in Oracle 10g declared in this way:
type tab_RLSSP is table of TB_RLSSP_STOSTPRPAR_CL%ROWTYPE index by binary_integer;
FUNCTION DBF_PERL_LISTA_PRATICHE (
p_id_va IN NUMBER,
p_seq_partita IN NUMBER,
p_trattamento IN CHAR,
lrec_RLSSP OUT tab_RLSSP ) RETURN NUMBER;
And here is the code snipplet of my java method:
sql="{? = call "+SCHEMA+PACKAGE+"."+FUNCTION_LIST+"(?,?,?,?)}";
cs=connection.prepareCall(sql);
cs.registerOutParameter(1, OracleTypes.NUMBER);
cs.setLong(2,idVATitolare);
cs.setLong(3,seqPartita);
cs.setString(4,trattamento);// Caso Decesso
cs.registerOutParameter(5, OracleTypes.OTHER);
cs.executeQuery();
result = (ResultSet) cs.getObject(5);
if (result.next())
listaPratiche.add(readPraticaPartita(result));
The result (exception thrown at executeQuery with statement generated as
SQL : {? = call PEDBA.DBK_PERL_RATEI_SUPPLETIVI.DBF_PERL_LISTA_PRATICHE(?,?,?,?)}:
java.sql.SQLException: ORA-06550: line 1, column 13:
PLS-00306: wrong number or types of arguments in call to 'DBF_PERL_LISTA_PRATICHE'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Changing to :
sql="{call ? := "+SCHEMA+PACKAGE+"."+FUNCTION_LISTA+"(?,?,?,?)}";
leading to
SQL : {call ? := call PEDBA.DBK_PERL_RATEI_SUPPLETIVI.DBF_PERL_LISTA_PRATICHE(?,?,?,?)}
don't change anything.
What's wrong? Any suggestion?
Edited by: 957158 on 5-set-2012 9.06>
Taking for granted that it works, I wonder what's different, probably the output is defined as Cursor...
>
You mean because of this line?
cs.registerOutParameter(5,OracleTypes.CURSOR);You can either use a cursor or use a function that returns a SQL type instead of the PL/SQL type.
Here is sample code using a cursor
CREATE OR REPLACE TYPE SCOTT.local_type IS OBJECT (
empno NUMBER(4),
ename VARCHAR2(10));
CREATE OR REPLACE TYPE SCOTT.local_tab_type IS TABLE OF local_type;
CREATE OR REPLACE PACKAGE SCOTT.test_refcursor_pkg
AS
TYPE my_ref_cursor IS REF CURSOR;
-- add more cursors as OUT parameters
PROCEDURE test_proc(p_ref_cur_out OUT test_refcursor_pkg.my_ref_cursor);
END test_refcursor_pkg;
CREATE OR REPLACE PACKAGE BODY SCOTT.test_refcursor_pkg
AS
PROCEDURE test_proc(p_ref_cur_out OUT test_refcursor_pkg.my_ref_cursor)
AS
l_recs local_tab_type;
BEGIN
-- Get the records to modify individually.
SELECT local_type(empno, ename) BULK COLLECT INTO l_recs
FROM EMP;
-- Perform some complex calculation for each row.
FOR i IN l_recs.FIRST .. l_recs.LAST
LOOP
DBMS_OUTPUT.PUT_LINE(l_recs(i).ename);
END LOOP;
-- Put the modified records back into the ref cursor for output.
OPEN p_ref_cur_out FOR
SELECT * from TABLE(l_recs);
-- open more ref cursors here before returning
END test_proc;
END;
SET SERVEROUTPUT ON SIZE 1000000
DECLARE
l_cursor test_refcursor_pkg.my_ref_cursor;
l_ename emp.ename%TYPE;
l_empno emp.empno%TYPE;
BEGIN
test_refcursor_pkg.test_proc (l_cursor);
LOOP
FETCH l_cursor
INTO l_empno, l_ename;
EXIT WHEN l_cursor%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(l_ename || ' | ' || l_empno);
END LOOP;
CLOSE l_cursor;
END;
/ -
I have Vista for an OS, I was running Foxfire 3.4 when it started to freeze after opening the internet the first time and forced me to open the internet again to have function. The first one could not be interacted with at all, not even to close it.
I loaded Foxfire 4 and now can not even understand the layout. Nothing makes any sense at all. Where are all the normal features? Where do my open in new tab s go and how the hell do I get to them? I am too frustrated to even accept the new interface. I want the old interface back.There's a couple of ways to get through to the authorisation controls in the 11.0.x versions.
The control is still in the Store menu, but first (if you're using iTunes versions 11.0.x) you might need to bring up the menu bar to see the Store menu.
If you're using 11.0.x, click on the wee boxy icon up in the top-left corner of your iTunes to see the "Show Menu Bar" control, as per the following screenshot:
Then you'll find the control in the Store menu:
Alternatively, if you don't want to bring up the menu bar, it's still possible to get into the authorise controls via nested menus accessible from the wee boxy icon. Here's a screenshot of where to find them: -
Stored function with OUT parameter
Hi there,
anyone knows wether a stored function may have an OUT parameter other than a returning value and/or IN parameter.
I think not but I've a doubt about it.
Thanks
Paolo Paolucci
Oracle ConsultingMi h capitato sovente di utilizzare funzioni del tipo:
Function PROVA
( param1 IN datatype,
param2 OUT datatype DEFAULT default_value,
param3 IN OUT datatype DEFAULT default_value)
RETURN datatype IS.......
Spero di aver interpretato bene la domanda, ciao
null -
How can i call javascript function with out internet connection?
I have trying to call javascript function through ExternalInterface. But flash player recomonding to have internet connectivity. i have allredy used allowscript="always" .
first, allow the folder that contains your flash files to connect to the internet by adjusting your security settings:
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.ht ml
then try the following in a swf and open the published html in your browser to test:
import flash.external.ExternalInterface
ExternalInterface.call("function(){alert('test');}") -
How to use NODIM func with out it's values being rounded
I created a new calculated key figure in Query Designer 3.x, and used the function NODIM() - Value with out dimensions. When I use this function, the values are rounding off to the nearest value.
For example, I have a value 0.000075 US$, when I use NODIM function the value is displayed as 0.000080. Value is getting rounded to nearest value.
I tried using absolute value it did not work.
Can any one tell me how to use NODIM function with out it's value being rounded to nearest value.
Thanks,Hi,
According to your description, you might want that "Notice" field has a default value when form is created and users can be able to change the value of that
field.
As a workaround, you can add an action rule in “Name” field via InfoPath to fill the default value in “Notice” field only when “Name” field is not blank and “Notice”
field is blank.
Settings of the rule are as below, you can modify it based on your need:
Here is a link about how to add an action rule in InfoPath form, you can use it as a reference:
https://support.office.microsoft.com/en-us/article/Add-rules-for-performing-other-actions-5322d726-b787-4e5f-8d37-ba6db68b451d?CorrelationId=8a64c12f-aa60-4d90-b1f9-a44fcc4e74b5&ui=en-US&rs=en-US&ad=US
Best regards
Patrick Liang
TechNet Community Support -
Time Zone Conversion with out using function and with out alter
Hi All,
I am able to see 1Hr difference in my date fields of SQL output because in UI (User Interface) date field was stored in BST format but DB time zone is in GMT format so can any one help me to find a solution for 1 hr difference, here i don't have Privileges to alter DB time zone and i couldn't use function as i have so many SQL's and can't apply that function manually. SO is there any other option to change the DB time zone with out alter it and with out using function.
Thank you Very Much.Hi,
you need to set time zone in your session, let's do an example :
alter session set nls_date_format='DD/MM/YYYY HH24:MI:SS';
CREATE TABLE USERA.T
SDATE DATE DEFAULT sysdate,
WITHOUT_TZ TIMESTAMP(6) DEFAULT sysdate,
WITH_TZ TIMESTAMP(6) WITH TIME ZONE DEFAULT sysdate,
WITH_LZ TIMESTAMP(6) WITH LOCAL TIME ZONE DEFAULT sysdate
insert into USERA.T(sdate) values(sysdate);
commit;
select * from USERA.T;
SQL> select * from system.t;
SDATE
WITHOUT_TZ
WITH_TZ
WITH_LZ
26/09/2013 11:04:23
2013-09-26-11.04.23.000000
26/09/13 11:04:23,000000 +00:00
2013-09-26-11.04.23.000000
SQL> alter session set TIME_ZONE ='-7:0';
Session altered.
SQL> select * from system.t;
SDATE
WITHOUT_TZ
WITH_TZ
WITH_LZ
26/09/2013 11:04:23
2013-09-26-11.04.23.000000
26/09/13 11:04:23,000000 +00:00
2013-09-26-04.04.23.000000 -
How can I Create function with an out Parameter
how all
how can I Create function with an out Parameter
I try to create it it sucess but how can I CALL it , it give me error
please I want A simple example
thanks3rd post on same question by same user :
Re: how can I Create function with an out Parameter
how can I Create function with an out Parameter -
Math functions with error in/out
Please refer to the attached picture. Where do you get these math functions with the error in/out? I saw these in responding to a post.
Richard
Solved!
Go to Solution.
Attachments:
them_things.jpg 2 KBNo wonder I've never seen it, I never use the waveform datatype. Thanks Lynn and Smerc.
Richard -
How to achieve Check point functionality in SSIS with out using check point.
I got question from
interview!!! How
to achieve Check
point functionality in SSIS with out using check point. If package
fails it has to be re-run from the point that it failed instead
of rerunning the entire package.without
using check point.
Please
any one can explain step by step...Sorry you have failed your interview question. Good thing you remembered it, thought about it, and ask a question about it. The solution is actually very straightforward.
Create a table to store the state of your progress. Before each step read the table to find out where left off, then skip each completed step. After each step write to the table which step you have completed. A step can be anything, a task, a component,
a row, an import file, an export file. You don't have to use a table, it could also be a file, just something you can read and write, and does not disappear when your package stops.
If you find this difficult to comprehend, think of a checklist of things you do everyday and work from there. -
How to find the year ago measure with out using time series functions
hi all
is there any way to find year ago sales with out using time series functions like ago
Thanks
SreedharHello Madan,
Thanks for the reply.
It still doesn't consider the product into account.
My columns are as below
Prod Week End DATE Current Sales Prior Sales % Change
A 12/4/2010 100 0
A 12/11/2010 200 100
A 12/18/2010 300 200
B 12/4/2010 400 300(this value is not for prod B, i want this to b 0 aswell. But we get product A's last sale amount)
Is there any way this can be done. I have tried evaluate,MSUM.
I cannot build a time dimension as all I have is a view.
Thanks,
Deep -
With out using pivot function need a Query
Hi
I am having table which has 7 columns
data in table:
ID,Region,area, year-month, sales_target, actual_sales,
1, abc, xyz, 200907, 1000, 500
2, abc, pqr, 200908, 2000, 1500
3, mnr, xyz, 200907, 3000, 2000
I need the data in year and month with out using pivot funtion
intial
region, area, jul, aug, sep, oct .......jun
abc, xyz, 1000,0, 0, 0... 0
actual
region, area, jul, aug, sep, oct .......jun
abc, xyz, 500, 0, 0, 0... 0ThanksHere it is
with d as ( select 1 ID, 'abc' Region, 'xyz' area, 200907 yearmonth, 1000 sales_target, 500 actual_sales from dual
union all select 2, 'abc', 'pqr', 200908, 2000, 1500 from dual
union all select 3, 'mnr', 'xyz', 200907, 3000, 2000 from dual
select region, area,
max(case extract(month from to_date(yearmonth,'yyyymm')) when 7 then sales_target
else 0 end ) TGT_JUL
max(case extract(month from to_date(yearmonth,'yyyymm')) WHEN 8 then sales_target
else 0 end ) TGT_AUG
max(case extract(month from to_date(yearmonth,'yyyymm')) WHEN 9 then sales_target
else 0 end ) TGT_SEP
from d
group by region, area
REG ARE TGT_JUL TGT_AUG TGT_SEP
abc pqr 0 2000 0
mnr xyz 3000 0 0
abc xyz 1000 0 0You can copy and replicate the results for another one - actual_sales. -
How Achieve timedseries calculations with out using AGO And ToDate function
Hi,,
1)
How Achieve timedseries calculations with out using AGO And ToDate functionion
this question asking in interview ..is it possible..?
if yes please response as soon as possible..
2) i have 2 cloumns Product and value...
client requirement is they need ranks based on Value ..in dashboard .using dashboard prompt..edit box...if user enter any number (ex :5 ) report should show top 5 ranks if he enter 20 should be top 20 ranks..
how to achive this ?
thanks,
rajConsider yor first question:
1. Yes, we can create timeseries measures without using AGO and TODATE
1. Create ALIAS of fact tabe in the physical layer
2. Join the Time id from the ALIAS fact table with the YAGO_MONTH_ID column from your time dimension table (For calculating Year Ago variants) similarly join with MAGO_MONTH_ID column for Month Ago measures.
3.Pull the ALIAS tables as an additional Logical table source in the Lgical layer
4.Keep the mapping of the columns from the ALIAS table as its is
5. For e.g If you pick Revenue from the Year Ago Alias table it will give you the "Prior Year Revenue"
See if this helps you
Maybe you are looking for
-
Can't download U2 album (this computer is already associated with an Apple ID)
Title pretty much sums it up. I can see the recently released, free-of-charge U2 album in my purchases, but when I click on the cloud icon I get the message that "This computer is already associated with an Apple ID" which is not at all revealing of
-
IPod icon not available in iTunes and Desktop
Okay gang here's one for you. While working on my Mac G4, I had ejected my iPod icon as I was getting ready to shut down for the day. Next day after downloading music from iTunes I suddenly noticed I no longer had the iPod icon on iTunes or my deskto
-
I got chagred 1 USD while created AppleID .. Why ??.. I am worry about the security ... is this safe ..or should I raise this issue to my credit card bank ??
-
MX04 - nuked my "doctypes" with PHPBB mod
Hi, I followed some directions on PHPBB to help get DWMX to recognise PHPBB's "TPL" doc types. http://www.phpbb.com/kb/article.php?article_id=110 Unfortunately, after I added the suggested code to the 3 files (extensions.txt, documenttypes.xml, MMDoc
-
IDOC bundling number of idocs in one message
Hi I am using IDOC bundling where I have one message with around 33,000 idocs inbound to PI. Can i break the number of idocs per message so that I can have 5,000 idocs in each message. Is there a paremeter that needs to be changed create a recordset