Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3437264
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:02:38+00:00 2026-05-18T08:02:38+00:00

I am trying to pull data from our Oracle datamart into R using RODBC.

  • 0

I am trying to pull data from our Oracle datamart into R using RODBC. I have been able to work through some of my issues, but I have one basic question.

How can I retain the formatting as it sits in the database?

Using the following command

uapp <- sqlQuery(ch, SQL, stringsAsFactors=F)

My data are retrieved as expected, but some fields are converted to numeric and logical once in R when they should be characters. I can get around this if I use:

uapp <- sqlQuery(ch, SQL, stringsAsFactors=F, as.is=T)

But I “lose” columns being formatted as dates when I would like them to be.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:02:38+00:00Added an answer on May 18, 2026 at 8:02 am

    You’re caught in a gap I’ve struggled with as well. I can’t opine on what is “right” or “best” but only what I’ve done in the past.

    I usually do what you did in the first example and just deal with type changes once they get into R. If you wanted to do the latter method, you could convert the date once it was in R. My Oracle systems seem to always be set up to return dates in the “22-NOV-10” format which is annoying as heck to parse. So I would use the Oracle to_char() function in my query to format my dates into something R can easily recognize.

    So, for example, I might have this in my SELECT statement:

    to_char(myDate, 'yyyy-mm-dd') as myDate
    

    then I pull that into a data frame called myData and do this:

    myData$properDate <- strptime(myData$myDate, "%Y-%m-%d")
    

    Whether to deal with fixing dates or deal with fixing other fields really depends on how many date fields you have and how many non-date fields the first method messes up. But in my experience I either end up fixing one, or the other.

    Something you might consider when using method 1: Try using cast() in your SQL in order to force a field into a particular type. The only times I’ve had trouble with RODBC molesting my data types is when the type is ambiguous on the server side. This is usually the result of CASE statements or somesuch on the SQL end.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to pull artifacts from teamcity. I've been trying to use c#
Using SQLite3 with Python 2.5, I'm trying to iterate through a list and pull
I am trying to pull some data out of our testing database with an
I am trying to modify a stored procedure I wrote to pull data from
I've generated some JSON and I'm trying to pull it into an object in
I'm trying to use SharpZipLib to pull specified files from a zip archive. All
I'm trying to make a local backup of the data from my Rails application,
I'm trying to make a pull down menu post a form when the user
I'm trying to write a query that will pull back the two most recent
I am trying to write a function that will pull the name of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.