Find the Next available date which is not necessarily the Maximum Date

Morning folks!
I am trying to find the next scheduled appointment date (Including any day after today) for a patient which may not be the maximum date for that person. I am trying to do this in Oracle Forms. My Query is working in SQL*Plus but is not working in Forms.
FUNCTION get_next_sched_date(P_PATIENT_ID in varchar2) RETURN DATE IS
  v_next_scheduled_date   patient_visit.target_date%TYPE;
BEGIN
  select next_target_date into v_next_scheduled_date
  from   ( select v.*, max(target_date) over (partition by patient_id) max_target_date,
                       lead(target_date) over (partition by patient_id order by target_date) next_target_date
           from   patient_visit v)
  where  patient_id = P_PATIENT_ID
  and    next_target_date >= SYSDATE
  and    max_target_date > next_target_date;
  return( v_next_scheduled_date );
EXCEPTION
   when NO_DATA_FOUND then
     return(NULL);
When I compile this in Oracle Forms, it gives me an Error.Encountered the symbol "(" when expecting one of the following: ,from.
I also noticed that Oracle Forms is not liking keywords such as LAG and LEAD. I am working on Oracle Forms 9i.
Any idea what I am doing wrong here? Thanks for listening to my Monday harping. :-)
Forms [32 Bit] Version 9.0.4.0.19 (Production)
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit ProductionEdited by: Roxyrollers on Aug 27, 2012 8:43 AM
Edited by: Roxyrollers on Aug 27, 2012 8:46 AM

Thanks.
For now, I have another simpler solution. I was just curious if the first way would have worked.
select MIN(target_date) into v_next_scheduled_date from patient_visit v1
where  patient_id = P_PATIENT_ID
and    target_date >= SYSDATE
and    target_date <= (select MAX(target_date) from patient_visit v2
                       where  v2.patient_id = v1.patient_id);Edited by: Roxyrollers on Aug 27, 2012 9:16 AM

Similar Messages

  • CD-ROM drive letter changed to the next available letter after an issue with the Storage appliance.

    Server platform:Windows server 2008 R2 Enterprise.
    Last time we experienced an issue with the storage device we are using to  attach a disk to our server 2008 (virtual). This storage device is also providing storage to the ESX where the server 2008 is hosted.
    The drive configuration in the server was:
    System C:\
    Tools D:\
    Apps E:\
    CD-ROM F:\
    Some hours after the storage appliance issue, we realized the Application on the server was not working and then we restarted the server. After restarting the server we went to the file explorer and realized that the Apps volume had the drive letter F and
    the CD-ROM had the E letter assigned.
    I assume windows lost the Apps disk due to the SAN disconnection. Maybe the CD-ROM was also disconnected and when the Storage appliance was connected again the CD-ROM acquire the next drive letter it found, which was the letter E:. Then the Apps disk was
    also discovered by Windows and it assigned the next available letter, F:.
    I was looking for some MS knowledge base to see how Windows 2008 server assigns the letter to the CD-ROM and how we can permanently fix the letter assigned to the disks and the CD-ROM so that this issue won't happen again. As you know many applications use
    the path including the drive letter.
    I thought that when you set a CD-ROM drive letter, it remains forever as is, and that in case of a SAN disconnection Windows assigns the same letter the drive had before the disconnection.
    Please advice if you have some documentation about this. And let me know if you have any thoughts about what really happened to prevent this in the future.
    Thank you guys!! 

    Hi, for the APP's drive it could had been assigned a new letter if the system did seen it as a new disk/partition.
    The partition was on your esx's LUN on the SAN ? (not an iSCSI connection from inside a VM?)
    Regards, Philippe
    Don't forget to mark as answer or vote as helpful to help identify good information. ( linkedin endorsement never hurt too :o) )
    Answer an interesting question ? Create a
    wiki article about it!

  • I would like to format cells with time only.  when I enter a time of day the current date is still in the cell which is not necessarily so

    I would like to format cells with time only.  when I enter a time of day the current date is still in the cell which is not necessarily so.  THere are  no options for just  date .

    christine275 wrote:
    ... (this is a time worked by date and not always entered on the date worked)--
    "Time" in Numbers is always "Time of Day", and is always part of a Date and Time value. "Amount of Time" is a Duration value, which may be displayed in a similar format to "Time of Day," but is a different type of value.
    If you are entering the number of hours and minutes worked, format the column as Duration, set the units and the format in which you want to have the value appear.
    The Date column will still contain a Date and Time value (Jan 1, 2011 00:00:00 in the cell shown in the example), but the "Time Worked" cells will contain only a Duration value.
    Incidently, the Date in A2 was entered as "jan 1" (without the quotes). Numbers automatically adds the current year and the default time value, then displays the result in the closest format to what you've entered, or in the Date and Time format you have chosen.
    The Duration value in B2 was entered as 3:15 (as displayed). Note that in the entry bar the duration is displayed as 3h 15m, probably to distinguish it from a similarly formatted (Date and) Time value.
    Regards,
    Barry

  • HT4623 I am updating my school's operating system for my iPads.  I have been able to complete 2 carts of 30 (60 total). The next cart I was able to download the IOS6.3.1 update but it states the install is not available. Good internet connection.

    I am updating my school's operating system for my iPads.  I have been able to complete 2 carts of 30 (60 total). The next cart I was able to download the IOS6.3.1 update but it states the install is not available. Good internet connection.  Please advise.....
    Thanks!

    Hi nytesinger,
    Welcome to the Support Communities!
    The article below may be able to help you with this issue.
    Click on the link to see more details and screenshots. 
    Apple Configurator Help: About Apple Configurator
    http://help.apple.com/configurator/mac/1.3/#cadf1802aed
    Apple Configurator Help: Prepare devices
    http://help.apple.com/configurator/mac/1.3/#cad96c7acd6
    Cheers,
    - Judy

  • How to show the next available number to populate

    I have a page which displays all of my columns.
    My second column are numbers. If the 3rd column is filled in, the data on all of the columns will be displayed including the 2nd column on this page.
    If the 3rd column is not filled in yet, only the next number of the 2nd column will be displayed somewhere on the page together with the rest of the data mentioned above. This number will be the next higher available number, or in other words, the next lowest number without something filled in for the 3rd column.
    So when I click on this number, I can go to the next page to at least populate column 3. Thanks.

    Let me see if I can explain better.
    I have a table with all fields displayed including the edit icon on the left.
    Let me see if I can illustrate this. Let the capital letters be columns of this table.
    And let the data be as shown under the lettered columns. Here is a hypothetical sample of the data. The ...... is just to make the spacing happen for the columns to line up in this example
    ..... A B C D E.........F
    edit 1 7 .c .d e 01-MAY-2008
    edit 1 8 .c .d e 02-MAY-2008
    edit....9...........-- would like to display this line
    I would like to display the next available number for column B (in this case number 9 since it is after 8) for me to be able to edit by filling in data in the rest of the columns.
    Now, for column B, I have number 9 all the way to say, 1000 available in the database but with no other data, just the number itself existing. Because these numbers (like 9) in column B have no data yet in colunm C, it will not be displayed in the table because there is no data to look at.
    So after I can add data to column C and maybe other columns, then when I apply changes will #9 and its data show up in the table after data 8 and then #10 will show up as the next number available to receive data where 9 use to appear.
    I hope this clarified it.

  • Need help in laoding flat file data, which has \r at the end of a string

    Hi There,
    Need help in loading flat file data, which has \r at the end of a string.
    I have a flat file with three columns. In the data, at the end of second column it has \r. So because of this the control is going to the beginning of next line. And the rest of the line is loading into the next line.
    Can someone pls help me to remove escape character \r from the data?
    thanks,
    rag

    Have you looked into the sed linux command? here are some details:
    When working with txt files or with the shell in general it is sometimes necessary to replace certain chars in existing files. In that cases sed can come in handy:
    1     sed -i 's/foo/bar/g' FILENAME
    The -i option makes sure that the changes are saved in the new file – in case you are not sure that sed will work as you expect it you should use it without the option but provide an output filename. The s is for search, the foo is the pattern you are searching the file for, bar is the replacement string and the g flag makes sure that all hits on each line are replaced, not just the first one.
    If you have to replace special characters like a dot or a comma, they have to be entered with a backslash to make clear that you mean the chars, not some control command:
    1     sed -i 's/./,/g' *txt
    Sed should be available on every standard installation of any distribution. At lesat on Fedora it is even required by core system parts like udev.
    If this helps, mark as correct or helpful.

  • I have iMovie 09. I just erased my external hard drive, but it is still formatted for the mac. However, iMovie will not recognize the hard drive. It shows the only hard drive available is the computers. How do I get the external hard drive to show up?

    I have iMovie 09. I just erased my external hard drive, but it is still formatted for the mac. However, iMovie will not recognize the hard drive. It shows the only hard drive available is the computers. How do I get the external hard drive to show up?

    In Finder's Menu, select Go menu>Go to Folder, and go to "/volumes". (no quotes)
    Volumes is where an alias to your hard drive ("/" at boot) is placed at startup, and where all the "mount points" for auxiliary drives are created for you to access them. This folder is normally hidden from view.
    Drives with an extra 1 on the end have a side-effect of mounting a drive with the same name as the system already think exists. Try trashing the duplicates with a 1 or 2 if there are no real files in them, and reboot.
    If it does contain data...
    http://support.apple.com/kb/TS2474

  • Iphoto6: several issues: 1st my library is so messed up, everytime I delete a photo, in the next moment I look at a file the deleted photo has quadrupled, as with files, dates wrong

    iphoto6: several issues: 1st my library is so messed up, everytime I delete a photo, in the next moment I look at a file & the deleted photo has quadrupled, as with files, dates are all wrong, missing a few years.............

    Sounds like your database is damaged.
    Try these in order - from best option on down...
    1. Do you have an up-to-date back up? If so, try copy the library6.iphoto file from the back up to the iPhoto Library allowing it to overwrite the damaged file.
    2. Download iPhoto Library Manager and use its rebuild function. This will create a new library based on data in the albumdata.xml file. Not everything will be brought over - no slideshows, books or calendars, for instance - but it should get all your albums and keywords back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one.  
    3. If neither of these work then you'll need to create and populate a new library.
    To create and populate a new *iPhoto 6* library:
    Note this will give you a working library with the same Rolls and pictures as before, however, you will lose your albums, keywords, modified versions, books, calendars etc.
    Move the iPhoto Library to the desktop
    Launch iPhoto. It will ask if you wish to create a new Library. Say Yes.
    Go into the iPhoto Library on your desktop and find the Originals folder. From the Originals folder drag the individual Roll Folders to the iPhoto Window and it will recreate them in the new library.
    When you're sure all is well you can delete the iPhoto Library on your desktop.
    In the future, in addition to your usual back up routine, you might like to make a copy of the library6.iPhoto file whenever you have made changes to the library as protection against database corruption.
    Regards
    TD

  • How to delete images from folder which are not in the database

    I am created windows form
    i wont to delete images from the folder where i have stored images but i only want to delete those images which are not in the data base.
    i don't know how it is possible . i have written some code
    private void button1_Click(object sender, EventArgs e)
    string connectionString = "Data Source";
    conn = new SqlConnection(connectionString);
    DataTable dt = new DataTable();
    cmd.Connection = conn;
    cmd.CommandText = "select * from tbl_pro";
    conn.Open();
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    da.Fill(dt);
    int count = Convert.ToInt32( dt.Rows.Count);
    string[] image1 = new string[count];
    for (int i = 0; i < count; i++)
    image1[i] = dt.Rows[i]["Image1"].ToString();
    string[] image2 = new string[count];
    for (int i = 0; i < count; i++)
    image2[i] = dt.Rows[i]["Image2"].ToString();
    var arr = image1.Union(image2).ToArray();
    string[] arrays;
    String dirPath = "G:\\Proj\\";
    arrays = Directory.GetFiles(dirPath, "*", SearchOption.AllDirectories).Select(x => Path.GetFileName(x)).ToArray();
    int b= arrays.Count();
    for (int j = 1; j <= b; j++)
    if (arrays[j].ToString() != arr[j].ToString())
    var del = arrays[j].ToString();
    else
    foreach (var value in del) // ERROR DEL IS NOT IN THE CURRENT CONTEXT
    string filePath = "G:\\Projects\\Images\\"+value;
    File.Delete(filePath);
    here error coming "DEL IS NOT IN THE CURRENT CONTEXT"
    I have to change anything .Will It work alright?
    pls help me
    Sms

    Hi Fresherss,
    Your del is Local Variable, it can't be accessed out of the if statement. you need to declare it as global variable like below. And if you want to collect the string, you could use the List to collect, not a string.  the string will be split to chars
    one by one.
    List<string> del=new List<string>();
    for (int j = 1; j <= b; j++)
    if (arrays[j].ToString() != arr[j].ToString())
    del.Add(arrays[j].ToString());
    else
    foreach (var value in del)
    string filePath = "G:\\Projects\\Images\\" + value;
    File.Delete(filePath);
    If you have any other concern regarding this issue, please feel free to let me know.
    Best regards,
    Youjun Tang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Itune is telling me I put in the wrong password. Which is not and now itune just reedem my itune card. and Im not able to buy anymusic

    I had created account. I enter my information. I also enter my itune card. After I enter my itune card. It said you can shop now. So, I had went to purchase music. And a box pop up telling me I need to enter my apple Id. I did that and it now say Im enter the wrong password. Which is not. So, how do i fix this problem. Beacuse my itune card is register in there and Im not able to buy music

    I cant find any reciept in my email or in my husbands email.  I am going to attempt to call and speak to someone who can help me because this was not my fault except trying to be normal and update my phone!

  • How to create entity for the table which is not having the primary key

    Hi,
    Is it possible to create an entity for the table which is not having the primary key.
    I have to write a method in my session bean and that method must use this entity.
    any websites for this.

    If you are talking about processes launched from a JVM (running outside), Process is available.
    If you are talking about processes already running outside of a JVM, you could roll-your-own class to provide similar functionality as Process. This approach would be platform dependent, backed by the platform's I/O scripting and therefore limited to what the platform supports for process manipulation, e.g. Linux/Unix capabilities far exceed Windows.

  • Can we add fields in MM17 which are not in the list

    Hi Folks,
    Pls help me on below.
    I want to add below fields in a variant in MM17
    Planned price 1 - MBEW-ZPLP1
    Planned price 2 - MBEW-ZPLP2
    Planned price 3 - MBEW-ZPLP3
    But these fields are not available in the List.
    how can i add them ?

    HI
        Only it is possible what ever the fields and tables available in the transaction.Cannot add any other additional fields which ever not in the transaction.
    Thanks
    Ganesh

  • Am using short keyboard.  Don't know how to create plus sign which is not on the keyboard. Advice would be much appreciated.

    Am using short keyboard.  Don't know how to create plus sign which is not on the keyboard. There is no number pad. Advice would be much appreciated.

    nicholasmitaka-shi wrote:
    This is a Japanese kana input keyboard, A1242, whioch looks quite as usual except that a few functions have no space on the board and have been ommitted. 
    Is the plus sign really not available on your keyboard at the place indicated on this graphic (to the right of the L key)? You might need to use shift or alt/option or shift+alt/option.
    http://en.wikipedia.org/wiki/File:KB_Japanese.svg

  • SSIS The parameterized sql statement yields metadata which does not match the main SQL statement

    Hi all,
    I'm getting the above error when trying to execute a custom lookup.  What I'm trying to do is lookup the minimum promotional price between date ranges.  The SQL executes fine in SSMS
    SELECT refTable.PRICE
    FROM ( SELECT MIN(PRICE) AS PRICE ,
    NAME ,
    ITEMRELATION ,
    FROMDATE ,
    TODATE
    FROM [dbo].[AllCustPrices]
    GROUP BY NAME ,
    ITEMRELATION ,
    FROMDATE ,
    TODATE
    ) [refTable]
    WHERE [refTable].[NAME] = ?
    AND [refTable].[ITEMRELATION] = ?
    AND ? BETWEEN [refTable].[FROMDATE]
    AND [refTable].[TODATE]
    but errors in SSIS?

    Apologies, totally forgot i posted a question on here.  I still haven't resolved this.  full error text is TITLE: Package Validation Error
    Package Validation Error
    ADDITIONAL INFORMATION:
    Error at Data Flow Task [Lookup MIN Price [440]]: The parameterized SQL statement yields metadata which does not match the main SQL statement.
    Error at Data Flow Task [SSIS.Pipeline]: "Lookup MIN Price" failed validation and returned validation status "VS_ISBROKEN".
    Error at Data Flow Task [SSIS.Pipeline]: One or more component failed validation.
    Error at Data Flow Task: There were errors during task validation.
     (Microsoft.DataTransformationServices.VsIntegration)
    BUTTONS:
    OK
    If I take off the MIN function and just put * SSIS is quite happy, it does not like MIN for some reason?
    I'm really stumped with this... checked metadata for third parameter which is W/C Date DT_DBTIMESTAMP which is same as FROMDATE, TODATE where i'm using BETWEEN...

  • I bought an unlocked Iphone 3GS, I needed to update Ios5 and restored the settings for that which was not authorised for unlocke, but after that iphone is not getting activate and no sim card insatlled error is there. i m using local sim card in Pakistan

    I bought an unlocked Iphone 3GS, I needed to update Ios5 and restored the settings for that which was not authorised for unlocke, but after that iphone is not getting activate and no sim card insatlled error is there. i m using local sim card in Pakistan

    You didn't buy an 'unlocked' iPhone 3GS - you bought a 'hacked' one.
    Updating to iOS 5 removed the hack and the unofficial unlock.
    All you can do is try to find out which network the phone is locked to and ask them if they can unlock it properly.
    Otherwise, sell it or throw it away and buy an officially unlocked phone from an official source.

Maybe you are looking for