R and database Roracle - database

I am using Rstudio (or R) with the package ROracle to connect to db. However I have the following error message
Error in .oci.Connect(.oci.drv(), username = username, password = password, :
ORA-12154: TNS:could not resolve the connect identifier specified
One possible solution is to add the following line to the .Renviron file. But I guess my R does not read this file. How can I be sure, or force R to read .Renviron? (I am using Windows.)
Some other suggestion from Oracle are here.
I am so grateful for every hint.

You can read the .Renviron file with the readRenviron function. Just make sure you enter the correct file path.
readRenviron(".Renviron")

Related

error while loading csv file though snlowsql copy into command

i was trying to load csv file from AWS s3 bucket with copy into command in one of the csv file throw error like
End of record reached while expected to parse column
'"RAW_PRODUCTS"["PACK_COUNT_UNITS":25]
and with the VALIDATION_MODE = RETURN_ALL_ERRORS it also give me 2 rows that have error i am not sure what error would be.
my concern is can we get specific error so that we can fix it in file.
You might try using the VALIDATE table function. https://docs.snowflake.com/en/sql-reference/functions/validate.html
Thanks Eda, i already reviewed above link but that did not work with sql query with copy into table from s3 bucket, so i create stage and place that csv file on stage and then try to run that validate command that give me same error row.
there is another way to identify error while executing copy into command you can add VALIDATION_MODE = RETURN_ALL_ERRORS you will get same result.
by the way i resolve error its due to /,, i remove / and it loaded successfully. / or /, is working as it was in other row but /,, did not work.

Snowflake error GsInstance with ID 222673 not in fdb

I got an error "Error - 390410: GsInstance with ID 222673 not in fdb" when trying to run a "CREATE OR REPLACE" command.
I guess that was a temporary issue because this hasn't occurred again, but what does this error mean? Did someone encounter this error and can please help me understand this?
Thanks!
I'd strongly recommend opening a support ticket if your queries are failing and error messages look like "Error - 390410: GsInstance with ID 222673 not in fdb", the ticket should include the Snowflake URL, the queryID of the command, etc... The more info you give support the more easily they can address the issue.
Getting your query_id can be done using either of the following:
via SQL commands:
https://docs.snowflake.com/en/sql-reference/functions/query_history.html
via the webUI:
https://docs.snowflake.com/en/user-guide/ui-history.html
I hope this helps...Rich

Liquibase Stored Procedure

I am trying to call Liquibase Stored Procedure Through Tag
it gives me error as sql code
DB2 SQL Error: SQLCODE=-440, SQLSTATE=42884
I Am Tring to call as follows : :
<sql> CALL TestProcedure('abc','xyz') </sql>
it executed well from outside command line Client and not using liquibase
i also tried calling using schema name no luck Open to suggestions
SQL440N is routine not found. The error message should give the text of the rountine name. Does it match what you have in your database. Is is a case sensitive problem? (i.e. try in upper case?)
SQL0440N No authorized routine named "<routine-name>" of type
"<routine-type>" having compatible arguments was found.

How to fix locale errors in RODBC (WAS: R CMD BATCH: "$ operator is invalid for atomic vectors" but not in Rstudio)

Maybe related: Stack overflow: Windoes does not support UTF-8
I have a script which I can source from Rstudio, but when I try to source it from Rgui.exe or try to BATCH CMD run, I get the following error in my Rout file:
Error in easy_clean$Sv_Karakter: $ operator is invalid for atomic vectors
The reason is that the database table I am quering have a latin charachter 'ø' in its name (se third line below). So the result of my query is this (as per str(easy)):
"";"x"
"1";"42000 102 [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '¸'."
"2";"[RODBC] ERROR: Could not SQLExecDirect 'select *
from PrøveDeltager a
left outer join Aftaler b
ON b.Cpr = a.CPR
LEFT OUTER JOIN GODK c
ON c.GODK_ID = b.GODK_ID
where a.slut >= '20140808'
AND a.slut <='20140818'
AND a.Branche = 'vvs'
AND a.SaleID is not null
AND a.CPR in (select x.CPRNR from Statistik x)
order by Sv_Karakter'"
In rstudio the query works.
Sys.getlocale('LC_CTYPE')returns Danish_Denmark.1252 in both R.gui and Rstudio - so I don't know how to fix this.
I did find this link to developer.r-project which discus windows locales (quite old though).
For now I have created a database view without the 'ø' - that view I can call without problems from R.
From sessionInfo I can say that:
Rstudio R is 64 bit, and R.exe is 32 bit.
Other than that, the only difference is this, for Rstudio:
loaded via a namespace (and not attached): 1 tools_3.1.0
Since I can't write my database credentials, I can't create a reproducible example. But here is the script. http://pastebin.com/XwdZPhL7
Two ways I can imagine that would yield an error with that code: one is if this results in a single column:
easy[!is.na(easy$Sv_Karakter),]
In that case, the result would be a vector because of the default action of the "[" function to create atomic vectors from single column results. The attempts to extract that column would fail with that error. The other case of failure (but perhaps not that error) would be when there was no 'Sv_Karakter' column in the 'easy' dataframe.
Better efforts at documentation by offering str(easy) or dput(head(easy)) are needed.
Your query returned an error message and it was in the form of an R vector. So that explains the particular error. You now need to figure out how your db connection is getting messed up, as Andreas was saying.

Access database in Physionet's ptbdb by Matlab

I set up the system first by
[old_path]=which('rdsamp');if(~isempty(old_path)) rmpath(old_path(1:end-8)); end
wfdb_url='http://physionet.org/physiotools/matlab/wfdb-app-matlab/wfdb-app-toolbox-0-9-3.zip';
[filestr,status] = urlwrite(wfdb_url,'wfdb-app-toolbox-0-9-3.zip');
unzip('wfdb-app-toolbox-0-9-3.zip');
cd mcode
addpath(pwd);savepath
I am trying to read databases from Physionet.
I have successfully reached one database mitdb by
[tm,sig]=rdsamp('mitdb/100',1)
but I want to reach the database ptbdb unsuccessfully by
[tm,sig]=rdsamp('ptbdb/100',1)
and get the error
Warning: Could not get signal information. Attempting to read signal without buffering.
> In rdsamp at 107
Error: Cannot convert to double:
init: can't open header for record ptbdb/100
Error using rdsamp (line 145)
Java exception occurred:
java.lang.NumberFormatException: Cannot convert
at org.physionet.wfdb.Wfdbexec.execToDoubleArray(Unknown Source)
The first error message refers to these lines in rdsamp.m:
if(isempty(N))
[siginfo,~]=wfdbdesc(recordName);
if(~isempty(siginfo))
N=siginfo(1).LengthSamples;
else
warning('Could not get signal information. Attempting to read signal without buffering.')
end
end
This line if(~isempty(siginfo)) is false means that the siginfo is empty that is there is no signal. Why? No access to the database, I think.
I think other errors follow from it.
So the error must follow from this line
[siginfo,~]=wfdbdesc(recordName);
What does the snake mean here in the brackets?
How can you get data from ptbdb by Matlab?
So
Does this error mean that the connection cannot be established to the database?
or
that there does not exists such data in the database?
It would be very nice to know how you can check if you have connection to the database like in Postrgres. It would be much easier to debug.
If you run physionetdb("ptdb",1) it will download the files to your computer. You will then be able to see the available records in the <current-dir>/ptdb/
Source: physionetdb function documentation. You are interested in the DoBatchDownload parameter.
After downloading it, I believe every command from the toolbox will check if you have the files locally before fetching from the server (as long as you give the function the correct path to the local files).
The problem is that the data unit "100" does not exist in the database ptbdb.
I run finally successfully after waiting 35 minutes with 100Mb cable broadband:
db_list = physionetdb('ptbdb')
and get not complete data finally to the patient 54 - there should be 294 patients.
'ptbdb/patient001/s0014lre' 'ptbdb/patient001/s0014lre' ... cut ...
The main developer, Ikaro's' answer helped me to wait so long:
The WFDB Toolbox connects to PhysioNet's file server. The databases
accessible through the WFDB Toolbox are not SQL database, they consist
of flat files. The error message that you are getting regarding the
ptdb/100 database is because you are attempting to get a record that
does not exist on the database.
For more information on a particular database or record in PhysioNet
please type:
help physionetdb
and
physionetdb('ptdb')
This flat file system is really a bottle neck in the system.
It would be a good time to change to SQL.

Resources