Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error - Potentially on conversion of fields while fetching. #32

Open
jfontestad opened this issue Oct 25, 2017 · 6 comments
Open

Error - Potentially on conversion of fields while fetching. #32

jfontestad opened this issue Oct 25, 2017 · 6 comments

Comments

@jfontestad
Copy link

jfontestad commented Oct 25, 2017

I am assuming that it is trying to convert the fetched fields into another data-type, rather than the data type per the database. In the code below, paidAmt is of data type decimal(19,2).

R Code:

selectQry <- "SELECT TOP 10 claimType, transType, paidAmt FROM tmpRx_01"
res <- dbSendQuery(conn, selectQry)
dsResults <- dbFetch(res)
dbClearResult(res)
dbDisconnect(conn)

Error:

Error in (function ()  : 
  clr_obj_ms_convert_to_SEXP: COM variant type code 14 unsupported. Returning NULL
Error in clrCall(res.Dict, "get_Item", Cnames[i]) : 
  Type:    RDotNet.EvaluationException
Message: Error in (function ()  : 
  clr_obj_ms_convert_to_SEXP: COM variant type code 14 unsupported. Returning NULL

Method:  RDotNet.ProtectedPointer evaluateCall(IntPtr)
Stack trace:
   at RDotNet.Function.evaluateCall(IntPtr call)
   at RDotNet.Function.createCallAndEvaluate(IntPtr argument)
   at Rclr.RDotNetDataConverter.CreateClrObj(Object obj) in c:\Users\per202\AppData\Local\Temp\RtmpuMBMYA\R.INSTALL2164365a3840\rClr\src\ClrFacade\RDotNetDataConverter.cs:line 603
   at Rclr.RDotNetDataConverter.TryConvertToSexp(Object obj) in c:\Users\per202\AppData\Local\Temp\RtmpuMBMYA\R.INSTALL2164365a3840\rClr\src\ClrFacade\RDotNetDataConverter.cs:line 320
   at Rclr.RDotNetDataConverter.ConvertToSexp(Object obj) in c:\Users\per202\AppData\Local\Temp\RtmpuMBMYA\R.INSTALL2164365a3840\rClr\src\ClrFacade\RDotNetDataConverter.cs:line 369
   at Rclr.RDotNetDataConverter.ConvertAll(Object[] objects, Func`2 converter) in c:\Users\per202\AppData\Loca
@jfontestad
Copy link
Author

When the paidAmt field is removed from the query, then the results are delivered as expected.

@jfontestad
Copy link
Author

I changed the paidAmt field to datatype money, as well as numeric, and still am getting the same error.

@ruaridhw
Copy link
Collaborator

ruaridhw commented Oct 26, 2017

This has been covered in #22 and #26. The underlying package rClr doesn't support these datatypes.

This is easily fixed with a CAST statement otherwise see the workaround provided by rsqlserver

selectQry <- "SELECT TOP 10 claimType, transType, CAST(paidAmt AS float) FROM tmpRx_01"

@ghost
Copy link

ghost commented Jan 4, 2018

Agreed that casting would fix this. There are 3 solutions besides a manual cast

  1. automatic conversion with 3 small tweaks to rsqlserver
  2. executing a stored proc that coverts decimal, numeric, and money columns automatically
  3. rclr

I've tested the first two successfully for decimal and money, and emailed one of the contributors to see how to get this reviewed for approval and released.

I also am trying to figure out how to modify rClr as well, and work with that package for potentially adding other R functionality in the future.

@ruaridhw
Copy link
Collaborator

ruaridhw commented Jan 5, 2018

If you want to get anything added to this package just fork the package, create a new branch and submit a pull request :)

Would be great to have a better solution to this!

@ghost
Copy link

ghost commented Jan 5, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants