SSAS tabular model Value.NativeQuery Faield - google-bigquery

I'm trying to use Value.NativeQuery with ODBC coomection to Big Query And get Error
Original Code:
let
Source = #"Odbc/dsn=Google BigQuery",
#"prod_Database" = Source{[Name="prod",Kind="Database"]}[Data],
default_Schema = #"prod_Database"{[Name="default",Kind="Schema"]}[Data],
DW_DIM_Table = default_Schema{[Name="DW_DIM",Kind="Table"]}[Data]
in
DW_DIM_Table
New Code
let
Source = #"Odbc/dsn=Google BigQuery",
MyQuery = Value.NativeQuery(#"Odbc/dsn=Google BigQuery", "SELECT * FROM `default`.DW_DIM")
in
MyQuery
Error:
The query statement is not valid.
When I'm trying Put the statement to Power Query Editor:
= Value.NativeQuery(#"Odbc/dsn=Google BigQuery", "SELECT * FROM `default`.DW_DIM")
get Error
Expression.Error: Native queries aren't supported by this value.
Details:
Table

I had the same error with Athena ODBC (which is also a Simba Driver) but was able to work around it by using "Odbc.Query".

Related

Getting "Method executeQuery cannot be used for update" for NOT update queries

I try to retrieve information about databases and tables of a DB2 System.
The kotlin application successfully connects with the database but when I execute a query (see code below) I always get the error message "Method executeQuery cannot be used for update" even though I do not execute an update query.
connection = DriverManager.getConnection(config.connectionString)
val statement: Statement = connection!!.createStatement()
val query = "DISPLAY DATABASE"
//val query = "LIST TABLES"
val resultSet: ResultSet = statement.executeQuery(query)
Error message:
com.ibm.db2.jcc.am.SqlException: [jcc][10103][10941][4.29.24] Method executeQuery cannot be used for update. ERRORCODE=-4476, SQLSTATE=null"
Can someone tell me what I'm doing wrong?

R-SQL Invalid value from generic function ‘fetch’, class “try-error”, expected “data.frame”

I am having a problem to fetch some data from database using ROracle. Everything works perfect (I am getting the data from different tables without any problem), but one of the tables throws an error:
library(ROracle)
con <- dbConnect(dbDriver("Oracle"),"xxx/x",username="user",password="pwd")
spalten<- dbListFields(con, name="xyz", schema = "x") # i still get the name of the columns for this table
rs <- dbSendQuery(con, "Select * From x.xyz") # no error
data <- fetch(rs) # this line throws an error
dbDisconnect(con)
Fehler in .valueClassTest(ans, "data.frame", "fetch") : invalid
value from generic function ‘fetch’, class “try-error”, expected
“data.frame”
I followed this question: on stackoverflow, and i selected the columns
rs <- dbSendQuery(con, "Select a From x.xyz")
but none of it worked and gave me the same error.
Any ideas what am I doing wrong?
P.S. I have checked the sql query in Oracle SQL Developer, and I do get the data table there
Update:
If anyone can help me to locate/query my Oracle error log, then perhaps I can find out what is actually happening on the database server with my troublesome query.
This is for debugging purposes only. Try running your code in the following tryCatch construct. It will display all warnings and errors which are happening.
result <- tryCatch({
con <- dbConnect(dbDriver("Oracle"),"xxx/x",username="user",password="pwd")
spalten <- dbListFields(con, name="xyz", schema = "x")
rs <- dbSendQuery(con, "Select * From x.xyz") # no error
data <- fetch(rs) # this line throws an error
dbDisconnect(con)
}, warning = function(war) {
print(paste("warning: ",war))
}, error = function(err) {
print(paste("error: ",err))
})
print(paste("result =",result))
I know I'm late to the game on this question, but I had a similar issue and discovered the problem: My query also ran fine in SQL Developer, but that only fetches 50 rows at a time. ROracle fetches the whole data set. So, an issue that appears later in the data set won't show immediately in SQL Developer. Once I pages through results in SQL Developer, it threw and error at a certain point because there was a problem with the actual value stored in the table. Not sure how an invalid value got there, but fixing it fixed the problem in ROracle.

--staging-table while loading data to sql server (sqoop)

I am getting following error msg when I am trying to load data to sql server 2012 with sqoop.
(org.apache.sqoop.manager.SQLServerManager) does not support staging of data for export. Please retry without specifying the --staging-table option
But the same code is working fine in mysql.
Is it something to do with the sql server compatibility with sqoop.
How to fix this issue
I am using following arg in sqoop export
String arguments[] = new String[] {
"export",
"--connect",
configuration.get(PROPERTY_DBSTRING),
"--username",
configuration.get(PROPERTY_DBUSERNAME),
"--password",
configuration.get(PROPERTY_DBPASSWORD),
"--verbose",
"--table",
tableName,
"--staging-table",
"TEMP_" + tableName,
"--clear-staging-table",
"--input-fields-terminated-by",
configuration.get(PROPERTY_SQOOP_FIELD_SEPARATER),
"--export-dir",
configuration.get(PROPERTY_INPUT_DATADIRECTORY) + "/" + tableName };
return Sqoop.runTool(arguments, configuration);

select count(*) not working with perl DBI

The goal of my code is to return a count of the number of rows in a table based on one specific parameter.
Here is code that works:
######### SQL Commands
### Connect to the SQL Database
my $dbh = DBI->connect($data_source, $user, $pass)
or die "Can't connect to $data_source: $DBI::errstr";
### Prepare the SQL statement and execute
my $sth1 = $dbh->selectrow_array("select count(*) from TableInfo where Type = '2'")
or die "Can't connect to $data_source: $DBI::errstr";
### Disconnect from Database statements are completed.
$dbh->disconnect;
######### end SQL Commands
print $sth1;
This will successfully print a number which is 189 in this instance.
When I try to use the same code but change the "Type = '2'" (which should return a value of 2000) I get the following error:
DBD::ODBC::db selectrow_array failed: [Microsoft][ODBC Driver 11 for SQL Server]Numeric value out of range (SQL-22003) at ./getTotalExpSRP.cgi line 33, <DATA> line 225.
Can't connect to dbi:ODBC:BLTSS_SRP: [Microsoft][ODBC Driver 11 for SQL Server]Numeric value out of range (SQL-22003) at ./getTotalExpSRP.cgi line 33, <DATA> line 225.
I've search everywhere but I cannot find out why this happens.
From the symptom of the issue I would guess that there is a limit to the size of the results returned but I cannot find any supporting evidence of this.
I have run a trace on my Microsoft SQL 2005 server and can confirm that the sql statement is being run properly with no errors.
I've viewed my odbc trace log but unfortunately I cannot derive any useful information when comparing a working example to the failed one.
Any help would be appreciated!!
Thanks,
Now we've seen the trace I can explain this. DBD::ODBC calls SQLDescribeCol and is told:
DescribeCol column = 1, name = , namelen = 0, type = unknown(0), precision/column size = 10, scale = 0, nullable = 1
display size = 11
Then it calls SQLColAttribute and is told the column size is 4. Since the column type was unknown (why the driver did that I'm not sure) DBD::ODBC decides to bind the column as a char(4) and so as soon as the count is > 3 digits it will overflow.
The version of DBI and DBD::ODBC being used here is really old and I suspect the latest versions will cope better with this.
Numeric value out of range is a type conversion error. Is TYPE supposed to be a number of a character/string? If it should be a number, use a number
my $sth1 = $dbh->selectrow_array(
"select count(*) from TableInfo where Type=2") # Type=2, not Type='2'
or use placeholders and let Perl and the database driver worry about type conversions
my $sth = $dbh->prepare("select count(*) from TableInfo where Type=?");
$sth->execute(2);
$sth->execute('2'); # same thing
my $st1 = $sth->fetchall_arrayref;

java.sql.SQLException: ORA-03115: unsupported network datatype or representation

I'm Using Oracle 11g database. When i try to access data from db it was showing the error java.sql.SQLException: ORA-03115: unsupported network datatype or representation. I'm not understanding what this error means..
my code is :
String uname,pass;
ResultSet rs = null;
response.setContentType("text/html");
PrintWriter out=response.getWriter();
try
{
uname=request.getParameter("uname");
pass=request.getParameter("pass");
Connection con=prepareConnection();
String Query="select uname from passmanager where pass=?";
PreparedStatement ps=con.prepareStatement(Query);
ps.setString(1,pass);
rs=ps.executeQuery(Query);
if (rs.next() && uname.equalsIgnoreCase(rs.getString("uname")) || uname.equalsIgnoreCase(rs.getString("email"))) {
HttpSession session = request.getSession(true);
session.setAttribute("uname", rs.getString(1));
ServletContext context = getServletContext();
RequestDispatcher dispatcher = context
.getRequestDispatcher("/profile");
dispatcher.forward(request, response);
}
Any one help me to solve this problem..
Instead of:
rs = ps.executeQuery(Query);
you should execute:
rs = ps.executeQuery();
Otherwise, you unprepare your statement and lose all parameters because you assign it a new SQL statement (even though it's the same).
This error appears when you try to get a field by name ( rs.getString("uname") in your case) which is not in the resultset.
And like igr said, you are trying to get the email field ( with rs.getString("email") ) and it's not in the query, so this is your error.
I found this conversation because I was getting the same error in an application when I was trying to get a field with an whitespace at the end of the string ( rs.getString("uname ") instead of rs.getString("uname" ).
And I just fix it using the correct name for the field I was getting from the query.
I hope it is useful! ;)
Add email column
select uname, email from passmanager where pass=?