Cursor in a Package
Hi
I declared a cursor in a package
create
PACKAGE DATA
AS
CURSOR C1_DATA IS SELECT * FROM EMP;
c_data C1_DATA%ROWTYPE;
procedure city;
procedure state;
procedure zip;
END;
I have all the records from emp(empid,empname,empcity,empstate,empzip) in the cursor. I need to write the package spec as
create
PACKAGE body DATA
as
procedure city..
procedure state..
procedure zip...
END;
I would like to write 3 different procedures for city,sate and zip update.So I need to fetch one record from cursor and then run 3 procedures for updating the same record.How can I achieve this
fetch a record from cursor and then run all the procedures and fetch the next record and run all the procedurs on the same rec
890563 wrote:
Hi
I wanted to write a package as
create
PACKAGE body DATA
as
fecth a record from the cursor to c_data
procedure city
begin update empcitytable set empcity = c_data.empcity where empid = c_data.empid;
procedure state
begin update empstatetable set empstate = c_data.empstate where empid = c_data.empid;
procedure zip
begin update empziptable set empzip = c_data.empzip where empid = c_data.empid;
END;
I would fetch a record from emp and update the same data in different tables.
Edited by: 890563 on 23 Oct, 2012 12:16 AMWell so you update three different tables. Again the question is why cursor? I would just do 3 merge
merge into empcitytable c
using emp e
on (e.empid = c.empid)
when matched then
update set c.empcity = e.empcity;
merge into empstatetable c
using emp e
on (e.empid = c.empid)
when matched then
update set c.empstate= e.empstate;
merge into empziptable c
using emp e
on (e.empid = c.empid)
when matched then
update set c.empzip = e.empzip;
Similar Messages
-
Declaration of cursor type in package/sp
Hi,
I'm using package with sp that using cursor like below:
--#1============================ PACKAGE
{PACKAGE ORA_PK_TR2 AS
Type CURS_01 IS REF CURSOR; --- return RYBB.T_COLLECT%rowtype;
Procedure ORA_SP_CUST (EXP_DATE IN date,
END
--#2============================ BODY
create or replace
PACKAGE BODY ORA_PK_TR2 as
Procedure ORA_SP_CUST (EXP_DATE IN date,
open_CURS_01 OUT CURS_01 ) IS
BEGIN
SQL_string = '(select * from RYBB.T_COLLECT where col='||EXP_DATE)'
OPEN open_CURS_01 FOR SQL_STRING;
END;
--#3============================= RUN_PORTION
DECLARE
EXP_DATE DATE;
OPEN_CURS_01 RYBB.ORA_PK_TR2.CURS_01;
TYPE_IN RYBB.T_COLLECT%ROWTYPE; --/***** <==== need to move into package
BEGIN
EXP_DATE := '10-sep-10';
RYBB.ORA_PK_TR2.ORA_SP_CUST(
EXP_DATE => EXP_DATE,
OPEN_CURS_01 => OPEN_CURS_01
LOOP
FETCH open_CURS_01 INTO TYPE_IN;
EXIT WHEN open_CURS_01%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(TYPE_IN.COL1||' '||TYPE_IN.COL2); --/ for sample
END LOOP;
END;}
I need to put TYPE_IN declation for cursor inside the package, so user who will run this pack/sp won't deal with this structure. How I can do this,
I tried to use <return RYBB.T_COLLECT%rowtype;> in package but then I get :
Error(122,6): PLS-00455: cursor 'open_CURS_01' cannot be used in dynamic SQL OPEN statement.
Not sure can I put it somehow into the BODY and make it available for user ?
Appreciate you help.
BEst
Trent
Edited by: trento on Sep 13, 2010 2:36 PM--#1============================ PACKAGE
PACKAGE ORA_PK_TR2 AS
Type CURS_01 IS REF CURSOR; --- return RYBB.T_COLLECT%rowtype;
Type CURS_01_TYP IS RYBB.T_COLLECT%rowtype;
--#3============================= RUN_PORTION
DECLARE
EXP_DATE DATE;
OPEN_CURS_01 RYBB.ORA_PK_TR2.CURS_01;
TYPE_IN RYBB.ORA_PK_TR2.CURS_01_TYP;
BEGIN
Difficult to read, don't you think?
Try use the tags B-)
Your code has other issues and (as shown here) won't compile. If you have a working solution, why not paste that instead? -
Cursor declaration in packages.
Hi,
Our company is decided to use stored procedures for all database access from Java Servlets/JSP. We have to use lot of ref cursors. In a package there will be lots of procedures using cursor. So is it enough to declare only one cursor in the package head of a package and use it in all packages and procedures. Is there any sharing problem in doing it.
Anto Paul.No, The purpose when you declare a cursosr in a package is that the resource can be shared for a lot of sessions maintain each sessions its private values. When a package is invoked the first time is loaded into the SGA and it makes faster the accesses to it.
Joel P�rez -
Passing in values to a cursor in a package procedure
Hi all
I have a package :- test
i have a procedure in the package :- test_proc
in the procedure i have a cursor
which has a select statement
select jobid,jobname from jobs
where jobcode = p_job_code; -- i think this is wrong
when i execute the package i pass the job code to the package as a parameter which i use in the cursor above
as a parameter i have values(i can select any of the above values )
job code :-
10
20
10,20
how can i pass the values to the cursor in the procedure
it is giving me invaiid number;Dear abcdxyz!
As already stated you should try this with dynamic SQL. Here is an example for you:
CREATE OR REPLACE PROCEDURE job_cursor(p_job_code VARCHAR2)
IS
l_jobid NUMBER(5);
l_jobname VARCHAR2(30);
c_job_cursor INTEGER;
l_ignore INTEGER;
BEGIN
-- open cursor on source table
c_job_cursor := DBMS_SQL.Open_Cursor;
-- parse the SELECT statement
DBMS_SQL.parse(c_job_cursor, 'SELECT jobid, jobname FROM job WHERE job_code IN (' || p_job_code || ')', DBMS_SQL.NATIVE);
-- define the column type
DBMS_SQL.Define_Column(c_job_cursor, 1, l_jobid);
DBMS_SQL.Define_Column(c_job_cursor, 2, l_jobname, 30);
ignore := DBMS_SQL.Execute(c_job_cursor);
LOOP
-- Fetch a row from the source table
IF DBMS_SQL.Fetch_Rows(c_job_cursor) > 0 THEN
-- get column values of the row
DBMS_SQL.Column_Value(c_job_cursor, 1, l_jobid);
DBMS_SQL.Column_Value(c_job_cursor, 2, l_jobname);
ELSE
-- No more rows to copy
EXIT;
END IF;
END LOOP;
DBMS_OUTPUT.PUT_LINE(l_jobid || ', ' || l_jobname);
DBMS_SQL.Close_Cursor(c_job_cursor);
EXCEPTION
WHEN OTHERS THEN
IF DBMS_SQL.Is_Open(c_job_cursor) THEN
DBMS_SQL.Close_Cursor(c_job_cursor);
END IF;
RAISE;
END;
/Yours sincerely
Florian W.
P.S. I haven't tested this procedure. -
How to divide resultset of a query in different ref cursors in a package
Hi Oracle Gurus,
I need to create a package which counts the no of rows returned by a select query on multiple tables and according to the returned rowcount inputs the resultset in a ref cursor. Procedure will be called by a .NET program and output param refcursor will be assigned to a data reader which will redirect all the data to an Excel file.
All the above is done. Issue is due to Excel's limit of 64000 rows, if data returned by query is greater than 64K it wont be fit in 1 Excel sheet. So, in order to overcome this limit I need to do some looping in Oracle package which keeps on storing the query results (rows<64K) in different ref cursors so that these refcursors as OUT params can be redirected to separate Excel sheets in C# program.
NOTE : Earlier on I created 2 procedures in the package to fetch rows<64K and another one to fetch rows between 64K and rowcount of the query. My program was calling 2 different procedures to redirect data into 2 diff Excel sheets.
But this fails when query resultset is even greater than 128000 or more and demands 3-4 or even more Excel sheets to be created.
Please help.
Any idea how to do looping in Oracle to accomplish this?> So, in order to overcome this limit I need to do some looping in Oracle package which keeps on
storing the query results (rows<64K) in different ref cursors so that these refcursors as OUT params
can be redirected to separate Excel sheets in C# program.
Huh?
That is saying that "I need to change this road and build it straight through that lake as the road has a curve here".
It surely is a LOT easier to leave the road as is and simply turn the darn steering wheel in the car?
Have the .Net data reader keep a row count of rows read from the ref cursor - and when it reached a pre-set max, have the reader do a "control break"[1] and change to a new worksheet as the destination for writing the rows to.
[1] Google the term if you do not understand this basic concept that was among the very basic program control structures taught back in the 80's.. while I foam at the mouth how today's "wonder kids" turned programmers, that grew up with computers, do not even comprehend the most basic programming logic designs... -
Report based on Ref Cursor and lock package/table (ORA-04021)
Hi,
I have reports based on Ref Cursor. Report builder and Reports Background Engine make pins for package, which consist of Ref Cursor, and for tables, which is used in package. So I can't grant any privileges on these tables anybody.
For example, after next statement:
GRANT SELECT ON table_name TO user_name
I received the next error:
ORA-04021: timeout occurred while waiting to lock object table_name
ThanksHi,
I have reports based on Ref Cursor. Report builder and Reports Background Engine make pins for package, which consist of Ref Cursor, and for tables, which is used in package. So I can't grant any privileges on these tables anybody.
For example, after next statement:
GRANT SELECT ON table_name TO user_name
I received the next error:
ORA-04021: timeout occurred while waiting to lock object table_name
Thanks -
How to create an VO (EO ?) from a cursor got from package ?
Hello,
I have a packaged function that returns a "ref cursor" object.
How can I use this to create a VO (or an EO, but I doubt about this) ?Thanks for the link, but it doesn't answer the question :(
I have a packaged function that returns a cursor :
mypackage.get_my_cursor(param1, param2)
Is is possible to create an EO / VO based on the return of this function ? -
hi,
what is the difference using cursor in body&specifications? how do we separate both of them?
regards
kar1007109 wrote:
for example their is 10 cursor in the package ....Is it possible to pass a different input value for each cursor???
The cursor declarations are just that... declarations. You can reuse the declarations multiple times, and if the cursor is parameterised it will work with whataver parameters are passed to it.
The instantiation of the cursor happens when you open it directly using an open statement, or indirectly using a for loop etc. -
Return package cursor from another store procedure
Hello
I’m new in Oracle, and I have the following problem:
I have an cursor in a package defined like that:
create or replace
PACKAGE "TestPACKAGE" AS
cursor DOWNLOAD_CURSOR is select A.* from Table1 A, Table2 B
END TestPACKAGE;
In reality there is more than one package with different cursors. I want to use that DOWNLOAD_CURSOR in a store procedure, function or another package, to return it to the client as a ref cursor.
Something likes that:
create or replace
procedure aa_test (retCURSOR OUT sys_refcursor) is
begin
retCURSOR := TestPACKAGE.DOWNLOAD_CURSOR;
end;
or to replace that procedure with another method to return data, and use them in a .NET application.961449 wrote:
Hello
I’m new in Oracle, and I have the following problem:
I have an cursor in a package defined like that:
create or replace
PACKAGE "TestPACKAGE" AS
cursor DOWNLOAD_CURSOR is select A.* from Table1 A, Table2 B
END TestPACKAGE;
In reality there is more than one package with different cursors. I want to use that DOWNLOAD_CURSOR in a store procedure, function or another package, to return it to the client as a ref cursor.
Something likes that:
create or replace
procedure aa_test (retCURSOR OUT sys_refcursor) is
begin
retCURSOR := TestPACKAGE.DOWNLOAD_CURSOR;
end;
or to replace that procedure with another method to return data, and use them in a .NET application.Static PL/SQL cursor declarations and Ref Cursors are not interchangable. You cannot return the static cursor definition as a ref cursor.
See...
SQL> ed
Wrote file afiedt.buf
1 declare
2 v_rc sys_refcursor;
3 cursor cur_emp is select * from emp;
4 begin
5 open v_rc for cur_emp;
6* end;
SQL> /
open v_rc for cur_emp;
ERROR at line 5:
ORA-06550: line 5, column 17:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 5, column 3:
PL/SQL: Statement ignored -
INVALID CURSOR - Anonymous Block calling Cursor in function
I am getting an error when trying to call my cursor.
CREATE OR REPLACE PACKAGE tax_update
AS
TYPE gencur IS ref cursor;
FUNCTION tax_sf
p_state IN bb_tax.state%type,
p_thecursor IN OUT gencur
RETURN NUMBER;
END;
CREATE OR REPLACE PACKAGE BODY tax_update
AS
FUNCTION tax_sf
p_state IN bb_tax.state%type,
p_thecursor IN OUT gencur
RETURN NUMBER
IS
lv_taxrate NUMBER;
BEGIN
OPEN p_thecursor FOR
SELECT taxrate
FROM bb_tax
WHERE state = p_state;
RETURN lv_taxrate;
END;
END;
DECLARE
tax_cur tax_update.gencur;
rec_tax bb_tax%rowtype;
BEGIN
LOOP
FETCH tax_cur INTO rec_tax;
EXIT WHEN tax_cur%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(rec_tax.taxrate);
END LOOP;
END;
DECLARE
ERROR at line 1:
ORA-01001: invalid cursor
ORA-06512: at line 6Assignment is to create a package that will hold tax rates by state in a packaged cursor. The package will contain a function that can receive a 2 character state abbr. as an argument and find a match in the cursor and return the tax rate for tha tstate. An anonymous block will test the function with state of NC.
Can anyone assist?You would need to call the function to open the cursor before you try to fetch from the cursor
DECLARE
tax_cur tax_update.gencur;
rec_tax bb_tax%rowtype;
l_some_number number;
BEGIN
l_some_number := tax_update.tax_sf( <<some state parameter>>, tax_cur );
LOOP
FETCH tax_cur INTO rec_tax;
EXIT WHEN tax_cur%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(rec_tax.taxrate);
END LOOP;
END;A couple of points, though.
1) Your function returns a NUMBER but that NUMBER will always be NULL. It seems rather unlikely that this is really what you want. It would seem to make more sense for the function to return the cursor rather than returning a superfluous number.
2) Your function requires a `bb_tax.state%type` parameter. But your anonymous block doesn't seem to have any concept of a state so I'm not sure what you want to pass in there.
3) Looking at the code, it seems a bit odd that your cursor returns a single column of data. If a state can have multiple rates, wouldn't you need to select some additional criteria in order to figure out which sort of tax each row represents or to otherwise differentiate different rows? If a state can only have a single tax rate, it makes no sense to open a cursor that is only going to ever return a single row.
4) There is no need to declare your own weak ref cursor type (tax_update.gencur). You can just use the Oracle built-in type SYS_REFCURSOR.
Justin -
How to make the cursor global if it has parameters that would be passed through calling environment
What I am trying to do is:
1. Pass two dates "p_start_date" and "p_end_date" to a procedure "calc_percnt". Based on these two dates the procedure creates a collection that has ticket info between the date range provided.
2. Iterate through this collection to find out the number of tickets that took less than 4 hrs (p_count_4), less than 8 hours (p_count_8), less than 12 hours(p_count_12) and less than 24 hours (24).
3. I want to move the logic of the above point 2 (also mentioned between dotted lines in the below mentioned code) to a function and call that function.
4. For the above point 3 I will have to create a function which will accept a collection variable something like this:
create or replace cal_perc (collection_var total_tckt_colcn) ....
I cannot do this because total_tckt_colcn needs to be declared
5. I cannot make the cursor and collection type as global by putting them in package specification because of the condition in cursor:
WHERE created_date >= p_start_date AND created_date < (p_end_date + interval '1' DAY)
it gives the error as "p_start_date" and "p_end_date" needs to be declared.
What is the best way to do this????
create or replace
PROCEDURE calc_percnt(
p_start_date IN N01.cc_ticket_info.LAST_CHANGED%type ,
p_end_date IN N01.cc_ticket_info.LAST_CHANGED%type ,
AS
v_start_date N01.cc_ticket_notes.LAST_UPDATED_STAMP%type;
v_end_date N01.cc_ticket_notes.LAST_UPDATED_STAMP%type;
CURSOR cur_total_tckt
IS
SELECT * from
WHERE created_date >= p_start_date AND created_date < (p_end_date + interval '1' DAY)
type total_tckt_colcn
IS
TABLE OF cur_total_tckt%rowtype;
total_tckt_col total_tckt_colcn;
total_coach_col total_tckt_colcn;
BEGIN
total_tckt_col := total_tckt_colcn ();
OPEN cur_total_tckt;
LOOP
FETCH cur_total_tckt bulk collect INTO total_tckt_col limit 100;
END LOOP;
EXIT
WHEN (cur_total_tckt%NOTFOUND);
END LOOP ;
CLOSE cur_total_tckt;
-- ---I want to move the following code in a function which finds the time required to close the ticket and increment the counter ------
FOR i IN total_tckt_col .first..total_tckt_col .last
LOOP
no_of_seconds := calc_time_diff(total_coach_col(i).created_date, total_coach_col(i).closed_date);
IF (no_of_seconds < 14400) THEN
p_count_4 := p_count_4 + 1;
p_count_8 := p_count_8 + 1;
p_count_12 := p_count_12 + 1;
p_count_24 := p_count_24 + 1;
ELSIF (no_of_seconds < 28800) THEN
p_count_8 := p_count_8 + 1;
p_count_12 := p_count_12 + 1;
p_count_24 := p_count_24 + 1;
ELSIF (no_of_seconds < 43200) THEN
p_count_12 := p_count_12 + 1;
p_count_24 := p_count_24 + 1;
ELSIF (no_of_seconds < 86400) THEN
p_count_24 := p_count_24 + 1;
END IF;
END LOOP;
END calc_percnt;I cannot add cursor definition to package because of the following condition:
WHERE created_date >= p_start_date AND created_date < (p_end_date + interval '1' DAY)
it gives me an error: "p_start_date" and "p_end_date" needs to be declared.
p_start_date and p_end_date are parameters that would be passed by the user.
Parameterized cursor to the rescue:
I have changed my cursor definition to:
create or replace
PACKAGE ES_REPORTS AS
CURSOR cur_total_tckt (p_start_date n01.cc_ticket_status_history.created_date%type, p_end_date n01.cc_ticket_status_history.created_date%type)
IS
SELECT t.ticket_id ticket_id , t.created_date created_date, t.created_by created_by, t.ticket_status ticket_status, t.last_changed last_changed, h.closed_date
FROM n01.cc_ticket_info t
inner join
(SELECT ticket_id , MAX(created_date) closed_date
FROM n01.cc_ticket_status_history
WHERE ticket_status = 'CLOSED' AND created_date >= p_start_date AND created_date < (p_end_date + interval '1' DAY)
GROUP BY ticket_id
) h
on (t.ticket_id = h.ticket_id)
WHERE (t. ticket_status = 'NOTIFIED' OR t.ticket_status = 'CLOSED') AND t.last_changed >= p_start_date AND t.last_changed < (p_end_date + interval '1' DAY);
END ES_REPORTS;
Not sure if it is good programing practice though? -
ORA-00060: deadlock detected while waiting for resource CLOSE cursor
Hi,
I am a new member of this forum. I am working with a problem we got a few weeks ago. It is from a Pro C batch executable running on 10 threads dealing with >800 data accessed from multiple tables. The error as reported came from a package.function call.
This is the error I encountered:
process_item~G****, D***~-60~ORA-00060: deadlock detected while waiting for resource~PACKAGE ERROR = CLOSE cursor C_***** in package R***.I*** 7641
The cursor is a simple SELECT cursor without Table or Record locking.
My questions are:
*Upon the occurrence of this error, is the execution already at the CLOSE cursor line or did the error occurred between the OPEN cursor and the CLOSE cursor? There are several lines of code in between OPEN and CLOSE:
- one that calls for a package.function that simply stores parameter values to a variable
- another one which fetches the cursor. The group that holds the cursor values is only used by a single function in the package
*Is it possible for this CLOSE cursor to cause a deadlock? What could have caused this?
*From what I know, Oracle deals with deadlocks by aborting the deadlocking process while others continue, but this deadlock caused our program to hang. How is this possible? Could the root cause of the deadlock be from our threading program? This is a rare occurrence and happened only twice this year.
Thanks,
RafRaf Serrano wrote:
Hi,
I am a new member of this forum. I am working with a problem we got a few weeks ago. It is from a Pro C batch executable running on 10 threads dealing with >800 data accessed from multiple tables. The error as reported came from a package.function call.
This is the error I encountered:
process_item~G****, D***~-60~ORA-00060: deadlock detected while waiting for resource~PACKAGE ERROR = CLOSE cursor C_***** in package R***.I*** 7641
The cursor is a simple SELECT cursor without Table or Record locking.
My questions are:
*Upon the occurrence of this error, is the execution already at the CLOSE cursor line or did the error occurred between the OPEN cursor and the CLOSE cursor? There are several lines of code in between OPEN and CLOSE:
- one that calls for a package.function that simply stores parameter values to a variable
- another one which fetches the cursor. The group that holds the cursor values is only used by a single function in the package
*Is it possible for this CLOSE cursor to cause a deadlock? What could have caused this?
*From what I know, Oracle deals with deadlocks by aborting the deadlocking process while others continue, but this deadlock caused our program to hang. How is this possible? Could the root cause of the deadlock be from our threading program? This is a rare occurrence and happened only twice this year.
Thanks,
RafSELECT (without FOR UPDATE) statements are never involved in ORA-00060.
only DML statements throw ORA-00060 error -
Hi,
I am new to Ref Cursor concepts and I am trying a small block but its throwing error. Pls help me.
PACKAGE SPEC:
CREATE OR REPLACE PACKAGE PKG_JOBINFO AS
PROCEDURE JOBINFO ( v_job_id IN number, p_cursor OUT PKG_JOBINFO.RESULT_REF_CURSOR);
TYPE RESULT_REF_CURSOR IS REF CURSOR;
END PKG_JOBINFO;
PACKAGE BODY:
CREATE OR REPLACE package body PKG_JOBINFO
AS
PROCEDURE JOBINFO ( v_job_id IN number,
p_cursor OUT PKG_JOBINFO.RESULT_REF_CURSOR)
AS
BEGIN
OPEN p_cursor FOR
SELECT JOB_ID,
JOB_NAME,
TABLE_NAME
FROM JOB_INFO
WHERE JOB_ID=V_JOB_ID;
EXCEPTION
WHEN OTHERS THEN
raise;
END;
END;
While compiling the package i am not getting any errors. I am getting errors only while executing
SQL> exec PKG_JOBINFO.JOBINFO ('23');
BEGIN PKG_JOBINFO.JOBINFO ('23'); END;
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'JOBINFO'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Please help me to resolve this error.
Thanks.user497267 wrote:
Thanks its working. So if we are using ref cursor we have to execute like this only.To add...
The actual issue you were experiencing was not because you were using ref cursors specifically, but because you had an OUT parameter in your procedure.
When you have an OUT parameter, you need to ensure that you pass in a variable to that parameter of the procedure in order that the procedure can populate it. In your case you were only passing in the first parameter, but you weren't passing in a variable to capture the OUTput.
What Alex showed was that by declaring a variable of the same datatype (ref cursor in your case) and passing that in as the second parameter, that variable was populated with the ref cursor information from inside the procedure. Once that variable was populated, after the procedure call, the data from that ref cursor can be obtained (using SQL*Plus' print command in Alex's example). -
I am trying to use a package constant in a query as follows:
SELECT field1 FROM table t WHERE CEIL(sysdate - t.field2) > schema.package.constant
field1 is a name
field2 is a timestamp
constant is an integer indicating the expiration time in days
basically I am trying to find all expired items.
I get the error "ORA-06553: PLS-221: 'constant' is not a procedure or is undefined" on this query.
I use this same query as a cursor in the package itself with no errors.Unfortunately you cannot directly use package global variables in select statements like this.
One workaround is to use bind variables for that:
<p>
SQL> CREATE OR REPLACE PACKAGE pkg
AS
myconstant VARCHAR (20) := 'This is my constant';
END pkg;
Package created.
SQL> VAR myconstant VARCHAR2 (20)
SQL> EXEC :myconstant := pkg.myconstant
PL/SQL procedure successfully completed.
SQL> SELECT :myconstant
FROM DUAL
:MYCONSTANT
This is my constant -
Help plss Should a cursor be created in database or program unit in forms l
Where can i create a cursor should it be in database i.e isql plus using internet explorer or should i create the cursor in forms
forms can i create the cursor so that i can use the cursor in the post item trigger of the userid item of login page
Can i create the cursor in a package specification and how can i call that cursor into a post_text item trigger
details below
Iam working on a Online exam for students Dummy project using forms
The student 1st comes to a WELCOME page i.e form which asks him if he is a new student or registered stud
If he clicks registered pushbutton it takes him to a LOGIN page where there are two items userid and password.I am using a Validate_item OR Post_item trigger to fire after the student enters his userid.
I need to compare the entered userid with the userid stored in the database STUDENTS table which i created which consists of the registered students details.
Our project Guide suggested that we create a cursor and fetch each userid everytime into the cursor and compare the entered userid with the cursor.hi Sqlstar,
Regarding to your all questions , i prefered that you search for a simple document or book in order to understand much more more about creating cursors.
however since this forum made to help people and to make a integerated community i would be glad to offer my help and going with you step bt step with your answers.
as for beginning
1) when you create the user_exists function in database , if you want to call it in the form level you would wirte a code like this
----WHEN-VALIDATE-ITEM------------user_id item---------
IF scheme_name.procedure_name(:block1.userid)!='TURE' then
message('User Name is not correct');
raise form_trigger_failure;
end if;
2) it's not a waste of recourse to make 2 validation of both userid and password
and as same you create a procedure for useris you should create a procedure for password where the user id is the outcomming of userid item in the form.
3)you have all choices to create the 2 procedures on database side or in the program unit at design time for the form it's up to you and as a small hint for you ,
when you create them in the program unit and want to call the procedures in the WHEN-VALIDATE-ITEM trigger you should denote the procedure name with the name of package first as following
-------[Package Spec Code]-------
PACKAGE user_validation IS
function user_exists (p_user_id number) return boolean;
end ;
--------------[Package Body Code]------
PACKAGE BODY user_validation IS
function user_exists (p_user_id number) return boolean
is
user_number number;
cursor c_user_id is
select user_id from <user_table>
where user_id=p_user_id;
begin
open c_user_id ;
loop
fetch user_id into user_number ;
return (true);
exit when c_user_id%NOTFOUND;
end loop;
execption when others then
return(false);
end user_exists;
end;
-----Calling at Validation level-----------
IF (user_validation.user_exists(:block1.userid))!=TURE then
message('User Name is not correct');
raise form_trigger_failure;
end if;
i hope this could be helpful engouh to start your application
Good Luck .
Regards
Omar
Maybe you are looking for
-
Can't update my iPod Touch to 3.1 (Windows 7 here). Help
Every time I try to update my iPod Touch to 3.1 it says that an error occurred (says "error 14) and then I can't update my iPod. It is now useless without any system. Help!!! BTW, I'm on Windows 7.
-
Creation of Tree View in CRM web ui
Hi All, How to create a Tree View in CRM web ui.Please let me know the step by step procedure. Thanks, Santhosh.
-
How to pass a presentation variable to a stored procedure?
Hi All, We have a complex security model to emulate. In order to achieve that, we need to find a way for OBI to run and pass parameter to a stored procedure (SP). "APlus_BI_EmplName2" is the name of the stored procedure. This SP requires a param and
-
PLD-"Formula Type Calculation Fields in Repetitive Area"
Hi there... I just would like to know if there is a limit as to the number of conditional operations in the repetitive area? Im currently working on the General Ledger in the Financial Reports. Our client wants to limit the number of decimal places
-
Firefox 3.6.13 won't install on my MacBook Air
When I attempt to install 3.6.13, I get a message that I lack the permissions for some of the elements.