Why oracle function return 4000 characters ?
Dear All
When I write any function to get some return value in a query, its width is set to 4000. Moreover, when i write the same query to create any LOV, it gives an error that record group field cannot be greater than 2000. Where the actual width of this field is 200 characters.
Why function always returns 4000 characters?
Regards
Edited by: OraLearner on Dec 1, 2010 11:47 AM
Because the maximum of a varchar2 in SQL is 4000 and you have no dimension in your function:
SQL> r
1 create or replace function myfunc(inMaxVal in number) return varchar2 is
2 vRet varchar2(32000);
3 begin
4 for i in 1..inMaxVal loop
5 vRet := vRet || '1';
6 end loop;
7 return vRet;
8* end;
Function created.
SQL> select myfunc(4001) from dual;
select myfunc(4001) from dual
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at "SCOTT.MYFUNC", line 7
SQL> select myfunc(4000) from dual;
MYFUNC(4000)
1111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111so the SQL Engine have to assume your function returns 4000 bytes. If you use this function in PL/SQL it can be up to 32767 bytes:
SQL> r
1 begin
2 dbms_output.put_line(substr(myfunc(4002), 1,255));
3* end;
11111111111111111111111111111111111111111111111111111111
PL/SQL procedure successfully completed.cheers
Similar Messages
-
Can oracle function return more than one value
Hi All
please answer can oracle function return more than one value
need one schenario
regardsCan any function, irrespective of the language, return multiple values?
OF COURSE NOT!!
So why do you think Oracle will now suddenly do it differently than all other languages? Never mind that it is impossible for a function (a unit/module of code) returning a memory address, to return multiple memory addresses. The machine code that does that, has not been yet been designed/implemented.
I am continually amazed that this question is asked. It is about something so fundamental in almost every single 3rd and 4th generation language... something that is taught right at the start... the definition of what a procedure and what a function is.
Sorry, but I simply cannot pull punches on this subject and smooth it over. There is something fundamentally wrong with your training as a programmer if you have to ask such a question about a function.
And whatever programming skills you build on such a foundation, will be seriously lacking.
I kindly suggest that you get back to the very basics of programming - and review and revisit until you fully understand it. There are no shortcuts in becomming a good programmer.
Message was edited by:
Billy Verreynne -
Why OCIEnvCreate function return -1
Hello,everyone. Now I use VS C++ 2005 (with sp1)and OCI that in ORACLE 10g to develop a application.
calling OCIEnvCreate failed when connect the Database. The return value is -1. My Pataner saied, I cannot use OCIErrorGet() to get the error informaintion,becase The Environment isnot initialed.
But I can connect Database by using ORACLE 10g Client in my mathine(Input the same username and password).
Why OCIEnvCreate function return -1?VC++ 2005 has some known incompatible issues with 10g DLLs. Either downgrade the oracle client or upgrade the VC++ version and try. Hope $ORACLE_HOME env are set in your system.
-
Toplink JPA Calling Oracle Function Return sys_refcursor
I have a function which return sys_refcursor and I am trying to call this using JPA(1.0)
@NamedNativeQuery( name = "getEmpsByDeptId"
, query = "{ ? = call my_pck.getEmployees(:longName)}"
, resultClass = Employee.class
, hints = { @QueryHint(name = "org.hibernate.callable", value = "true")
, @QueryHint(name = "org.hibernate.readOnly", value = "true")
DAOImpl
query = getEntityManager().createNamedQuery("getEmpsByDeptId");
query.setParameter("longName", "SCOTT");
list = (List<Employee>)query.getResultList();
However when I execute, I am getting the following exception
Exception [TOPLINK-6132] (Oracle TopLink Essentials - 2.1 (Build b52-fcs (09/24/2008))):
oracle.toplink.essentials.exceptions.QueryException Exception Description:
Query argument 2 not found in list of parameters provided during query execution.
Query: ReadAllQuery(test.entity.Employee) at oracle.toplink.essentials.exceptions.QueryException.namedArgumentNotFoundInQueryParameters
I have tried using
call my_pck.getEmployees(?)}"
and
query.setParameter(1, "SCOTT");
However error remains the same and how can I resolve this issue?
I have used the same function with Hibernate using JPA2.0 and it has worked.
Thanklecaro wrote:
OK. But obviously there is some oracle object that one can call via an Access pass-through query which returns rows?Just to clarify. You could fetch data in Access from an Oracle function that returns a ref cursor using VBA editor. To use a pass-through query Oracle function should be a table function or pipelined table function:
CREATE OR REPLACE
TYPE testvalues_obj_type
AS OBJECT(
val varchar2(10),
isnum number
CREATE OR REPLACE
TYPE testvalues_tbl_type
AS TABLE OF testvalues_obj_type
CREATE OR REPLACE
FUNCTION fn_testvalues
RETURN testvalues_tbl_type
PIPELINED
IS
CURSOR testvalues_cur
IS
SELECT testvalues_obj_type(MyValue,fn_isnum(MyValue)) testvalues_obj
FROM t_values;
BEGIN
FOR v_rec IN testvalues_cur LOOP
PIPE ROW(v_rec.testvalues_obj);
END LOOP;
RETURN;
END;
/To test it in Oracle:
SELECT *
FROM TABLE(fn_testvalues)
VAL ISNUM
Merced 0
Pixie 0
452 1
SQL> Now in Access pass-trough query window enter:
SELECT *
FROM TABLE(fn_testvalues);SY. -
Oracle Function returns a Ref Cursor to a ResultSet object - Performance
My program calls an Oracle PL/SQL function which returns a ref cursor to a ResultSet object. I know that the function runs to completion relatively quickly when i run it in an anonymous block but when the call is made through my Java application the resultset takes about 30 mins to return. Below is a snippet of my code:
currentConnection = ConnectionManager.getInstance().getConnection();
reportStmt = currentConnection.prepareCall("BEGIN ? := ENVISION.PKG_WMS_TO_AP.F_REPORT_CI_SC_HOLDING(?,?); END;"); reportStmt.registerOutParameter(1, OracleTypes.CURSOR);
reportStmt.setString(2, invoice.getCrewHQ());
reportStmt.setDate(3, invoice.getWrCompletionDate());
reportStmt.execute();
reportRS = ((OracleCallableStatement) reportStmt).getCursor(1);
Through a debugger I see that the second last statement (reportStmt.execute()) runs quickly. It is only when I step into the last statement that the debugger takes up to 30 minutes.
Any thoughts?Flynn,
The Internet is a dynamic place. After nearly two and a half years, there is a chance that a link will change. This is the new URL for the relevant Web page:
http://asktom.oracle.com/~tkyte/ResultSets/
Good Luck,
Avi. -
Why getScale() function returns 0 ?
Hi,
I have a query which selects sum(amount) .
If i call rs.getDouble("sum") , it returns me proper double value
as 2000.50.
But the following code gives only Long value as 2000
ResultSetMetaData rsmd = rs.getMetaData();
if (rsmd.getScale(1) == 0)
double value = rs.getLong("sum");
else
long value = rs.getLong("sum");
Can anybody tell me why getScale() returns 0 ?
Is there any other way to find out whether value is double or long?
thanx in advance,
SulabhaThis sounds to me, firstly, as a Driver implementation
issue. I would check the documentation of the driver
first.
Also, there is ResultSetMetaData.getPrecision() method
which may be implmented to let you know how the number
is structured.
I tried with getScale() and getPrecision() methods both.
They work properly for any field of datatype NUMBER but if i use Group function like SUM() , then they return Zero.
Can this be a driver problem?
public static int getScale(ResultSet rs, String
field)
int scale = 0;
String temp = rs.getString(field);
if(temp.indexOf(".") != -1)
scale = temp.substring(temp.indexOf(".")).length();
return scale;
}Yes....this will work definitely.
Thanks,
Sualbha -
Why this function returns 3 and not assign a number?
Hi all,
call function 'NUMBER_GET_NEXT'
exporting
nr_range_nr = '01'
object = 'ZSBMDNUM'
importing
number = ZMM_TR_STR-dosyano
exceptions
interval_not_found = 1
number_range_not_intern = 2
object_not_found = 3
quantity_is_0 = 4
quantity_is_not_1 = 5
interval_overflow = 6
others = 7.
Thanks.Hi,
follow the below procedure for auto number generation.
From SNRO create a custom no. range object. When creating it specify
Short, long text,Number length domain (Ex: NUM5) and Warning % (Ex:
10.0.).
After creating it maintain the intervals by clicking the button
Number Ranges from the 1st screen and in the next screen press
change intervals and then maintain the intervals (From number, To
number, Current no etc.).
Now u can use this no. range object with the FMs, those I mentioned
in my earlier reply.
You can maitain a number range object from tran. SNRO and can
fetch
the next available no. using the FM 'NUMBER_GET_NEXT'.
Also check the FMs below for further operations on number range.
'NUMBER_RANGE_OBJECT_READ',
'NUMBER_RANGE_INTERVAL_LIST'
'NUMBER_RANGE_OBJECT_LIST'
'NUMBER_RANGE_OBJECT_GET_INFO'
Reward if useful,
Thanks,
Sreeram. -
How can I make Function return varchar2 more than 4000
I have a function
FUNCTION testing (v_pk_application in number, v_inccharges in char)
return varchar2(30000)
--return number
is
v_net_sum varchar2(30000);
v_net_sum2 varchar2(30000);
v_datarow varchar2(3000);
v_datarow2 varchar2(3000);
begin
return v_net_sum;
end;
I want to return varchar2 more than 4000, how can I do that.
Thanksuser10659388 wrote:
I want to return varchar2 more than 4000, how can I do that.A function can return a string up to the maximum allowed for varchar2.
Varchar2 can be up to 32767 characters...
SQL> create or replace function ret_str return varchar2 is
2 v_str varchar2(32767);
3 begin
4 v_str := lpad('*',32767,'*');
5 return v_str;
6 end;
7 /
Function created.
SQL> declare
2 v_retstr varchar2(32767);
3 begin
4 v_retstr := ret_str();
5 end;
6 /
PL/SQL procedure successfully completed.However, SQL only supports varchar2 up to 4000 characters so the same function will cause SQL to error, even though the function is perfectly valid.
SQL> select ret_str() from dual;
select ret_str() from dual
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at "SCOTT.RET_STR", line 5
SQL>So, if you intend to use the function only in PL/SQL then you can use varchar2 up to 32767 characters, but if you intend to use it in SQL then you will be limited to returning 4000 characters. Alternatively you can return a CLOB which SQL supports but they are a little more tricky to work with than varchar2...
SQL> ed
Wrote file afiedt.buf
1 create or replace function ret_str return clob is
2 v_str clob;
3 begin
4 v_str := lpad('*',32767,'*');
5 return v_str;
6* end;
SQL> /
Function created.
SQL> select ret_str() from dual;
RET_STR()
SQL> -
Retrieve a single row from Oracle function
Hi!
I have an Oracle function created as follow:
CREATE OR REPLACE FUNCTION user_data(userId IN users.user_id%TYPE)
RETURN users%ROWTYPE AS
userData users%ROWTYPE;
BEGIN
SELECT * INTO userData
FROM users
WHERE user_id = userId;
RETURN userData;
END user_data;
This function returns a single row from 'users' table.
I tried to retrieve that single row by mean of:
CallableStatement statement = connection
prepareCall("{ call ? := get_data(?) }");
statement.*registerOutParameter(1, OracleTypes.OTHER)*;
statement.setInt(2, 103);
statement.execute();
ResultSet rs = (ResultSet) statement.getObject(1);*
String value = rs.getString(2);
System.out.println(value);
But this code doesn't work.
I tried other OracleTypes, also. (I don't know what OracleType I receive when the Oracle function return a ROWTYPE.)
Can somebody tell me how to retrieve that single row?
What is the type of out parameter (registerOutParameter()) when the Oracle function return a ROWTYPE?
Notes: No cursor can be added. No database change is allowed.
Thank you in advance.
[Adrián E. Córdoba]
Edited by: aecordoba on Mar 18, 2011 3:58 PMaecordoba wrote:
I beg your pardon for my bad English. (It isn't my original language.)
It's not a language problem. It's that you didn't provide any details about what went wrong.
That just is my problem:
I know the retrieved result is not a result set: It's a single row.Doesn't matter if it's a single row. You have a ResultSet object. You have to call ResultSet's next() method to get to the first row, even if it's the only row.
1- Which is the Oracle type I receive in Java when the Oracle function returns a ROWTYPE?I don't know.
2- How can I get each column value when I receive a single row in Java?The same way as when there are multiple rows: For each row, call ResultSet.next() to advance to the next row, then call the appropriate ResultSet.getXxx() methods to get each column's value. Again: If you have a ResultSet, you must call next() to get to the first row, even if there is only one row. "First row out of 1 total row" is no different than "first row out of 100 total rows."
EDIT: Okay, I didn't notice before that you're using a CallableStatement with "out" parameters. I've never used one of those before, so I'm not familiar with the details. I really don't know if casting to a ResultSet is appropriate here. Do you actually have documentation that says you can do that, or are you just guessing and trying to find something that works.
Edited by: jverd on Mar 18, 2011 11:26 AM -
How to return less than 4000 characters from pl/sql function in SQL call?
Hello,
Is there a way to limit length for varchar when calling pl/sql function from SQL? No matter how I write it it always returns 4000 bytes.
If there is none, then does it make sense ever to specify lenght of the return variable?
My goal is to encapsulate business rules within pl/sql functions. But if all varchar columns are returned as 4000 it is not feasible solution. Not only this is a performance issue in a data warehousing environment, bet when using those rules within SQL views user experiance would suffer as well. Are we left with the rule hardcoding solution? Also, I think that using SUBSTRING or TRUNC functions on top of business rules function defeats the purpose.
Please see my attempt below. Your thoughts are appreciated.
Thank you.
/* Formatted on 06/11/2009 2:26:41 PM (QP5 v5.126.903.23003) */
CREATE OR REPLACE FUNCTION mytest (myvar_in VARCHAR2)
RETURN VARCHAR2
AS
l_return VARCHAR2 (15);
BEGIN
l_return := 'TEST_' || myvar_in;
RETURN l_return;
END mytest;
CREATE TABLE TEST_ME
AS
SELECT mytest ('ME') AS VERYLONG FROM DUAL;
describe TEST_ME;
RUN ABOVE CODE:
Function created.
Table created.
TABLE TEST_ME
Name Null? Type
VERYLONG VARCHAR2(4000)
Edited by: Ilmars2 on Jun 11, 2009 2:46 PMPointless,
Thanks for jumping in on this and I am glad you asked :).
I do not doubt that it is an architectural challenge. Otherwise it would have been done already! I am struggling with the fact that SQL knows what data type the function will return, but does not know the length of it, precision or scale. I will leave it at that.
I will go with some high level requirements to allow for alternative thoughts:
1) Business defined rules. There are multiple types of business rules. Simple lookups, bucketing, complex calculations, data retrieved from other tables etc. We have about 500 different rules. Some of them are even overloaded – different inputs will produce the same output.
Some simple examples are:
Rule1 - Fruit
when ‘A’ then ‘Apple’
When ‘O’ then ‘Orange’
Else ‘N/A’ end
Rule2 – Bonus
when STATUS =’Active’ and LEVEL=’CEO’ then bonus=salary*1.0
when STATUS =’Active’ and LEVEL=’nobody’ then bonus=salary*0.01
else bonus=0
Rule 3 – Income Bracket
When more than 0 and less or equal to 30000 then INC_B=’LOW’
When more than 30000 and less of equal to 60000 then INC_B=’MIDDLE’
Etc.
2) Challenge: All data users in an organization need to use the same rules (let’s assume data source is Oracle database). How to expose all the rules to different types of users in manageable way? Types of users – analysts, application/web developers, data warehouse teams etc.
3) Current system: Not only each user has coded their own rules (luckily based on the common specification), but hard-coding is taking place for each query within the confines of one project. The project I just looked at had about 12 modules with 30 hardcoded queries. Oops! Few rules just changed.
My take: I was leaning toward encapsulating business logic within UDF’s. UDF’s provide all the flexibility we need + overloading. All the functions could be consumed by data warehouse team (building summary tables, cubes etc.) and application developers. For power users we could build views by applying the same functions on top of the source data. Thus avoid data duplication. It seemed win-win until this 4000 issue :).
Your thoughts on alternative approaches are appreciated.
Thank you. -
How can a function returning character length greater than 4000 be selected in SQL
Hi,
I want to know if there is a way to write a select query on a function call which returns a varchar of more than 4000 characters.
CREATE OR REPLACE FUNCTION FUNC1
RETURN VARCHAR2
IS
str VARCHAR2(32767);
BEGIN
str := <some string greater than 4000 char>;
RETURN str;
END;
SELECT FUNC1 from dual; ---- This gives an PL/SQL numeric or value error. Character string buffer too small.
Is there any way to resolve this?
Thanks32767 is not default. The default is still 4000 for VARCHAR2. You need to set the initialization parameter MAX_STRING_SIZE= EXTENDED for 32767.
Text from Oracle documentation
Extended Data Types
Beginning with Oracle Database 12c, you can specify a maximum size of 32767 bytes for the VARCHAR2, NVARCHAR2, and RAW data types. You can control whether your database supports this new maximum size by setting the initialization parameter MAX_STRING_SIZE as follows:
If MAX_STRING_SIZE = STANDARD, then the size limits for releases prior to Oracle Database 12c apply: 4000 bytes for the VARCHAR2 and NVARCHAR2 data types, and 2000 bytes for the RAW data type. This is the default.
If MAX_STRING_SIZE = EXTENDED, then the size limit is 32767 bytes for the VARCHAR2, NVARCHAR2, and RAW data types. -
Oracle 11g Table function returns no records on first call
Hello,
On a Oracle 11g R2 I've a table function ( PIPELINED ) returning rows selected from a table.
The first time the function is selected, in a session ( I've tried to disconnect and log in again ), it returns no rows.
I've tried to log the call using DBMS_OUTPUT and from what I see the select on the table function returns no rows and no output is printed. So I presume Oracle is not calling the function.
The same function on a similar environment ( same db versions, patches and database structure ) works fine. The second environment is a production environment so it has more memory and some other settings enabled.
Does anyone know of settings that can relate to this behaviour ?
Thanks in advance for the help.
Regards,
Stefano MuretThank you for answering so fast.
Here's the function code:
FUNCTION template_parameters (iTemplate IN TEMPLATE_RAW_DATA.TMPL_ID%TYPE := NULL)
RETURN table_type_tmpl_parameters PIPELINED
IS
li_exception INTEGER DEFAULT -20025;
POUT_PARM TABLE_TYPE_TMPL_PARAMETERS;
lt_parms table_type_tmpl_parms_raw;
sParmCheck VARCHAR2(4000);
iOccurrence INTEGER;
BEGIN
pOut_Parm := table_type_tmpl_parameters();
pOut_Parm.EXTEND;
select
tmpl_id
*,tmpl_name*
*,replace(upper(trim(sql_out)),'[SCHEMA].')*
*,UPPER(TRIM(out_tmpl_parms))*
bulk collect into lt_parms
from ref_templates
where tmpl_id = NVL(iTemplate,tmpl_id)
order by tmpl_id;
FOR k IN 1..lt_parms.COUNT
LOOP
pOut_Parm(1).tmpl_id := lt_parms(k).tmpl_id;
pOut_Parm(1).tmpl_name := lt_parms(k).tmpl_name;
FOR i IN 1..2
LOOP
IF i = 1 THEN
sParmCheck := lt_parms(k).sql_out;
ELSE
sParmCheck := lt_parms(k).sql_parms;
END IF;
iOccurrence := 1;
*pOut_Parm(1).parameter_name := regexp_substr(sParmCheck,'\[[^\[]+\]',1,iOccurrence);*
WHILE pOut_Parm(1).parameter_name IS NOT NULL
LOOP
PIPE ROW (pOut_Parm(1));
iOccurrence := iOccurrence + 1;
*pOut_Parm(1).parameter_name := regexp_substr(sParmCheck,'\[[^\[]+\]',1,iOccurrence);*
END LOOP;
END LOOP;
END LOOP;
RETURN;
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR(li_exception,SUBSTR(SQLERRM,1,1000));
RETURN;
END template_parameters;
This function is part of a package.
The data on both environments is the same. -
I am using PL_SQL with Oracle8i and OAS 4.0 web server.I want to
use owa_text.vc_arr to pass the inputs in serval text areas in the form on a web application.
If the input string length is less than 4000 characters, everything works fine.However when the strings are longer than 4000 characters but less than the max length 32767 characters, I got this error message:
OWS-05101: Execution failed due to Oracle error 2005
ORA-02005: implicit (-1) length not valid for this bind or define datatype.
In the Oracle Application Server 4.0 documment, it says
about owa_text.vc_arr :Type vc_arr is table of varchar2(32767)
index by binary_integer. It means that owa_text.vc_arr can handle multiple strings and each string can have up to 32767 single byte characters, is it right?
Owa_text.vc_arr is supposed to handle the string with more
than 4000 characters, is it true? Could anyone tell me why? Any
help will be greatly appreciated!!!
Thanks very much.
Helena Wang
Here is the pl_sql procedure to create my form on the web:
PROCEDURE myform
IS
BEGIN
htp.p('
<form action="'||service_path||'helena_test.saveform3"
method=post>
<input type=hidden name=tdescription value="X">
Input1: <textarea name=tdescription rows=50 cols=70
WRAP=physical></textarea>
Input2: <textarea name=tdescription rows=50 cols=70
WRAP=physical></textarea>
<input type=submit name=WSave value="Save">
</form>
END;
/***** here is the pl_sql procedure which I use to save the
form***/
procedure saveform3(tdescription in owa_text.vc_arr,
WSave in varchar2 default 'No')
is
len pls_integer;
begin
for i in 2..tdescription.count loop
len := length(tdescription(i));
htp.p(len);
htp.p(tdescription(i));
end loop;
end;The maximum size of a VARCHAR2 field in Oracle 8i is 4000 bytes.
you'll ned to use a LOB type (or LONG if you prefer the old way) -
Oracle function and query return different results
Hi, I am using oracle 10g database.
Function is :
create or replace FUNCTION FUNC_FAAL(myCode number,firstDate date
*, secondDate date)*
RETURN INTEGER as
rtr integer;
BEGIN
select count() into rtr*
from myschema.my_table tbl where tbl.myDateColumn between firstDate and
secondDate and tbl.kkct is null and tbl.myNumberColumn = myCode ;
return (rtr);
END FUNC_FAAL;
This function returns 117177 as result.
But if I run same query in the function seperately ;
select count()*
from myschema.my_table tbl
where tbl.myDateColumn between firstDate and secondDate
and tbl.kkct is null and tbl.myNumberColumn = myCode ;
I get different result 11344 (which is the right one).
Table and function are in the same schema.
What can be the problem ?
Thanks.1. i think ur parameter name and Column names are same Firstdate and seconddate try to choose different name
2. try using Trunc function around your dates
where trunc(tbl.myDateColumn) between trunc(firstDate) and trunc(secondDate)then compare the result....sometimes time elements comes into play.
Baig
[My Oracle Blog|http://baigsorcl.blogspot.com/] -
Calling oracle function from Access passthrough query does not return list
Thanks to the help I received in an earlier post I've created an oracle 10g function that returns a list after executing the sql it contains. It works in oracle, using sql developer.
I need to have the list that it returns show up in MS Access via a passthrough query. It's not working so far. The connection string etc is ok, I'm able to use passthrough queries to run sql strings successfully. But when I try to call the function via the Access passthrough query at first nothing seems to happen (ie no list appears) and if I try to run it again, there is a odbc error 'call in progress. Current operation canceled'. There are only the three records in the table. I'm missing something, can anyone spot it?
The passthrough query looks like this
select * from fn_testvalues from dual
Again that runs in oracle.
To create the testing table and 2 functions see below.
CREATE TABLE t_values (MyValue varchar2(10));
Table created
INSERT INTO t_values (
SELECT 'Merced' c1 FROM dual UNION ALL
SELECT 'Pixie' FROM dual UNION ALL
SELECT '452' FROM dual);
3 rows inserted
CREATE OR REPLACE FUNCTION fn_isnum(p_val VARCHAR2) RETURN NUMBER IS
n_val NUMBER;
BEGIN
n_val := to_number(p_val);
RETURN 1;
EXCEPTION
WHEN OTHERS THEN
RETURN 0;
END;
Function created
testing the table:
SELECT val, fn_isnum(MyValue ) isnum
FROM t_values;
VAL ISNUM
Merced 0
Pixie 0
452 1
Now the function that is called in the passthrough query:
create or replace function fn_testvalues
return sys_refcursor is
rc sys_refcursor;
begin
open rc for
Select t_values.*, fn_isnum(MyValue) IsNum from t_values;
return(rc);
end fn_testvalues;lecaro wrote:
OK. But obviously there is some oracle object that one can call via an Access pass-through query which returns rows?Just to clarify. You could fetch data in Access from an Oracle function that returns a ref cursor using VBA editor. To use a pass-through query Oracle function should be a table function or pipelined table function:
CREATE OR REPLACE
TYPE testvalues_obj_type
AS OBJECT(
val varchar2(10),
isnum number
CREATE OR REPLACE
TYPE testvalues_tbl_type
AS TABLE OF testvalues_obj_type
CREATE OR REPLACE
FUNCTION fn_testvalues
RETURN testvalues_tbl_type
PIPELINED
IS
CURSOR testvalues_cur
IS
SELECT testvalues_obj_type(MyValue,fn_isnum(MyValue)) testvalues_obj
FROM t_values;
BEGIN
FOR v_rec IN testvalues_cur LOOP
PIPE ROW(v_rec.testvalues_obj);
END LOOP;
RETURN;
END;
/To test it in Oracle:
SELECT *
FROM TABLE(fn_testvalues)
VAL ISNUM
Merced 0
Pixie 0
452 1
SQL> Now in Access pass-trough query window enter:
SELECT *
FROM TABLE(fn_testvalues);SY.
Maybe you are looking for
-
I've recently been given a PowerMac G5 and as soon as I turn it on, the fans spin for a couple seconds and then it shuts off...Any idea at whats going on with it?
-
How can I get a stripped screw out of the bottom of my iPhone?? I need help, How can I get a stripped screw out of the bottom of my iPhone?? I need help
-
I want to insert HOSTID that has unique values in a new application in a primary key column in database. I am starting with h000000001 and I want to go from that to h000000002 and .... h0000000010 , 11, 12 etc etc. How do I do this? I did this: rs =
-
Notebook won't start after BIOS upgrade
Notebook: HP Pavilion dv6-7003 OS: Windows 7 32-bit An HP update thing just came up telling me to update, so I did, after they were all downloaded/installed I restarted and then it went to a special BIOS screen telling me what to do (not to turn of
-
How to pass parameter to DestinationURI of a link?
Hi All, I have a requirement to generate report by clicking of a link and the report should open in a separate window. I am facing problem with passing parameter to destinationURI of link. Using MessageChoice event I am getting parameter value in PFR