Partition cursor parameter
Hi expert,
I have a problem with a custom procedure
create or replace
PROCEDURE PRC_PARTITION
AS
STRFLUSSO VARCHAR2(50) := 'PRC_PARTITION';
STRERR VARCHAR2(255);
V_PARTITION VARCHAR2(255);
V_PARTITION_TRANSACTION VARCHAR2(255);
CURSOR V_CUR (V_PARTITION_CUR VARCHAR2)
IS
SELECT NAME FROM CITY PARTITION (V_PARTITION_CUR);
BEGIN
SELECT max(partition_name) into V_PARTITION FROM user_tab_partitions WHERE table_name = 'CITY';
DBMS_OUTPUT.Put_Line (V_PARTITION);
FOR I IN V_CUR(V_PARTITION)
LOOP
EXIT WHEN V_CUR%NOTFOUND;
DBMS_OUTPUT.Put_Line (I.NAME);
END LOOP;
EXCEPTION
WHEN OTHERS THEN
STRERR := SUBSTR (SQLERRM, 1, 254);
dbms_output.put_line('Errore:'||STRERR);
rollback;
END PRC_CARING_TRANSACTION;
Connecting to the database DBTEST.
SYS_P6209
Errore:ORA-02149: Specified partition does not exist
Process exited.
Disconnecting from the database DBTEST.But the partition SYS_P6209 exists and I can run this:
SELECT NAME FROM CITY PARTITION (SYS_P6209);.... what I wrong
cheers,
Lain
SELECT table_name,partition_name,high_value FROM user_tab_partitions WHERE table_name = 'CITY';
CITY SYS_P5969 TIMESTAMP' 2011-03-25 00:00:00'
CITY SYS_P6049 TIMESTAMP' 2011-04-01 00:00:00'
CITY SYS_P6209 TIMESTAMP' 2011-04-15 00:00:00'Current_date is the column partitioned:
SELECT * FROM CITY WHERE CURRENT_DATE ... ??thanks for all suggest.
Cheers,
Lain
Similar Messages
-
Cast error message when discovering ref cursor parameter from stored proced
We are today using Microsoft's Oracle provider with some code from the old Data Application Block (from MSDN) to discover parameters from the stored procedures. This code uses the OracleCommandBuilder.DeriveParameters to get the parameters from the stored procedure and command.Parameters.CopyTo copies the discovered parameters into the command object.
If I test with a simple function returning a ref cursor I get one parameter with type refCursor and ParameterDirection.OutPut. This is working fine as long we where using Microsoft's Oracle provider. But using Oracle ODP .NET I get the following error message on datadapter.Fill (I fill a dataset with the result from the reference cursor)
Unable to cast object of Type 'Oracle.DataAccess.Client.OracleDataReader' to type 'Oracle.DataAccess.Types.OracleRefCursor.
If I create a ref parameter manualy like this:
OracleParameter myrefCursor = new OracleParameter();
myrefCursor .OracleDbType = OracleDbType.RefCursor;
myrefCursor .ParameterName = "myParameterName";
myrefCursor .Direction = ParameterDirection.ReturnValue;
and add it to the command object this is working OK. So it seems to be a problem with discovering ref cursor parameters from the database, other parameter types is OK.. I have compared the properties of my manual ref cursor parameter with the one discovered from the stored procedure, but I cannot see any difference. (I see the Value property has some values for the discovered one, but I have set this to DBNull.Value without any result)
Any ideas why I get this error code? Is there any other code blocks I can use to discover the parameters? We send in params object[] with the different values into the helper class and the value is added to the parameter. (Se I don't need to set the data type etc for each parameter, I just need to have the correct order of the parameters)For accuracy's sake, just wanted to let everyone know that this is actually a bug. The correct bug number is 8423178.
Christian
Mark_Williams wrote:
Just to follow-up on this issue...
The bug has been closed as "not a bug" as it seems undocumented behavior was relied upon for this to work in earlier releases.
Note from the documentation on DeriveParameters:
"The output values of derived parameters return as .NET Types by default. To obtain output parameters as provider types, the OracleDbType property of the parameter must be set explicitly by the application to override this default behavior. One quick way to do this is to set the OracleDbType to itself for all output parameters that should be returned as provider types." (emphasis added)
The issue, as you might already know, is that there is no corresponding .NET Framework Type for an Oracle Ref Cursor and the type is, therefore, set to Object. So, explicitly setting the type to OracleDbType.RefCursor should work.
Regards,
Mark -
Hello,
I've been informed that it is possible to define a boolean cursor parameter in PL/SQL.
I tried, and it compiles:
cursor c_test(b_test boolean) is select 1 from dual;
Can somebody give me an example of the use of such a parameter?
thanks,
MarkoCan somebody give me an example of the use of such a parameter? I think it's just a PL/SQL curio. We can't use a BOOLEAN in SQL so we cannot use the parameter in the cursor's query.
Cheers, APC
Blog : http://radiofreetooting.blogspot.com/ -
Ora-01001 in procedures with ref cursor parameter after upgrade to 11.1.0.7
Hi,
after upgrading from 11.1.0.6.0 to 11.1.0.7.0, I get ora-01001 in procedure calls which have a ref cursor as an out parameter.
Even a new 11.1.0.7 instance throws this error. My OS is Linux SLES10SP2.
Please see atched sample code:
CREATE OR REPLACE PACKAGE test1_pck
IS
PROCEDURE run1; -- OK on 11.1.0.6; fails on 11.1.0.7
PROCEDURE run2; -- OK on 11.1.0.6; OK on 11.1.0.7
END test1_pck;
CREATE OR REPLACE PACKAGE BODY test1_pck
IS
TYPE t_rec IS RECORD(col dual.dummy%TYPE);
TYPE t_cur IS REF CURSOR RETURN t_rec;
PROCEDURE foo1(p_cur OUT t_cur)
IS
v_sql VARCHAR2(255) := 'BEGIN OPEN :1 FOR SELECT dummy FROM dual; END;';
BEGIN
EXECUTE IMMEDIATE v_sql USING p_cur;
END foo1;
PROCEDURE foo2
IS
v_sql VARCHAR2(255) := 'BEGIN OPEN :1 FOR SELECT dummy FROM dual; END;';
v_cur t_cur;
v_rec t_rec;
BEGIN
EXECUTE IMMEDIATE v_sql USING v_cur;
LOOP
FETCH v_cur INTO v_rec;
EXIT WHEN v_cur%NOTFOUND;
CASE v_rec.col
WHEN 'X' THEN dbms_output.put_line('success');
ELSE dbms_output.put_line('error');
END CASE;
END LOOP;
END foo2;
PROCEDURE run1
IS
v_cur t_cur;
v_rec t_rec;
BEGIN
foo1(v_cur);
LOOP
FETCH v_cur INTO v_rec;
EXIT WHEN v_cur%NOTFOUND;
CASE v_rec.col
WHEN 'X' THEN dbms_output.put_line('success');
ELSE dbms_output.put_line('error');
END CASE;
END LOOP;
END run1;
PROCEDURE run2
IS
BEGIN
foo2;
END run2;
END test1_pck;
Thanks for any hints.
Regards FrankHi Max,
the referenced thread discusses a .Net problem. A lot of layers are involved their. My problem is a very basic problem. You get this error even if you run the test in a sql session on the server.
It would be a great help for me
a) if someone could test this package on a 11.1.0.7 database
b) if someone could test this package on a 11.2 database (is it fixed in Release2?)
c) if someone could give me hints how I could modify the procedure to make it usable for 11.1.0.7
(I already tried a lot e.g. EXECUTE IMMEDIATE v_sql USING OUT p_cur;
Thank you
Frank -
Sort(Order by) a cursor by cursor parameter
Hello,
I want to make cursor to query three column data, and order by the paramter when calling store procedure. But the cursor did not order by column name at all.
Any help will be appreciated.
ggu.
My package/procedure:
CREATE OR REPLACE PACKAGE test_PKG AUTHID DEFINER
AS
TYPE REF_CUR IS REF CURSOR;
PROCEDURE test_proc(COLN IN VARCHAR2, OUTCUR OUT REF_CUR);
END test_PKG;
CREATE OR REPLACE PACKAGE BODY TEST_PKG
AS
PROCEDURE test_proc(COLN in varchar2, outcur out ref_cur) IS
BEGIN
IF NOT OUTCUR%ISOPEN
THEN
open OUTCUR FOR
SELECT CPS.PYROL_ID,
CPS.VEND_ID,
CPS.CONT_ID
FROM EPRS.CNTRCTR_PYROL_SUBMIT CPS
ORDER BY COLN; <------What should be here?
END IF;
end test_proc;
end test_pkg;
var results refcursor;
execute test_PKG.test_PROC('Vend_ID', :results);
print results;
It gave me results:
PYROL_ID VEND_ID CONT_ID
193 06883 009214070
196 11756 202101064
205 06507 072202046
206 06507 042202046
207 06507 032202046
208 06883 012202046I could make the question more clear;
I want to query a table, for example, with three columns. The query results should be sorted by one specific column. I want to leave the column to be ordered by as a parameter, how to implment it?
Thanks. -
Cursor-pasing multiple values as a cursor parameter
declare
credit_amount number:=0;
debit_amount number:=0;
v1 number:=0;
v2 number:=0;
v3 varchar2(500);
v4 varchar2(500);
v5 varchar2(240);
v6 varchar2(240);
v7 number;
v8 varchar2(240);
v9 varchar2(240);
v10 number;
v11 number;
v12 varchar2(240);
v13 varchar2(240);
v14 varchar2(240);
v15 number;
v16 number;
--This cursor is for liability records which are in GL not in AP
cursor c1(p_header_id number,p_reference_2 varchar2,p_reference_4 varchar2)
is
(select
jl.je_header_id "JE_HEADER_ID"
,jl.period_name "PERIOD"
,glcc.concatenated_segments "ACCOUNT_CODE"
,DECODE(jl.accounted_dr,null,0,jl.accounted_dr)"ACCOUNTED_DEBIT"
,DECODE(jl.accounted_cr,null,0,jl.accounted_cr) "ACCOUNTED_CREDIT"
,DECODE(jl.accounted_dr,null,0,jl.accounted_dr) - DECODE(jl.accounted_cr,null,0,jl.accounted_cr) "NET"
,glcc.CODE_COMBINATION_ID "CODE_COMBINATION_ID"
,jl.SET_OF_BOOKS_ID "SET_OF_BOOKS_ID"
,jl.PERIOD_NAME "PERIOD_NAME"
,DECODE(Jl.entered_dr,null,0,Jl.entered_dr)"ENTERED_DEBIT"
,DECODE(Jl.entered_cr,null,0,Jl.entered_cr) "ENTERED_CREDIT"
,jl.reference_1 "SUPPLIER"
,jl.reference_2 "INVOICE_ID"
,jl.reference_3 "CHECK_ID"
,jl.reference_4 "CHECK_NUMBER"
,jl.reference_5 "INVOICE_NUM"
,jl.reference_6 "'AP_PAYMT_JUST_INSERTED'"
,jl.reference_7 "set_of_books_id"
,jl.GL_SL_LINK_ID "GL_SL_LINK_ID"
,jl.REFERENCE_8 "INVOICE_DIST_LINE_NUMBER"
,jl.reference_9 "INVOICE_PAYMENT_ID"
,jl.REFERENCE_10 "LIABILITY"
,jl.TAX_CODE_ID "TAX_CODE_ID"
,jl.TAX_GROUP_ID "TAX_GROUP_ID"
FROM
gl_je_lines jl
, apps.gl_code_combinations_KFV glcc
, gl_je_headers jh
WHERE
jl.period_name='Mar-10'
and glcc. code_combination_id in (1016,1296,1298)
and jh.je_header_id = jl.je_header_id
AND glcc.code_combination_id = jl.code_combination_id
and jh.je_source = 'Payables'
AND jl.je_header_id = p_header_id
and jl.reference_2 = p_reference_2
and jl.reference_4 = p_reference_4
MINUS
select
ir.je_header_id
, h.period_name "APPERIOD"
,g.CONCATENATED_SEGMENTS "AP ACCOUNT CODE"
,DECODE(l.accounted_dr,null,0,l.accounted_dr) "AP ACCOUNTED_DR"
,DECODE(l.accounted_cr,null,0,l.accounted_cr) "AP ACCOUNTED_CR"
,DECODE(l.accounted_dr,null,0,l.accounted_dr) - DECODE(l.accounted_cr,null,0,l.accounted_cr) "NET"
,l.CODE_COMBINATION_ID "AP_CCID"
,h.set_of_books_id
,h.PERIOD_NAME "PERIOD_NAME"
,DECODE(l.entered_dr,null,0,l.entered_dr)"ENTERED_DEBIT"
,DECODE(l.entered_cr,null,0,l.entered_cr) "ENTERED_CREDIT"
,l.reference1 "SUPPLIER"
,l.reference2 "INVOICE_Id"
,l.reference3 "reference_3"
,l.reference4 "reference_4"
,l.reference5 "INVOICE_NUM"
,l.reference6 "reference_6"
,l.reference7 "reference_7"
,l.GL_SL_LINK_ID "GL_SL_LINK_ID"
,l.REFERENCE8 "REFERENCE_8"
,l.reference9 "reference_9"
,l.REFERENCE10 "REFERENCE_10"
,l.TAX_CODE_ID "TAX_CODE_ID"
,l.TAX_LINK_ID "TAX_LINK_ID"
from
ap_ae_lines_all l,
ap_ae_headers_all h,
gl_code_combinations_kfv g
,gl_import_references ir
where
ir.gl_sl_link_id=l.gl_sl_link_id
AND g.CODE_COMBINATION_ID = l.CODE_COMBINATION_ID
and h.ae_header_id = l.ae_header_id
AND h.period_name ='Mar-10'
AND g.CODE_COMBINATION_ID in (1016,1296,1298)
AND ir.JE_HEADER_ID = p_header_id
and l.reference2 = p_reference_2
and l.reference4 = p_reference_4);
--This cursor is for writeoff records
cursor c2
is
(select * from gl_je_lines
where period_name='Mar-10'
and reference_10='WRITEOFF'
and reference_2 in ('525706','525600'));
credit number:=0;
debit number:=0;
j varchar2(240);
i varchar2(4000):='0';
cursor c3 (p_invoice_id varchar2)
is
(select
jl.je_header_id "JE_HEADER_ID"
,jl.period_name "PERIOD"
,glcc.concatenated_segments "ACCOUNT_CODE"
,DECODE(jl.accounted_dr,null,0,jl.accounted_dr)"ACCOUNTED_DEBIT"
,DECODE(jl.accounted_cr,null,0,jl.accounted_cr) "ACCOUNTED_CREDIT"
,DECODE(jl.accounted_dr,null,0,jl.accounted_dr) - DECODE(jl.accounted_cr,null,0,jl.accounted_cr) "NET"
,glcc.CODE_COMBINATION_ID "CODE_COMBINATION_ID"
,jl.SET_OF_BOOKS_ID "SET_OF_BOOKS_ID"
,jl.PERIOD_NAME "PERIOD_NAME"
,DECODE(Jl.entered_dr,null,0,Jl.entered_dr)"ENTERED_DEBIT"
,DECODE(Jl.entered_cr,null,0,Jl.entered_cr) "ENTERED_CREDIT"
,jl.reference_1 "SUPPLIER"
,jl.reference_2 "INVOICE_ID"
,jl.reference_3 "CHECK_ID"
,jl.reference_4 "CHECK_NUMBER"
,jl.reference_5 "INVOICE_NUM"
,jl.reference_6 "'AP_PAYMT_JUST_INSERTED'"
,jl.reference_7 "set_of_books_id"
,jl.GL_SL_LINK_ID "GL_SL_LINK_ID"
,jl.REFERENCE_8 "INVOICE_DIST_LINE_NUMBER"
,jl.reference_9 "INVOICE_PAYMENT_ID"
,jl.REFERENCE_10 "LIABILITY"
,jl.TAX_CODE_ID "TAX_CODE_ID"
,jl.TAX_GROUP_ID "TAX_GROUP_ID"
FROM
gl_je_lines jl
, apps.gl_code_combinations_KFV glcc
, gl_je_headers jh
WHERE
jl.period_name='Mar-10'
and glcc. code_combination_id in (1016,1296,1298)
and jh.je_header_id = jl.je_header_id
AND glcc.code_combination_id = jl.code_combination_id
and jh.je_source = 'Payables'
and jl.reference_2 in (p_invoice_id)
MINUS
select
ir.je_header_id
, h.period_name "AP PERIOD"
,g.CONCATENATED_SEGMENTS "AP ACCOUNT CODE"
,DECODE(l.accounted_dr,null,0,l.accounted_dr) "AP ACCOUNTED_DR"
,DECODE(l.accounted_cr,null,0,l.accounted_cr) "AP ACCOUNTED_CR"
,DECODE(l.accounted_dr,null,0,l.accounted_dr) - DECODE(l.accounted_cr,null,0,l.accounted_cr) "NET"
,l.CODE_COMBINATION_ID "AP_CCID"
,h.set_of_books_id
,h.PERIOD_NAME "PERIOD_NAME"
,DECODE(l.entered_dr,null,0,l.entered_dr)"ENTERED_DEBIT"
,DECODE(l.entered_cr,null,0,l.entered_cr) "ENTERED_CREDIT"
,l.reference1 "SUPPLIER"
,l.reference2 "INVOICE_Id"
,l.reference3 "reference_3"
,l.reference4 "reference_4"
,l.reference5 "INVOICE_NUM"
,l.reference6 "reference_6"
,l.reference7 "reference_7"
,l.GL_SL_LINK_ID "GL_SL_LINK_ID"
,l.REFERENCE8 "REFERENCE_8"
,l.reference9 "reference_9"
,l.REFERENCE10 "REFERENCE_10"
,l.TAX_CODE_ID "TAX_CODE_ID"
,l.TAX_LINK_ID "TAX_LINK_ID"
from
ap_ae_lines_all l,
ap_ae_headers_all h,
gl_code_combinations_kfv g
,gl_import_references ir
where
ir.gl_sl_link_id=l.gl_sl_link_id
AND g.CODE_COMBINATION_ID = l.CODE_COMBINATION_ID
and h.ae_header_id = l.ae_header_id
AND h.period_name ='Mar-10'
AND g.CODE_COMBINATION_ID in (1016,1296,1298)
and l.reference2 in (p_invoice_id)); --here if i put l.reference2 in (p_invoice_id)) it must show the details of
-- of all.but it doesnot display sir
--here if i put l.reference2 not in (p_invoice_id)) it shows that id also sir
BEGIN
for writeoff_rec in c2
LOOP
FOR Main_cur in c1(writeoff_rec.je_header_id,writeoff_rec.reference_2,writeoff_rec.reference_4)
LOOP
j:='0';
IF writeoff_rec.accounted_dr is not null AND Main_cur.ACCOUNTED_CREDIT<>0
THEN
v10:=Main_cur.ACCOUNTED_CREDIT;
credit_amount:= credit_amount+Main_cur.ACCOUNTED_CREDIT;
ELSIF writeoff_rec.accounted_cr is not null AND Main_cur.ACCOUNTED_DEBIT<>0
THEN
v11:=Main_cur.ACCOUNTED_DEBIT;
debit_amount:= debit_amount+Main_cur.ACCOUNTED_DEBIT;
END IF;
if c1%found then
j:=Main_cur.INVOICE_ID;
end if;
END LOOP;
-- i:=i||','||j;
i:= i||','''||j||'''';
END LOOP;
dbms_output.put_line(i); --Here i got all invoiceids of varchar2 records without single qutations
--its look like '0','23232','2324234' etc.
for cash_clearing_cur in c3(i)--Here is the problem ..is it correct way here i am passing parameter to cursor
loop
v3:=0;
v4:=0;
v5:=0;
v6:=0;
v7:=0;
v8:=0;
v9:=0;
v10:=0;
v11:=0;
v12:=0;
v13:=0;
v14:=0;
v15:=0;
v16:=0;
credit:=credit+cash_clearing_cur.ACCOUNTED_CREDIT;
debit:=debit+cash_clearing_cur.ACCOUNTED_DEBIT;
v3:=cash_clearing_cur.JE_HEADER_ID;
v4:=cash_clearing_cur.INVOICE_ID;
v5:=cash_clearing_cur.CHECK_NUMBER;
v6:=cash_clearing_cur.LIABILITY;
v7:=cash_clearing_cur.CODE_COMBINATION_ID;
v8:=cash_clearing_cur.PERIOD;
v9:=cash_clearing_cur.ACCOUNT_CODE;
v10:=cash_clearing_cur.ACCOUNTED_CREDIT;
v11:=cash_clearing_cur.ACCOUNTED_DEBIT;
v12:=cash_clearing_cur.SUPPLIER;
v13:=cash_clearing_cur.CHECK_ID;
v14:=cash_clearing_cur.INVOICE_NUM;
v15:=cash_clearing_cur.GL_SL_LINK_ID;
v16:=cash_clearing_cur.SET_OF_BOOKS_ID;
DBMS_OUTPUT.PUT_LINE('HEAd '||v3||','||'inv_id '||v4||','||
'chk_num '||v5||','||'ref10 '||v6||','||'CCID '||V7||','||'PED '||V8
||','||'acctcode '||v9||','||'acct_Ct '||V10
||','||'acct_Dt '||v11||','||'chk_id '||v13||','||'inv_num '||V14
||','||'link '||v15||','||'sob '||v16||','||'suplir '||V12);
end loop;
DBMS_OUTPUT.PUT_LINE( 'Dr Amt ' ||debit || 'Cr amt ' || credit );
EXCEPTION
when too_many_rows then
dbms_output.put_line('Invalid no of rows');
when no_data_found then
dbms_output.put_line('no data found exception');
when others then
dbms_output.put_line('Other than Invalid no of rows');
dbms_output.put_line(SQLERRM);
END;
ouutput was
0,0 that means cursor c3 is not compiled because i am passing multiple values in parametr .is there any solutionWhats wrong with your previous thread passing variable which has multiple values to cursor as parameter
Opening a new thread doesn't mean that you will get more responses. Did you carefully studied the hints given by Justin Cave ? I guess no, because you ignored the first point itself to format your code with tag. -
Hi,
recently I found out that a cursor must not have explicit a defined parameter list:
1. Option
cursor cur_example
is
select name
from table1
where name = p_name
=> instead of
2. Option
cursor cur_example (p_name IN VARCHAR2)
is
select name
from table1
where name = p_name
why is then sometimes a parameterlist definition necessary?
cheers,
Bernhard> my problem is to understand if a parameter list must not necessarily be defined? But if it is defined it seems that it is only for readability reasons!!!!!????
True. In programming generally we often have the choice of whether to pass a parameter or have the code refer to a global variable, and passing the parameter is nearly always better practice because it makes the dependency explicit and therefore easier to understand. For example, this sort of scenario is ambiguous without cursor parameters:
DECLARE
v_somevar VARCHAR2(1) := 'X';
v_count INTEGER;
CURSOR c IS
SELECT COUNT(*) FROM dual WHERE dummy = v_somevar;
BEGIN
v_somevar := 'Y';
OPEN c;
FETCH c INTO v_count;
CLOSE c;
DBMS_OUTPUT.PUT_LINE('Count = ' || v_count);
END;I would always prefer the equivalent,
DECLARE
v_somevar VARCHAR2(1) := 'X';
v_count INTEGER;
CURSOR c ( cp_someval dual.dummy%TYPE ) IS
SELECT COUNT(*) FROM dual WHERE dummy = cp_someval;
BEGIN
v_somevar := 'Y';
OPEN c (v_somevar);
FETCH c INTO v_count;
CLOSE c;
DBMS_OUTPUT.PUT_LINE('Count = ' || v_count);
END; -
REF CURSOR as IN parameter to stored procedure
Currently, ODP.NET supports REF CURSOR parameter as OUT parameter only.
Based on the project requirements it is necessary to pass
multiple records to the stored procedure.
In this case REF CURSOR as IN parameter is useful.
What are the plans to implement REF CURSOR as IN parameter to stored procedure?
What is the work around in case it is necessary to pass several different
record types as arrays to stored procedure?ODP.NET does not limit REF Cursor parameters to IN parameters. This is a known PL/SQL limitation.
An excerpt from Application Developer's Guide:
"If you pass a host cursor variable to PL/SQL, you cannot fetch from it on the server side unless you also open it there on the same server call". -
Hi
I am trying to partition a table for performance improvement. I have used 742243 as a reference which is described below.
I have followed the proceedure and created the partitions. But that is not visible in oracle. Could anyone let me know how to approach the problem.
Many thanks for you help
Deb Sircar
Using the database utility (transaction SE14), you can partition a table defined in the DDIC with the RANGE, LIST or HASH methods.
Since the use of transaction SE14 is not obvious, we will explain the partitioning of a table with an example.
Enter the table to be partitioned in transaction SE14, choose "Edit" and choose the "Storage parameter" pushbutton in the subsequent screen.
In the next menu, choose the "For new creation" pushbutton.
Place the cursor on "Table" and choose "Create parameter values" (second button) in the application toolbar.
You can select a template for the parameter values, for example, "Current Database Parameters".
The subsequent screen is similar to the following:
INDEX ORGANIZED
TABLESPACE
INITIAL EXTENT 16
NEXT EXTENT 160
MINIMUM EXTENTS 1
MAXIMUM EXTENTS 300
PCT INCREASE 0
FREELISTS 1
FREELIST GROUPS 1
PCT FREE 10
PCT USED 40
PARTITION BY
You can select the partitioning method in the "PARTITION BY" parameter with the input help.
Depending on the type you select, more parameters will be displayed, for example, the "COLUMN LIST" parameter for RANGE, and "HIGH VALUE" for the displayed partition.
INDEX ORGANIZED
TABLESPACE
INITIAL EXTENT 16
NEXT EXTENT 160
MINIMUM EXTENTS 1
MAXIMUM EXTENTS 300
PCT INCREASE 0
FREELISTS 1
FREELIST GROUPS 1
PCT FREE 10
PCT USED 40
PARTITION BY RANGE
COLUMN LIST
PARTITION
PARTITION NAME
HIGH VALUE
TABLESPACE
INITIAL EXTENT
For each parameter, you can enter one or multiple values. The values are case-sensitive and must be entered depending on the data type (if necessary, enclose them in single quotes (')).
To obtain another entry for a parameter, for example, for PARTITION or HIGH VALUE, you must place the cursor on the parameter and choose "Insert parameter values" (fourth button) in the application toolbar. .......
PCT FREE 10
PCT USED 40
PARTITION BY RANGE
COLUMN LIST
PARTITION
PARTITION NAME
HIGH VALUE
HIGH VALUE
TABLESPACE
INITIAL EXTENT
PARTITION
PARTITION NAME
HIGH VALUE
HIGH VALUE
TABLESPACE
INITIAL EXTENT
If you enter several values for a parameter, the entries must follow the right syntax; for example, if you want to enter three field names in the "COLUMN LIST" parameter, the entry must look as follows:
COLUMN LIST "COL1", "COL2", "COL3"
After you have populated and saved the parameter values, you can create the required table with transaction SE14 in the database by choosing the "Activate and adjust database" pushbutton.
Partitioning of an index is only supported in line with the partitioning of the table (local index). You can specify this option by populating the "PARTITIONED" parameter:
PARTITIONED X
Header Data
Release Status: Released for Customer
Released on: 03.06.2004 15:01:27
Master Language: German
Priority: Recommendations/additional info
Category: Installation information
Primary Component: BC-DB-ORA OracleHi
1. Do you have sqlplus access to the database?
2. What do you mean by "But that is not visible in oracle"? Is the table still non-partitioned on the database? Is the table shown as "active" and "exists in database" in SE14? What does a check -> database object show?
3. Can you please also add a few details about what exactly you wanted to achieve, like table name, partitioning layout, indexes.
With this info we might be able to help you.
Best regards, Michael -
How to give ref cursor in VB procedure call
This is my Oracle Sp
CREATE OR REPLACE PROCEDURE CRD_DMAN.infy_usp_trades_by_broker_bkr
** Procedure name: CRD_DMAN.USP_TRADES_BY_BROKER
** Author's name: Infosys
** Date written: 04/11/07
** Description: Compliance Trade by Borker
** Maintenance history:
** Date Chg req# Name Remarks
** 04/11/07 Infosys Created
p_ordercursor IN OUT infy_pkg_compliance_transact.cur_compliancetrade,
p_startdate IN VARCHAR,
p_enddate IN VARCHAR,
p_fundcode IN cs_fund_config.parent_acct_cd%TYPE,
p_clientcode IN ts_order_alloc.acct_cd%TYPE,
p_brokercode IN ts_order_alloc.exec_broker%TYPE,
p_reportname IN report_log.report_name%TYPE,
p_callingapplication IN report_log.calling_application%TYPE,
p_callinguser IN report_log.calling_user%TYPE
IS
--Declaring Local Variables
v_owner VARCHAR2 (30);
v_startdate VARCHAR2 (10);
v_enddate VARCHAR2 (10);
v_rowcount NUMBER:=0;
v_logrec base_util_pkg.crd_log_record;
exp_error EXCEPTION;
v_fundcodevalue NUMBER;
BEGIN
BEGIN
/*checking if the start date and end date are null and
assigning the sysdate accordingly*/
IF (TRIM(p_startdate) IS NULL )
THEN
v_startdate := TO_CHAR (SYSDATE, 'mm/dd/yy');
ELSE
v_startdate := p_startdate;
END IF;
IF (TRIM(p_enddate) IS NULL )
THEN
v_enddate := TO_CHAR (SYSDATE, 'mm/dd/yy');
ELSE
v_enddate := p_enddate;
END IF;
/*checking if fund code is null and assigning value accordingly*/
IF TRIM (p_fundcode) IS NULL
THEN
v_fundcodevalue := 0;
ELSE
v_fundcodevalue := 1;
END IF;
/*checking if the reportname or calling user or calling
application name*/
IF (p_reportname IS NULL OR p_callinguser IS NULL
OR p_callingapplication IS NULL)
THEN
RAISE exp_error;
END IF;
END;
--opening and fetching the data into cursor
v_logrec.start_time := SYSDATE;
BEGIN
OPEN p_ordercursor
FOR
SELECT
oa.exec_broker EXEC_BROKER_CODE,
b.bkr_name EXEC_BROKER_NAME,
oa.acct_cd CLIENT_CODE,
f.acct_name CLIENT_NAME,
CASE WHEN (Exists (SELECT 1
FROM cs_fund_broker fb
WHERE rel_typ_cd IN('P','M')
AND oa.exec_broker=fb.BKR_CD
AND oa.acct_cd =fb.acct_cd))
THEN 'Y'
ELSE 'N' END DIRECTED_BROKER,
COUNT ( distinct o.order_id) COUNT_TICKNUM,
MAX (o.trade_date) TRADE_DATE,
SUM (oa.exec_amt) BASE_COST,
SUM (oa.commision_amt) TOTAL_COMMISSION,
(SELECT ab.bkr_typ_cd FROM au_broker ab
WHERE ab.au_change_date =(SELECT TO_TIMESTAMP(MAX(ab.au_change_date))
FROM au_broker ab WHERE b.bkr_typ_cd != ab.bkr_typ_cd AND b.bkr_cd = ab.bkr_cd))
BROKER_HISTORY
FROM
ts_order o
JOIN ts_order_alloc oa ON (o.order_id = oa.order_id)
JOIN cs_broker b ON(oa.exec_broker = b.bkr_cd)
JOIN cs_fund f ON(oa.acct_cd = f.acct_cd)
WHERE
o.status = 'ACCT'
AND oa.exec_broker = CASE WHEN TRIM (p_brokercode) IS NULL
THEN oa.exec_broker
ELSE TRIM(p_brokercode) END
AND oa.acct_cd = CASE WHEN TRIM(p_clientcode) IS NULL
THEN oa.acct_cd
ELSE TRIM(p_clientcode) END
AND ((0 = v_fundcodevalue) OR EXISTS (SELECT 1 FROM crd.cs_fund_config cf
WHERE cf.parent_acct_cd =TRIM (p_fundcode)
AND oa.acct_cd = cf.child_acct_cd))
AND o.trade_date BETWEEN TO_DATE (v_startdate, 'mm/dd/yy')
AND TO_DATE (v_enddate, 'mm/dd/yy')
GROUP BY oa.exec_broker, b.bkr_name ,oa.acct_cd ,f.acct_name,oa.directed_broker,b.bkr_typ_cd,b.bkr_cd;
END;
BEGIN
SELECT
owner
INTO
v_owner
FROM
all_objects
WHERE
object_name = 'INFY_USP_TRADES_BY_BROKER_BKR';
v_logrec.end_time := SYSDATE;
v_logrec.user_code := v_owner;
v_logrec.input_param_values := 'INFY_USP_TRADES_BY_BROKER_BKR,'
|| v_startdate
|| ','
|| v_enddate
|| ','
|| p_fundcode
|| ','
|| p_clientcode
|| ','
|| p_brokercode;
v_logrec.report_name := p_reportname;
v_logrec.object_name := 'INFY_USP_TRADES_BY_BROKER_BKR';
v_logrec.rows_returned := v_rowcount;
v_logrec.calling_application := p_callingapplication;
v_logrec.calling_user := p_callinguser;
END;
BEGIN
--calling the procedure to insert values into the report_log table
COMMIT;
SET TRANSACTION READ WRITE;
base_util_pkg.crd_base_util_proc (v_logrec);
SET TRANSACTION READ ONLY;
END;
EXCEPTION
WHEN exp_error
THEN
DBMS_OUTPUT.put_line ('ERROR');
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('ERROR OCCURED' || SQLCODE);
DBMS_OUTPUT.put_line (SQLERRM);
END infy_usp_trades_by_broker_bkr;
END OF CRD_DMAN.USP_TRADES_BY_BROKER
This is my Pakage from where i am using ref cursor
CREATE OR REPLACE PACKAGE CRD_DMAN.infy_pkg_compliance_transact
AS
** Package name : CRD.INFY_PKG_COMPLIANCE_TRANSACTIONS
** Author's name : Infosys
** Date written : 06/11/07
** Project/System : CRD
** Description : Compliance Trades By Borker Package
** Maintenance history:
** Date Chg req# Name Remarks
** 06/11/07 CRD Infosys Created
--Defining The ComplianceTrade Record DataType
TYPE rec_compliancetrade IS RECORD (
exec_broker_code crd.ts_order_alloc.exec_broker%TYPE,
exec_broker_name crd.cs_broker.bkr_name%TYPE,
client_code crd.ts_order_alloc.acct_cd%TYPE,
client_name crd.cs_fund.acct_name%TYPE,
directed_broker crd.ts_order_alloc.directed_broker%TYPE,
count_ticknum crd.ts_order.order_id%TYPE,
trade_date crd.ts_order.trade_date%TYPE,
base_cost crd.ts_order_alloc.cur_base_mkt_val%TYPE,
total_commission crd.ts_order_alloc.commision_amt%TYPE,
broker_history crd.au_broker.bkr_typ_cd%TYPE
--Declaring a variable of rec_auditdata data type
TYPE cur_compliancetrade IS REF CURSOR
RETURN rec_compliancetrade;
END infy_pkg_compliance_transact;
END OF CRD.INFY_PKG_COMPLIANCE_TRANSACTIONS
How to call this SP from VB code with ref cursor parameter?I'm fairly sure that's not possible, since there's nothing in the ODBC spec to allow for ref cursors. The driver has built in support to check for ref cursors that are returned via a stored procedure call, but there's nothing built into the driver to pass one IN. Since a ref cursor can't be constructed on the client side, you'd have to have some sort of structure that allowed you to reference the ref cursor directly in order to be able to pass one back to the database.
Since you're using VB.NET anyway, the better solution is probably just to use ODP.NET instead, which DOES allow you to reference a ref cursor directly, and there are samples that install with ODP.NET that show you how to do that.
Greg -
How to get highest number of open cursors within the current calendar day
Hi all ,
i need to know how to get the highest number of open cursors within the current calendar day.
Thanks ,823030 wrote:
the issue is my customer is getting the error ORA-01000: maximum open cursors exceeded and we need an sql statment that gets the following values :
-highest number of open cursors experienced in the current calendar day.
-current open cursors
-and maximum open cursorsThis error is rare. It happens when
a) the value of the open cursor parameter is set extremly low (default is something like 1000). Low would be something like 10.
b) <strike>you have many concurrent users(=sessions) and </strike>the application does not use bind values
In this case each select will open a new cursor, instead of reusing it.
c) you have a select that opens a cursor for each line. This can happen with a statement where you have the CURSOR keyword somewhere in the select or where clause. Those cursors will be closed when the select is finished. But during the run time of the select, all cursors stay open.
To track the number of "open cursors" during the day you would need to implement some monitoring. Maybe based on the view that was already mentioned.
Edited by: Sven W. on May 16, 2011 2:30 PM - since the parameter is on session level, other open cursors should not influence it much. -
Cursors are not closed when using Ref Cursor Query in a report ORA-01000
Dear Experts
Oracel database 11g,
developer suite 10.1.2.0.2,
application server 10.1.2.0.2,
Windows xp platform
For a long time, I'm hitting ORA-01000
I have a 2 group report (master and detail) using Ref Cusor query, when this report is run, I found that it opens several cursors (should be only one cursor) for the detail query although it should not, I found that the number of these cursors is equal to the number of master records.
Moreover, after the report is finished, these cursors are not closed, and they are increasing cumulatively each time I run the report, and finally the maximum number of open cursors is exceeded, and thus I get ORA-01000.
I increased the open cursors parameter for the database to an unbeleivable value 30000, but of course it will be exceeded during the session because the cursors are increasing cumulatively.
I Found that this problem is solved when using only one master Ref Cursor Query and create a breake group, the problem is solved also if we use SQL Query instead of Ref Query for the master and detail queries, but for some considerations, I should not use neither breake group nor SQL Query, I have to use REF Cursor queries.
Is this an oracle bug , and how can I overcome ?
Thanks
Edited by: Mostafa Abolaynain on May 6, 2012 9:58 AMThank you Inol for your answer, However
Ref Cursor give me felxibility to control the query, for example see the following query :
function QR_1RefCurDS return DEF_CURSORS.JOURHEAD_REFCUR is
temp_JOURHEAD DEF_CURSORS.JOURHEAD_refcur;
v_from_date DATE;
v_to_date DATE;
V_SERIAL_TYPE number;
begin
SELECT SERIAL_TYPE INTO V_SERIAL_TYPE
FROM ACC_VOUCHER_TYPES
where voucher_type='J'
and IDENT_NO=:IDENT
AND COMP_NO=TO_NUMBER(:COMPANY_NO);
IF :no_date=1 then
IF V_SERIAL_TYPE =1 THEN
open temp_JOURHEAD for select VOCH_NO, VOCH_DATE
FROM JOURHEAD
WHERE COMP_NO=TO_NUMBER(:COMPANY_NO)
AND IDENT=:IDENT
AND ((TO_NUMBER(VOCH_NO)=:FROM_NO and :FROM_NO IS NOT NULL AND :TO_NO IS NULL)
OR (TO_NUMBER(VOCH_NO) BETWEEN :FROM_NO AND :TO_NO and :FROM_NO IS NOT NULL AND :TO_NO IS NOT NULL )
OR (TO_NUMBER(VOCH_NO)<=:TO_NO and :FROM_NO IS NULL AND :TO_NO IS NOT NULL )
OR (:FROM_NO IS NULL AND :TO_NO IS NULL ))
ORDER BY TO_NUMBER(VOCH_NO);
ELSE
open temp_JOURHEAD for select VOCH_NO, VOCH_DATE
FROM JOURHEAD
WHERE COMP_NO=TO_NUMBER(:COMPANY_NO)
AND IDENT=:IDENT
AND ((VOCH_NO=:FROM_NO and :FROM_NO IS NOT NULL AND :TO_NO IS NULL)
OR (VOCH_NO BETWEEN :FROM_NO AND :TO_NO and :FROM_NO IS NOT NULL AND :TO_NO IS NOT NULL )
OR (VOCH_NO<=:TO_NO and :FROM_NO IS NULL AND :TO_NO IS NOT NULL )
OR (:FROM_NO IS NULL AND :TO_NO IS NULL ))
ORDER BY VOCH_NO;
END IF;
ELSE
v_from_date:=to_DATE(:from_date);
v_to_date:=to_DATE(:to_date);
IF V_SERIAL_TYPE =1 THEN
open temp_JOURHEAD for select VOCH_NO, VOCH_DATE
FROM JOURHEAD
WHERE COMP_NO=TO_NUMBER(:COMPANY_NO)
AND IDENT=:IDENT
AND ((voch_date between v_from_date and v_to_date and :from_date is not null and :to_date is not null)
OR (voch_date <= v_to_date and :from_date is null and :to_date is not null)
OR (voch_date = v_from_date and :from_date is not null and :to_date is null)
OR (:from_date is null and :to_date is null ))
ORDER BY VOCH_DATE,TO_NUMBER(VOCH_NO);
ELSE
open temp_JOURHEAD for select VOCH_NO, VOCH_DATE
FROM JOURHEAD
WHERE COMP_NO=TO_NUMBER(:COMPANY_NO)
AND IDENT=:IDENT
AND ((voch_date between v_from_date and v_to_date and :from_date is not null and :to_date is not null)
OR (voch_date <= v_to_date and :from_date is null and :to_date is not null)
OR (voch_date = v_from_date and :from_date is not null and :to_date is null)
OR (:from_date is null and :to_date is null ))
ORDER BY VOCH_DATE,VOCH_NO;
END IF;
END IF;
return temp_JOURHEAD;
end; -
How to use a variable in a cursor?
Hi,
Is it possible to use a variable as condition for fetching data using cursors? The code works fine ( as shown) without using the clause 'where empno < 7600'. How can I use the variable 'stmt' in defining/fetching data by using cursor cur_1? My target is to get info for employee whose empno<7600. Any inputs would be appreciated.
DECLARE
STMT VARCHAR2(50) := 'EMPNO < 7600';
CURSOR CUR_1 IS SELECT EMPNO, ENAME, JOB, MGR FROM EMP;
BEGIN
OPEN CUR_1;
LOOP
FETCH CUR_1 INTO :EMP.EMPNO, :EMP.ENAME, :EMP.JOB, :EMP.MGR;
EXIT WHEN CUR_1%NOTFOUND;
NEXT_RECORD;
END LOOP;
CLOSE CUR_1;
END;Hi:
You could use a CURSOR Parameter:
DECLARE
CURSOR CUR_1 (empno_in IN VARCHAR2) IS SELECT EMPNO, ENAME, JOB, MGR FROM EMP WHERE empno < empno_in;
BEGIN
OPEN CUR_1 (7600);
LOOP
FETCH CUR_1 INTO :EMP.EMPNO, :EMP.ENAME, :EMP.JOB, :EMP.MGR;
EXIT WHEN CUR_1%NOTFOUND;
END LOOP;
CLOSE CUR_1;
END;
or a REF Cursor, like so:
DECLARE
TYPE CUR_1_TYPE IS REF CURSOR;
CUR_1 CUR_1_TYPE;
BEGIN
OPEN CUR_1 FOR SELECT EMPNO, ENAME, JOB, MGR FROM EMP WHERE empno < 7600;
LOOP
FETCH CUR_1 INTO :EMP.EMPNO, :EMP.ENAME, :EMP.JOB, :EMP.MGR;
EXIT WHEN CUR_1%NOTFOUND;
END LOOP;
CLOSE CUR_1;
END;
Note - these will run in SQL*Plus ... I believe you are using Oracle Forms as you had the NEXT_RECORD command in your example, and I had to remove it. -
Oracle Instant Client and OUT Parameter of custom type in Stored Procedures
Hi @ all!
I try to set up a simple client application, that calls a stored procedure via Instant Client from C#.
The stored procedure and assiciated types looks like this:
TYPE MYVALUE AS OBJECT
Id INTEGER,
value FLOAT
TYPE MYVALUELIST AS TABLE OF MYVALUE;
PROCEDURE ReadValues( ID IN INTEGER,
RESULTSET OUT MYVALUELIST)
IS
...I created an Oracle Command executing this SP and added OracleParameters for ID and (where I got stuck) the RESULTSET.
Is it possible to pass a parameter with a custom type from C# in some way?
I already tried it as a function with SELECT * FROM TABLE(ReadValues(1));
With my parameter RESULTSET as the RETURN type. But since I use DML within the procedure, this does not work inside of a query...
Any suggestions?
Thanks in advance!Hi Greg!
Sorry, I misunderstood the forum topic then. =(
Anyway, in the example you provided in the link, this is nearly exactly my situation. But there the Oracle.DataAccess.Client is used, where the OracleDBType can be called to initialize an object of type person. I use the instant client libraries called by using System.Data.OracleClient. There is only the OracleType enum, that does not contain an object or something similar.
So I do it right now after trying a bit with a ref cursor parameter and an OracleDataAdapter - the ref cursor is passed back from Oracle as a DataReader, so die DataAdapter is able to use it for a .Fill():
OracleCommand cmd = new OracleCommand();
cmd.Parameters.Add("RESULTSET", OracleType.Cursor).Direction = ParameterDirection.Output;
OracleDataAdapter odr = new OracleDataAdapter(cmd);
DataTable result = new DataTable();
odr.Fill(result);Within my stored procedure I just added the following OUT parameter:
PROCEDURE ReadValues( ID IN INTEGER,
RESULTSET OUT sys_refcursor)
IS
currentlist MYVALUELIST;
... [Adding elements to that list] ...
OPEN resultset for select * from TABLE(currentlist);It works now, but I don't like that solution that much since I'm always afraid that there are lots of opened cursors idyling around. Do I have to close this one explicitly after filling my table by the DataAdapter?
Regards -
Can't registerOutParameter of cursor type in SQL Server 2000
Hi, there,
I'm using SQL Server 2000 and a type 4 JDBC driver for it from JRun 3.1. I wrote a stored procedure which has a Cursor (ResultSet) as an output parameter. But I used callStmt.registerOutParameter(1, java.sql.Types.OTHER);
I got an exception:
callable stmt class: allaire.jrun.db.jdbc.base.BaseCallableStatement
java.sql.SQLException: [JRun][SQLServer JDBC Driver]The specified SQL type is not supported by this driver.
I definitely want the cursor to be an output parameter in my SQL 2000 store procedure, rather than defining a store procedure without an output Cursor parameter and then use callStmt.getResultSet();
Does any one knows a way to register an output parameter of type CURSOR in SQL Server 2000 JDBC?
I know that with in Oracle JDBC driver, you can do this:
callStmt.registerOutParameter(1, OracleTypes.CURSOR);
ButI failed to find a equivalent in SQL Server 2000 JDBC driver.
Thanks a lot.If you found any solution to this, would you please let me know too? It'll help a tonne.
Maybe you are looking for
-
ASA 5505 (8.3.1) DMZ to Outside access problem
We have a hub and spoke VPN setup and at one location used the DMZ port/vlan subnet to access the hub. We have since changed and want the DMZ to only access the outside interface (have base license that can only access one interface). We have taken o
-
Has anyone run into this situtation?
-
Hello, I bought music on my iPod touch. Why is it that I cannot put that music on my other Ipod(s)? I downloaded my IPodTouch to my computer with no problems. I tried to drag the music I bought on my IpodTouch to other playlists on my computer and it
-
Idoc Status 53 but Applicaton document not posted message type PORDCR
Hi, Need your help. I am using message type PORDCR and Basic type PORDCR04 to create Purchase order through inbound Idocs. I am getting correct status '53' Application document posted along with the new Purchase order number. When I am trying to see
-
Trouble making a CLR Function - Part 2
I successfully made a CLR split function in c# and registered it in sql server. Now I added another function to the assembly called FormatString. First I had to drop the function Split, and then the assembly CLRHelper, then I added the assembly and