Home » Developer & Programmer » Forms » if comes after commit (oracle 9.2.0.1 forms 6i win xp)
icon10.gif  if comes after commit [message #334333] Wed, 16 July 2008 04:06 Go to next message
seyed456
Messages: 220
Registered: May 2008
Location: south india .
Senior Member

hello all,

i have created a form named enroll ,in this the control is not getting into if loop when the situation happens after commit statement.

if user gives the exam date same as enrollmentdate (assigned as sysdate) then control not entering into red colored if stmt.
pls help me.

  DECLARE
             v_status char(1) := 'N';
             v_courseid number;
             a number;
         
       
 BEGIN
     
         IF :exam_date IS NULL
   THEN
      MESSAGE ('enter the Exam date');
   
   ELSIF :course IS NULL
   THEN
      MESSAGE ('select the coursename');
   ELSIF :exam_paper IS NULL
   THEN
      MESSAGE ('select the exam paper');
   END IF;
 
 
         SELECT course_id
     INTO v_courseid
     FROM online_course
     WHERE course = :block3.course
     AND exam_paper = :block3.exam_paper;

 if :exam_date  >=  to_date(sysdate,'dd-mon-yyyy') then
   
   INSERT INTO onlin_enroll(exam_id, user_name, course_id, exam_date,enrollment_date, status)
   VALUES(exa_id_seq.nextval, :global.abc, v_courseid, :exam_date,sysdate, v_status);
    commit;
   [COLOR=red]if :exam_date = to_date(sysdate,'dd-mon-yyyy') then
     call_form('E:\STUDENTS\STUDENTPROJECT\online1\qns');  
  else
        a:=show_alert('alert_reg');
  end if;[/COLOR]  
  else
    a:= show_alert('alert_exam');
end if;


         exception
             when others then
     
         a:=show_alert('alert_error');	
END;



thanks in advance
Re: if comes after commit [message #334337 is a reply to message #334333] Wed, 16 July 2008 04:16 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
to_date(sysdate, 'dd-mm-yyyy')

Why do you want to convert a date (sysdate) to a date (to_date)?

Remove that stupid, unnecessary, buggy and mischieving exception handler.
If you don't plan to handle the exception, then you should not catch it either.
Do NOT use when others until you understand why I told you to not use it.
Re: if comes after commit [message #334338 is a reply to message #334337] Wed, 16 July 2008 04:25 Go to previous messageGo to next message
seyed456
Messages: 220
Registered: May 2008
Location: south india .
Senior Member

hey frank,

im checking examdate with sysdate ,
sysdate has hours mins n seconds ,. but i created a examdate in 'dd-mon-yyyy' format.

insertion s fine
but i cudnt able to call a form QNS ..


Re: if comes after commit [message #334340 is a reply to message #334338] Wed, 16 July 2008 04:34 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
If you want to discard the time-part of sysdate (i.e. set it to 00:00:00, since an Oracle date ALWAYS has a time-part), you should use a function that does so. For example trunc.
to_date(sysdate, 'dd-mm-yyyy') is plain wrong. Since to_date requires a string as first argument, it does an implicit conversion of the date sysdate to a string. For that it uses the default date-format, which could give you all sorts of trouble.
Re: if comes after commit [message #334345 is a reply to message #334340] Wed, 16 July 2008 04:48 Go to previous messageGo to next message
seyed456
Messages: 220
Registered: May 2008
Location: south india .
Senior Member

i will do use truncate function ..
if exam_date = sysdate then im
inserting data into onlin_enroll table
after that im calling the form qns ...

but it cudnt call that form just giving message "no changes to save"

Re: if comes after commit [message #334355 is a reply to message #334345] Wed, 16 July 2008 05:04 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Please stick to normal English.

Did you remove the exception handler like I advised you?
The message is caused by your "commit"
Re: if comes after commit [message #334359 is a reply to message #334355] Wed, 16 July 2008 05:09 Go to previous messageGo to next message
seyed456
Messages: 220
Registered: May 2008
Location: south india .
Senior Member

i removed exception handler .

i written the following code but still i cudnt have to call form QNS.
DECLARE
   v_status     CHAR (1) := 'N';
   v_courseid   NUMBER;
   a            NUMBER;
BEGIN
   IF :exam_date IS NULL
   THEN
      MESSAGE ('enter the Exam date');
   ELSIF :course IS NULL
   THEN
      MESSAGE ('select the coursename');
   ELSIF :exam_paper IS NULL
   THEN
      MESSAGE ('select the exam paper');
   END IF;

   SELECT course_id
     INTO v_courseid
     FROM online_course
    WHERE course = :block3.course AND exam_paper = :block3.exam_paper;

   IF :exam_date > TRUNC (SYSDATE)
   THEN
      INSERT INTO onlin_enroll
                  (exam_id, user_name, course_id, exam_date,
                   enrollment_date, status
                  )
           VALUES (exa_id_seq.NEXTVAL, :GLOBAL.abc, v_courseid, :exam_date,
                   SYSDATE, v_status
                  );

      COMMIT;
   ELSIF :exam_date = TRUNC (SYSDATE)
   THEN
      INSERT INTO onlin_enroll
                  (exam_id, user_name, course_id, exam_date,
                   enrollment_date, status
                  )
           VALUES (exa_id_seq.NEXTVAL, :GLOBAL.abc, v_courseid, :exam_date,
                   SYSDATE, v_status
                  );

      MESSAGE ('hello');
      CALL_FORM ('E:\STUDENTS\STUDENTPROJECT\online1\qns');
      COMMIT;
   ELSIF :exam_date < TRUNC (SYSDATE)
   THEN
      a := SHOW_ALERT ('alert_exam');
   ELSE
      NULL;
   END IF;
END;
Re: if comes after commit [message #334382 is a reply to message #334333] Wed, 16 July 2008 06:09 Go to previous message
seyed456
Messages: 220
Registered: May 2008
Location: south india .
Senior Member

i resolved the problem ,

thanks for your support frank. ..
Previous Topic: Clearing the data when i change value in LOV
Next Topic: pass a built-in function in a variable
Goto Forum:
  


Current Time: Tue Dec 06 02:43:24 CST 2016

Total time taken to generate the page: 0.13099 seconds