DON"T CHANGE DATE [message #188016] |
Wed, 16 August 2006 14:40 |
sweetgeegee27
Messages: 107 Registered: June 2005
|
Senior Member |
|
|
Hey everybody. I want to amend the script below so that is the document is reprinted, the printed_Date remains the same.
DECLARE
Cursor c_p IS
SELECT printed_date from document where
Doc_type_no = 8
AND assess_no = :assess_no
AND doc_State_no = 2
and tax_payeR_no = :assess.tax_payeR_no;
BEGIN
OPEN c_p;
FETCH c_p INTO :date_printed;
CLOSE C_p;
END;
next_record;
END LOOP;
go_record(1);
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHEN OTHERS THEN
CGTE$OTHER_EXCEPTIONS;
END;
|
|
|
|
|
|
Re: DON"T CHANGE DATE [message #188203 is a reply to message #188020] |
Thu, 17 August 2006 07:38 |
sweetgeegee27
Messages: 107 Registered: June 2005
|
Senior Member |
|
|
First of all it is a database that we use at work and I am fairly new to Oracle, that why I ask questions in the PL/SQL for Newbies forum.
Now, I was thinking of adding piece of code so that if the report is reprinted, the printed_date field won't change. So it should go something like if the printed_date field is not null, do not change it, else put the current date. I just don't know how to add it in the already created script above.
Thanks.
|
|
|
Re: DON"T CHANGE DATE [message #188205 is a reply to message #188203] |
Thu, 17 August 2006 07:45 |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
I'm slightly confused (common occurrence)
The code you posted won't change the data in the database at all.
I'll guess that this a misplaced Forms question, in which case you could try replacing
OPEN c_p;
FETCH c_p INTO :date_printed;
CLOSE C_p;
with IF :date_printed IS NOT NULL THEN
OPEN c_p;
FETCH c_p INTO :date_printed;
CLOSE C_p;
END IF;
which should solve the problem
|
|
|
Re: DON"T CHANGE DATE [message #188209 is a reply to message #188203] |
Thu, 17 August 2006 07:53 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Code you provided is incomplete and doesn't make much sense; why would you want to use a cursor when you only open - fetch - close it? It *should* be used for collection of data, not a single record.
Besides that, there's record navigation (which record? Is this code taken from a form?) which does ... what?
Perhaps such a function might help ... see whether you can use it somewhere (and how) or not.CREATE OR REPLACE FUNCTION fun_print_date (par_report_id IN NUMBER)
RETURN DATE
IS
l_printed_date DATE;
BEGIN
SELECT printed_date
INTO l_printed_date
FROM document
WHERE report_identifier = par_report_id;
RETURN (l_printed_date);
EXCEPTION
WHEN NO_DATA_FOUND THEN
RETURN (sysdate);
END;
|
|
|