How to descrbe a ref cursor from a PL/SQL prog?
Hi,
here is a sample of the my problem
let suppose a table country :
create table country(country_code VARCHAR2(3), country_name VARCHAR2(50));
then a package containing different procedures among them, this one :
PL/SQL prog
create or replace package country_pkg as
type rec1 is ref cursor return country%rowtype;
Procedure get_all_countries(rec in out rec1);
blablabla ...
END country_pkg;
in the package body, i have the following code :
create or replace package body country_pkg as
procedure get_all_countries(rec IN OUT rec1) is
begin
if not rec%open then
open rec for select * from country order by country_name;
end if;
exception
when NO_DATA_FOUND then
close rec;
end get_all_countries;
blablabla....
end;
Then in the C program
(*proc)->request->command = "begin get_all_countries(:rec); end;"
checkerr(&connect, \
OCIStmtPrepare(connect->stmthp,\
connect->errhp,\
(*proc)->request->command,\
strlen((*proc)->request->command),\
OCI_NTV_SYNTAX, OCI_DEFAULT));
checkerr(&connect, \
OCIHandleAlloc((dvoid*)(connect->envhp),\
(dvoid**) &((*proc)->stmthp), OCI_HTYPE_STMT,
(size_t) 0,\
(dvoid**) 0));
bndhp = (OCIBind**) g_malloc0((*proc)->argnum*sizeof(OCIBind*));
for(i = 0; i < (*proc)->argnum; i++)
switch ((*proc)->desc->type)
case 102:
checkerr(&connect,
OCIBindByPos(connect->stmthp, &bndhp[j],
connect->errhp,
i+1,&((*proc)->stmthp), (sb4) 0,
SQLT_REF, (dvoid*) 0, (ub2*) 0, (ub2*) 0,
(ub4) 0,
(ub4*) 0, (ub4) OCI_DEFAULT));
default:
some code ....
checkerr(&connect, \
OCIStmtExecute(connect->svchp, connect->stmthp,\
connect->errhp, 1, (ub4) 0, (OCISnapshot*) 0,\
(OCISnapshot*) 0, OCI_DEFAULT));
parm_status = OCIParamGet(connect->stmthp, OCI_HTYPE_STMT,connect->errhp, (dvoid**)&arg, 0);
while(parm_status == OCI_SUCCESS)
OCIAttrGet((dvoid*) arg, OCI_DTYPE_PARAM,
(dvoid*)type,0, (ub4) OCI_ATTR_NUM_PARAMS,
connect->errhp);
counter++;
parm_status = OCIParamGet(connect->stmthp,
OCII_HTYPE_STMT,connect->errhp,
(dvoid**)&arg, counter);
This piece of code doesn't work as 'arg' is always NULL
and OCIParamGet retruns OCI_SUCCESS.
I'm certainly missing something but I don't see what. Could anyone help me to get that piece of code working?
regards,
Raphael
unfortunately, not yet!
I dropped the matter for now, I'll come back on it later.
On your side, let me know if you find something interesting on that topic by posting a message here.
Similar Messages
-
How to return a ref cursor from this dbms_sql?
Hi,
Can anyone show me how to return a ref cursor from this dbms_sql based procedure? I see 11g has a dbms_sql.to_refcursor(cursor_handle). How can this be done is 10g?
Thx.
CREATE OR REPLACE PROCEDURE Sample_Get_t
p_sample_id sample.sample_id%TYPE,
p_contract_id sample.contr_id%TYPE
IS
cursor_handle INT;
sql_stmnt varchar2(500);
rows_processed NUMBER;
BEGIN
sql_stmnt :=
'SELECT
sample_id,
contr_id,
rcpt_id
FROM
sample s
WHERE
s.contr_id = :1
and s.sample_id = :2
ORDER BY
sample_id';
cursor_handle := dbms_sql.open_cursor;
dbms_sql.parse(cursor_handle, sql_stmnt, dbms_sql.native);
dbms_sql.bind_variable(cursor_handle, ':1', p_contract_id);
dbms_sql.bind_variable(cursor_handle, ':2', p_sample_id);
rows_processed := dbms_sql.execute(cursor_handle);
dbms_sql.close_cursor(cursor_handle);
END Sample_Get_t;In 10 this cannot be done with dbms_sql (to my knowledge). There are a couple of other options.
1) open the ref cursor for the dynamic statement using bind variables (or SYS_CONTEXT variables, which i prefer since they are much easier to deal with when you are dynamically adding predicates).
declare
wRefCursor SYS_REFCURSOR;
begin
open wRefCursor for 'select * from all_objects where owner = :Logged_in_user' using user;
end;
/or using the context (the context will bind for you)
declare
wRefCursor SYS_REFCURSOR;
begin
open wRefCursor for 'select * from all_objects where owner = SYS_CONTEXT(''CONTEXT_NAME'', ''VARIABLE_NAME'') ';
end;
/Be aware that contexts ALWAYS return varchar values, so if you are comparing to a number you should wrap it in TO_NUMBER, a date, TO_DATE and so on....
2) change the DBMS_SQL to do an insert into a global temporary table and return the ref cursor which select's * from GTT;
3) upgrade to Oracle 11 :) -
How to out Dynamic ref cursor from Procedure to Forms
Hi
I am trying to out Dynamic ref cursor from Procedure to Forms, But I am unable to do so. however cursor return the value within procedure but I am failed to capture the same in Forms
Pl advice suggestion if any, Here I am attaching full procedure for reference
CREATE PACKAGE winepkg
IS
TYPE wine IS RECORD ( mynumber number);
/* Define the REF CURSOR type. */
TYPE wine_type IS REF CURSOR RETURN wine;
END winepkg;
CREATE procedure find_wine
(col1_in in number,
c1 out winepkg.wine_type) as
vsql varchar2(1000);
cur sys_refcursor;
x number;
BEGIN
vsql:='select bo_id from bo_details where bo_details.bo_id = '||col1_in ;
open cur for vsql;
c1:=cur;
--fetch c1 into x;
--dbms_output.put_line(x);
END find_wine;
In front end forms
Declare
TYPE F is REF CURSOR;
CUR_F F;
rec number;
Begin
break;
find_wine( 1601480000011078,cur_f ) ;
Loop
fetch cur_f into rec ;
Message(rec ) ;pause;
exit when cur_f%notfound ;
End loop ;
exception
when others then
Message(sqlerrm) ;pause;
End ;yo can use
declare
c_cursor EXEC_SQL.CursType;
v_stmt varchar2(2000) = 'select a, b, c from mytab where cond1'; -- you can create this value dynamically
begin
c_cursor := Exec_SQL.Open_cursor;
EXEC_SQL.PARSE(c_articulos, v_stmt);
EXEC_SQL.DEFINE_COLUMN(c_articulos,1, v_colchar1, 30);
EXEC_SQL.DEFINE_COLUMN(c_articulos,2, v_colchar2, 15);
EXEC_SQL.DEFINE_COLUMN(c_articulos,3, v_colchar3, 30);
v_exec := EXEC_SQL.EXECUTE(c_cursor);
WHILE EXEC_SQL.FETCH_ROWS(c_cursor) > 0 LOOP
EXEC_SQL.COLUMN_VALUE(c_cursor,1,v_colchar1);
EXEC_SQL.COLUMN_VALUE(c_c_cursor,2,v_colchar2);
EXEC_SQL.COLUMN_VALUE(c_c_cursor,3,v_colchar3);
assign_values_to_block;
END LOOP;
EXEC_SQL.CLOSE_CURSOR(c_cursor);
end;
and WORKS IN FORMS 6 -
Q: NULL return REF CURSOR from a PL/SQL function
I was told that PL/SQL does not handle properly NULL REF CURSORS.
Here's my implementation in a PL/SQL package
PACKAGE SPEC:
TYPE z_rec IS RECORD (
TYPE z_cur IS REF CUR RETURN z_rec;
FUNCTION some_function(
p_msg OUT VARCHAR2)
RETURN z_cur;
PACKAGE BODY:
FUNCTION some_function(
p_msg OUT VARCHAR2)
RETURN z_cur
IS
retval z_cur;
OPEN retval FOR
SELECT ...
-- Successfull data retrieval
p_msg := NULL;
RETURN retval;
EXCEPTION
WHEN OTHERS THEN
p_msg := SUBSTR( SQLERRM, 1, 255 );
RETURN NULL;
END some_function;
I am expecting that a user of this function would call it and test p_msg (output parameter)
1. IS NULL p_msg it means there were no errors encounetered. The returned cursor can be NULL though (i.e. no records retrieved)
2. IS NOT NULL p_msg, it means that there were errors and the returned cursor is not usable.
My question is:
what are the pitfalls of this approach?
Thanks a lot.user10817976 wrote:
I asked and still waiting for the answer.
retval z_cur;
What I am afraid for is that
OPEN retval FOR
SELECT ...
EXCEPTION
retval := NULL;
tries to open the cursor. What happens in case of error? Well, I imagine retval is still NULL. Do I need to (try) to close the cursor in the EXCEPTION section (in order not to misuse the number of cursors in the pool?) That's my worry.No.
If there is an error opening the cursor the cursor will not be open and will not need closing.
The code should simply be
function some_function
return z_cur
is
retval z_cur;
begin
open retval for
select ...
return retval;
end some_function; It is bad practice for a function to have output parameters.
It is bad practice to turn exceptions into return codes.
http://tkyte.blogspot.com/2008/06/when-others-then-null-redux.html
Remember everyone, everyone remember, keep in mind:
When others not followed by RAISE or RAISE_APPLICATION_ERROR is almost certainly, with 99.999999999% degree of accuracy, a bug in your developed code. Just say "no" to when others not followed by raise or raise_application_error!Read the links, it leads to problems over and over again. -
How return parameter ref Cursor from procedure using dynamic SQL?
I sorry, but i very need help.
I using Oracle 8.0.6
I need to return parameter of type ref Cursor from procedure.
create or replace package PlanExp is
type cursortype is ref cursor;
procedure ShowPlan (cursorparam out
cursortype.............);
end PlanExp;
create or replace package body PlanExp is
procedure ShowPlan (cursorparam out cursortype,
.............) Is
sql_str varchar2(1000);
sql_str_select varchar2(100);
sql_str_from varchar2(100);
sql_str_where varchar2(500);
Return_Code integer;
Num_Rows integer;
cur_id_sel integer;
tSum_Plan DBMS_SQL.NUMBER_TABLE;
tSum_Plan_Ch DBMS_SQL.NUMBER_TABLE;
tSum_Plan_Day DBMS_SQL.NUMBER_TABLE;
begin
/* calculating string variables ........... /*
sql_str := 'select ' || sql_str_select ||
'from ' || sql_str_from ||
'where ' || sql_str_where ||
'group by ' || sql_str_select;
cur_id_sel := dbms_sql.open_cursor;
dbms_sql.parse(cur_id_sel, sql_str, dbms_sql.native);
dbms_sql.define_array(cur_id_sel, 1, tSum_Plan, 20, 1);
dbms_sql.define_array(cur_id_sel, 2, tSum_Plan_Ch, 20, 1);
dbms_sql.define_array(cur_id_sel, 3, tSum_Plan_Day, 20, 1);
Return_Code := dbms_sql.execute(cur_id_sel);
delete from TEMP_SHOWPLAN;
Loop
Num_Rows := dbms_sql.Fetch_Rows(cur_id_sel);
dbms_sql.column_value(cur_id_sel, 1, tSum_Plan);
dbms_sql.column_value(cur_id_sel, 2, tSum_Plan_Ch);
dbms_sql.column_value(cur_id_sel, 3, tSum_Plan_Day);
if Num_Rows = 0 then
exit;
end if;
Exit When Num_Rows < 20;
End Loop;
dbms_sql.close_cursor(cur_id_sel);
end;
end PlanExp;
How return cursor (cursorparam) from 3 dbms_sql.column_value-s ?I am using Oracle 8.1.7, so I don't know if this will work in
8.0.6 or not:
SQL> CREATE TABLE test
2 (col1 NUMBER,
3 col2 NUMBER,
4 col3 NUMBER)
5 /
Table created.
SQL> INSERT INTO test
2 VALUES (1,1,1)
3 /
1 row created.
SQL> INSERT INTO test
2 VALUES (2,2,2)
3 /
1 row created.
SQL> INSERT INTO test
2 VALUES (3,3,3)
3 /
1 row created.
SQL> CREATE TABLE temp_showplan
2 (tSum_Plan NUMBER,
3 tSum_Plan_Ch NUMBER,
4 tSum_Plan_Day NUMBER)
5 /
Table created.
SQL> EDIT planexp
CREATE OR REPLACE PACKAGE PlanExp
IS
TYPE CursorType IS REF CURSOR;
PROCEDURE ShowPlan
(cursorparam IN OUT CursorType,
sql_str_select IN VARCHAR2,
sql_str_from IN VARCHAR2,
sql_str_where IN VARCHAR2);
END PlanExp;
CREATE OR REPLACE PACKAGE BODY PlanExp
IS
PROCEDURE ShowPlan
(cursorparam IN OUT CursorType,
sql_str_select IN VARCHAR2,
sql_str_from IN VARCHAR2,
sql_str_where IN VARCHAR2)
IS
sql_str VARCHAR2 (1000);
cur_id_sel INTEGER;
return_code INTEGER;
BEGIN
DELETE FROM temp_showplan;
sql_str := 'INSERT INTO temp_showplan '
|| ' SELECT ' || sql_str_select
|| ' FROM ' || sql_str_from
|| ' WHERE ' || sql_str_where;
cur_id_sel := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE (cur_id_sel, sql_str, DBMS_SQL.NATIVE);
return_code := DBMS_SQL.EXECUTE (cur_id_sel);
DBMS_SQL.CLOSE_CURSOR (cur_id_sel);
OPEN cursorparam FOR SELECT * FROM temp_showplan;
END ShowPlan;
END PlanExp;
SQL> START planexp
Package created.
Package body created.
SQL> VARIABLE g_ref REFCURSOR
SQL> EXEC PlanExp.ShowPlan (:g_ref, 'col1, col2,
col3', 'test', ' 1 = 1 ')
PL/SQL procedure successfully completed.
SQL> PRINT g_ref
TSUM_PLAN TSUM_PLAN_CH TSUM_PLAN_DAY
1 1 1
2 2 2
3 3 3 -
How to get an UPDATABLE REF CURSOR from the STORED PROCEDURE
using C# with
ORACLE OLE DB version: 9.0.0.1
ADO version: 2.7
I returns a REF CURSOR from a stored procedure seems like:
type TCursor is ref cursor;
procedure test_out_cursor(p_Dummy in varchar, p_Cur out TCursor) is
begin
open p_Cur for select * from DUAL;
end;
I create an ADO Command object and set
cmd.Properties["IRowsetChange"].Value = true;
cmd.Properties["Updatability"].Value = 7;
cmd.Properties["PLSQLRSet"].Value = 1;
cmd.CommandText = "{CALL OXSYS.TEST.TEST_OUT_CURSOR(?)}";
and I use a Recordset object to open it:
rs.Open(cmd, Missing.Value,
ADODB.CursorTypeEnum.adOpenStatic,
ADODB.LockTypeEnum.adLockBatchOptimistic,
(int) ADODB.CommandTypeEnum.adCmdText +
(int) ADODB.ExecuteOptionEnum.adOptionUnspecified);
The rs can be opened but can NOT be updated!
I saved the recordset into a XML file and there's no
rs:baseschema/rs:basetable/rs:basecolumn
attributes for "s:AttributeType" element.
Any one have idea about this?
thanks very muchIt is not possible through ADO/OLEDB.
Try ODP.NET currently in Beta, it is possible to update DataSet created with refcursors. You need to specify your custom SQL or SP to send update/insert/delete.
As I remember there is a sample with ODP.NET Beta 1 just doing this. -
Populate a REF CURSOR from regular cursor...
Hi all,
I apologize if the answer to this is somewhere...I've been looking on the web for sometime and can't find an answer to the following problem. I have a Significant Events database that contains network based issues and problems. As problems are detected on the network an SE is issued and published. As the SE records are updated, NEW records are entered into the table and "linked" back to the original. Each update results in a new row. Thus, an SE with two updates would have a total of 3 lines. When the SE gets closed (set the column CLOSED to SYSDATE), only the "original" SE is closed, any updates are left open...aka, the CLOSED column is left null.
That said, I need a way to get the original and/or latest updated SE rows from the table. Thus, I am trying to use a PL/SQL package. The PL/SQL "must" return a REF CURSOR as the results are being passed to a client process.
My initial approach was within a PL/SQL procedure, I have an SQL statement that returns the SE originals. Once in that cursor I need to do the following:
- Attempt to fetch any linked SE rows.
- if no rows then
- add the original to the REF CURSOR.
- else
- find latest SE update
- add latest SE update to REF CURSOR.
- end if
My Question is : How do I manually "add" a row to a REF CURSOR?
If this is not possible, is there a way to populate a REF CURSOR from maybe another construct like:
TYPE ian_se_record is RECORD (
se_id number
,linked_se_id number
,submitted date
,updated date
,closed date
,segroup varchar2(150)
,incident_start_time varchar2(150)
,business_units_affected varchar2(150)
,officenum varchar2(1500)
,sedetails varchar2(4000)
TYPE ian_se_table is table of ian_se_record index by binary_integer;
With the above construct I could:
- Fill ian_se_table with the process described above.
- And finally select off ian_se_table into the REF CURSOR?
Any help would be greatly appreciated,
adymHi michaels,
I've put your solution in place, but can't seem to get it to run. The two types were moved out of the package and into real types as you said. Here's the function, for brevity, I've remove some of the less important code:
function ian_se_fetch return sys_refcursor
is
p_csr_events sys_refcursor;
cursor csr_items is
select
se_id
...removed for brevity...
/* END : csr_items */
ian_se_row ian_se_record;
ian_se_tbl ian_se_table;
l_lng_index number;
l_lng_linked number;
l_lng_id number;
begin
* OPEN : Open the main cursor of originals...
for the_item in csr_items loop
* CHECK : Check for any updates to the original...
l_lng_linked := 0;
select count(*)
into l_lng_linked
from sig_se_t src
where src.linked_se_id = the_item.se_id;
l_lng_id := 0; /* reset the se-id */
/* SE original...no linked records yet. */
if ( l_lng_linked = 0 ) then
l_lng_id := the_item.se_id;
/* SE updates...one or more updates are present. */
else
begin
select
se_id
into l_lng_id
from sig_se_t src
where src.linked_se_id = the_item.se_id
and rownum = 1
order by updated desc; /* latest update */
exception
when too_many_rows then
l_lng_id := the_item.se_id;
when others then
l_lng_id := 0;
end;
end if;
if ( l_lng_id != 0 ) then
select
se_id
,linked_se_id
,submitted
,updated
,closed
,segroup
,incident_start_time
,business_units_affected
,officenum || decode( nvl(impact,'1')
,'1',''
,decode(impact
,'NA', ''
,':' || impact
) impact
,sedetails
into ian_se_row.se_id
,ian_se_row.linked_se_id
,ian_se_row.submitted
,ian_se_row.updated
,ian_se_row.closed
,ian_se_row.segroup
,ian_se_row.incident_start_time
,ian_se_row.business_units_affected
,ian_se_row.officenum
,ian_se_row.sedetails
from sig_se_t src
where src.se_id = l_lng_id;
l_lng_index := nvl(ian_se_tbl.last,0)+1;
ian_se_tbl(l_lng_index).se_id := ian_se_row.se_id;
ian_se_tbl(l_lng_index).linked_se_id := ian_se_row.linked_se_id;
ian_se_tbl(l_lng_index).submitted := ian_se_row.submitted;
ian_se_tbl(l_lng_index).updated := ian_se_row.updated;
ian_se_tbl(l_lng_index).closed := ian_se_row.closed;
ian_se_tbl(l_lng_index).segroup := ian_se_row.segroup;
ian_se_tbl(l_lng_index).incident_start_time := ian_se_row.incident_start_time;
ian_se_tbl(l_lng_index).business_units_affected := ian_se_row.business_units_affected;
ian_se_tbl(l_lng_index).officenum := ian_se_row.officenum;
ian_se_tbl(l_lng_index).sedetails := ian_se_row.sedetails;
end if;
end loop;
* REF CURSOR : Open the ref cursor on the dataset...
if ( nvl(ian_se_tbl.last,0) = 0 ) then
p_csr_events := null;
else
open p_csr_events for
select *
from table (cast ( ian_se_tbl as ian_se_table ));
end if;
return p_csr_events;
end;Here's the test. I keep getting the same error ORA-06530:
SQL> variable v refcursor;
SQL> exec :v:=pkg_ian.ian_se_fetch;
BEGIN :v:=pkg_ian.ian_se_fetch; END;
ERROR at line 1:
ORA-06530: Reference to uninitialized composite
ORA-06512: at "N0002501.PKG_IAN", line 131
ORA-06512: at line 1
SQL> print v
ERROR:
ORA-24338: statement handle not executedOther things I tried:
- The ian_se_fetch() function was a procedure using an in out parameter...same error.
- Wrote a small anonymous block and tried to LOOP/FETCH. Same ORA-06530 error.
P.S. Line 131 of pkg_ian is the SELECT ... INTO ian_se_row.se_id, ...
Any help would be greatly appreciated,
tia,
adym
Message was edited by:
alink -
How do I stop the cursor from spontaneously going to Line one space one in Notes?
How do I stop the cursor from spontaneously going to Line one Space one in Notes?
I am currently working on a MacBook Pro connected by Wi-Fi or Blue Tooth to my 16GB iPhone 4S; and supposedly to iCloud. I install every upgrade on each computer till the computer can take no more. My current MacBook Pro continues to accept upgrades.
I have been dealing with Address Book foibles since it first came out and the problems seem to get worse rather than resolved.
Problem #1: When a Company Name is checked to take precedence over a personal name the record/file does not surface during searches. This has happened for years on all my Macs, including most recently my MacBook Pro and its predecessor PowerBook G4. How do I fix this?
Problem #2: The Printing Defaults for Address Book Files are not useful and I can find no way to change them to my own preferences once and for all. I must reset them for every file every time I choose to print a file. Is there some way to set the defaults to MY preferences and only occasionally reset them according to my needs?
Problem #3: When entering information in "Notes" the cursor randomly and spontaneously goes to line one space one as I am entering information. How do I stop this? Then when I cut and paste the misplaced text to where it belongs it may or may not return to once again begin at line one space one and following.
Problem #4: When Printing a Record/File from Address Book I would like to use the whole 8.5" x 11" page. Instead it prints on an 8.5" x 11" page in three columns. Is there a way to format the output? I have not found one and the Mac 'Geniuses' do not know of any.
Problem #5: Subsequent to one of the upgrades in the last year or so, the search feature does not work. (I have had this computer since May 2011). No matter what I type in the search line I am stuck in the 'All' Directory. To find anyone or anything I must scroll through the address book manually. Is there a fix to this?
Problem #6: Sometimes, when I try to sync my MacBook Pro and my iPhone, the records simply duplicate. How d I undo this without manually deleting the duplicates?
Problem #7: Does anyone know of a third party Address-Book-type App that is better than the Apple version and can easily import over 3000 contacts information?'''I had the same problem when I updated to firefox 4. This is how i fixed it:'''
The problem seems to be caused by the 'New Tab Homepage' add on. So:
# Disable or remove the 'New Tab Homepage' add on and restart firefox.
# Download and install the firefox add on called 'NewTabURL' and restart firefox.
# Click on the Options button for NewTabURL and uncheck 'Select location bar after loading new tab'
# Under the 'Default URL for new tabs' heading, choose 'Home Page'
# Click on the Save button.
Hopefully, problem solved! -
Return ref cursor from database link/stored proc? do-able?
Is it possible to return a REF CURSOR from a stored procedure that is being called from a remote database via a database link???
We are trying from Pro*Cobol on MVS (which has db link pointing to AIX thru db link) and get a 00993 error, which seems to say this is not possible.
Before I give up, thought I would check with the experts....
Thanks in advance.You can't return Java objects as stored procedure or query results.
Douglas -
Ref cursor from anonymous block
I have no problem to get a ref cursor from a Fill method call with an anonymous pl/sql block. But if my anonymous block contains a DECLARE section, the dataset is not populated.
ex:
BEGIN OPEN :cuInscription FOR SELECT column FROM table; END;
is ok but with
DECLARE A NUMBER; BEGIN OPEN :cuInscription FOR SELECT column FROM table; END;
the dataset is not populated (even if the SQL CALL succeed).
Do you know about that?This issue has been fixed in the ODP.NET 92040 release.
-
How do i keep my cursor from jumping around when i am typing
how do i keep my cursor from jumping around when i am typing [email protected]
== This happened ==
Every time Firefox opened
== noneCheck your settings in System Preferences > Trackpad
Try a different Tracking speed.
Sometimes just cleaning the trackpad can avoid erratic cursor behavior.
How to clean Apple products -
How do I stop my cursor from selecting things on the page? It shows up like I want to type something and when I press the down key it goes through all the words like its a word document.
== This happened ==
Every time Firefox opened
== June 27, 2010You have '''caret browsing''' enabled - that preference appears as set in your Troubleshooting Information.
http://kb.mozillazine.org/Accessibility.browsewithcaret
Hit the '''F7''' key to disable '''''caret browsing'''''. -
Create a cursor from a PL/SQL variable or an external file
Dear friends,
is there a way for me to make Oracle Forms read a cursor from a PL/SQL variable, or an external file? Let's suppose we have the code below:
DECLARE
cursor c_values is select * from my_table;
r_values c_values%ROWTYPE;
BEGIN
for r_values in c_values loop
do_something;
end loop;
END;
In the situation described above, could I create "select * from my_table" from a PL/SQL variable (it could be something like p_cursor = 'select * from my_table'), or an external file - for example, make my form read the contents of c:\my_select.sql , where we see the "select * from my table" text?
My question comes because I need to export data from select instructions that were dinamically created inside the form - that is, via PL/SQL -, and I don't want to rewrite it, but I'll have to do it if I have no choice. Your help will be greatly appreciated.
Best regards,
Franklin
Edited by: franklinbrasil on 12/03/2009 11:33
Edited by: franklinbrasil on 12/03/2009 11:35Dear friends,
I am using DBMS_SQL package, which solved my problem. Please let me explain it better, if it's not clear.
I have some PL/SQL blocks inside my form, which creates SQL queries dinamically, and a dinamically created SQL is stored into a VARCHAR2 variable. These SQL queries are exported for use in Oracle Graphics, but since OG is not being developed by Oracle anymore then I am trying to find a substitute for it.
So I thought about creating an option for the final user: he/she can choose exporting data into Microsoft Excel, and user does what he/she wants, creating a customized graphic. Exporting into Excel works finely, with no problems at all - I could find a routine by searching on the web.
My goal was to use the same queries created above to export data dinamically to Microsoft Excel, and I absolutely don't want to rewrite all these dinamically created queries - one which works dinamically, other with no flexibility inside my form. Worse than it, I have many other dinamically created queries, and I obviously don't want to rewrite them all - any maintenance in this form would be terrible, with each SQL instruction written twice.
Since all dinamically created SQL instructions are stored inside a VARCHAR2 variable, I thought about reusing the same SQL, as explained above - and here we have your suggestions about using a ref cursor, execute immediate, and so on. And (answering Andreas) query structure is always based on the same table, but its structure changes a lot, depending on what the final user chooses in a drop-down list (it's a list of graphics options, where final user chooses one option, and form must mount SQL dinamically, based on user's choice).
By using your explanations, I could find DBMS_SQL solution here: http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96590/adg09dyn.htm#26799
. Please notice that I had to change DBMS_SQL.native into 1 for it to work in my form. I'll mark all your answers as helpful because I can use them both for database and form purposes.
If my message was not clear enough, please tell me and I'll try to make it more clear.
Best regards,
Franklin -
Tell me how to format a date retrieved from a MS SQL Server 2000 database?
Tell me how to format a date retrieved from an MS SQL Server 2000 database for various uses in my JSP page?
Or if you want to use JSTL instead of a scriptlet see:
http://forum.java.sun.com/thread.jspa?threadID=676754&tstart=0 -
How to get second maximum salary from employee table(sql query)
how to get second maximum salary from employee table(sql query)
dude there is no matter of structure .........that user already said its from employee table ...............its basic table in sql and there is no need to specify the table structure
.........i think u got my point I think you are the one who didn't understand Sarma's point.
Give a man a fish and you feed him once. Teach a man how to fish and you feed him a life long.
>
and the query is
select max(sal) from emp where sal<(select max(sal)
from emp);
this will give the 2nd max salary from the emp tableBtw: You solution is bad, because it needs to scan and sort the table emp twice. And a better solution has been given already.
Message was edited by:
Sven W. - reordered statements
Maybe you are looking for
-
Error is displayed when I try updating my iPod
When I try to update my iPod, all of the sudden it now shows a error message that says "Songs on the iPod cannot be updated because all of the playlists selected for updating no longer exist." I don't know what this means and I don't know how to fix
-
Copying Goods return to AP Credit note
Hi all, We've returned some goods to a supplier, so we do a goods return on SAP, so that credits stock and Debits allocation account. Our supplier has sent us an AP credit note. So we 'copy to' AP Credit (from Goods return) and the automatic journal
-
How to change the Group name?
Hi I made some groups and assigned users to it. Now the need requires me to change the names of the group. Could you please explain me how to do this and also will this chage be also effective in the desktop master rule. I'm using EP6.0, SP11 Thanks
-
N8 : ractivate help when using applications
N8 can show help (clue) when using application. I have de-activated by mistake but i can't find how to reactivate it. Do you know how ? Thank you.
-
Can anyone give me a list of reasons why my ipod touch and my new ipad are recognised as cameras in itunes on my xp computer? It always used to work so do not know what has changed. Things are okay on my laptop.