Home » SQL & PL/SQL » SQL & PL/SQL » how to write a procedure for this condition
how to write a procedure for this condition [message #400990] Thu, 30 April 2009 23:37 Go to next message
Messages: 1
Registered: May 2008
Location: MUMBAI
Junior Member
i have one table with columns v_sub,v_visit and v_date and the structure is like this.

v_sub v_visit v_date
1 visit-1 01-mar-09
1 visit-2 05-mar-09
1 visit-3 17-mar-09
2 visit-1 04-feb-09
2 visit-2 12-mar-09
2 visit-3 20-mar-09

i want to write a procedure which check weather it is in chronological order or not.(for v_sub,v_visit and v_date should be in chronological order as above)

i want to check for v_sub if v_visit is visit-1 and v_date is 01-mar-09 then for visit-2 the v_date should be after 01-mar-09.

Thanks in advance
Re: how to write a procedure for this condition [message #400994 is a reply to message #400990] Thu, 30 April 2009 23:42 Go to previous messageGo to next message
Messages: 25531
Registered: January 2009
Location: SoCal
Senior Member
You need to help us by following the Posting Guidelines as stated below.


Please, please, please Read & Follow Posting Guidelines above.

Go to the section labeled "Practice" & do as directed.

Post DDL for tables.

Post DML for test data.

Post expected/desired results.

Re: how to write a procedure for this condition [message #401013 is a reply to message #400990] Fri, 01 May 2009 01:52 Go to previous message
Michel Cadot
Messages: 65084
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter), use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Post a working Test case: create table and insert statements along with the result you want with these data.

Have a look at LAG/LEAD functions to compare current a row with the previous/next one.

Previous Topic: Group Function with Analytic function
Next Topic: Delete duplicate rows
Goto Forum:

Current Time: Sat Jul 22 22:24:17 CDT 2017

Total time taken to generate the page: 0.11045 seconds