closing unused RODBC handle

user2480137 picture user2480137 · Jun 21, 2013 · Viewed 16.3k times · Source

I have been receiving a Warning Message:

`historicalHourly <- importHistoricalHourly(startDatePast,endDatePast,Markets,location)
[1] "Importing Hourly Data"
[1] "Flag - Moving from importHistoricalHourly to CleaningUpHourly"
[1] "Flag - Moving to importHistoricalDaily from CleaningUpHourly"Warning messages:

1: closing unused RODBC handle 41 
2: closing unused RODBC handle 40 
3: closing unused RODBC handle 36` 

In the function, everything checks out as far as return values, print statements. I have an idea that it is definitely a warning due to this function:

hHourly.df <- retrievelim(PowerCodeID,columns,startDatePast,endDatePast,unitstr="Hours")

which is accessing a separate database in another program. This function is returning a dataframe of dateTime Values by the hour with different numeric values in the next column

If anyone could give me an idea about why it is closing the database and what is happening, I would greatly appreciate it.

Answer

Se&#241;or O picture Señor O · Jun 21, 2013

It's because that function contains odbcConnect(...) without odbcClose(...) as joran suggests. Since the odbcConnect object is created within the function, it is pending deletion the next time there's a garbage collection (?gc). Sometimes that happens when you call the function, sometimes it happens later.

When an odbcConnect object gets deleted by gc(), it closes the database connection and displays a message. Nothing to worry about.