Google BigQuery returns "Not found: Dataset nnn-business-insight:nnn_raw_harvest was not found in location US" - google-bigquery

I'm a bit stuck as the same query works outside a procedure.
Any bright ideas anyone?
So this works:
select * from `sps-business-insight.sps_raw_harvest.users` limit 10
And this gives an error:
CREATE OR REPLACE TABLE
sps.harvest_monthly AS (
select * from `sps-business-insight.sps_raw_harvest.users` limit 10
)
Error message:
Not found: Dataset sps-business-insight:sps_raw_harvest was not found in location US
I have checked the structure of the table reference
Make sure your FROM location contains 3 parts
A project (e.g. bigquery-public-data)
A database (e.g. hacker_news)
A table (e.g. stories)*
and it works if it's not inside a "CREATE TABLE" or a "CREATE PROCEDURE" statement...

Related

Newly Added Column is not Appearing in Synonym

I have a table named YY_ZZ_VAT_TRX_DETAILS under the XX schema.
It has an existing SYNONYM to AA schema.
I am currently logged in as AA and I wanted to add a column to YY_ZZ_VAT_TRX_DETAILS and executed the below command just fine
alter table XX.YY_ZZ_VAT_TRX_DETAILS
add (USER_DEFINED_FISC_CLASS VARCHAR2(30));
Table XX.YY_ZZ_VAT_TRX_DETAILS altered.
I tried to select the Column from the Table using the simple query below
select USER_DEFINED_FISC_CLASS
from YY_ZZ_VAT_TRX_DETAILS;
But I surprisingly got this error:
ORA-00904: "USER_DEFINED_FISC_CLASS": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action: Error at Line: 1 Column: 9
I thought I just missed altering the table, so I re-ran the ALTER script again, but got this error instead:
Error starting at line : 4 in command - alter table
XX.YY_ZZ_VAT_TRX_DETAILS add (USER_DEFINED_FISC_CLASS VARCHAR2(30))
Error report - ORA-01430: column being added already exists in table
01430. 00000 - "column being added already exists in table"
*Cause:
*Action:
I checked the Object Definition and sure enough, I found the new column there:
But when I query all the columns from the Table, I still can't see it:
select *
from YY_ZZ_VAT_TRX_DETAILS;
However, when I query using the XX schema prefix, I'm able to see the column:
select *
from XX.YY_ZZ_VAT_TRX_DETAILS;
Why isn't the synonym picking up the newly-added column?
It seems this was caused by this "Edition-Based Redefinition" thing that Oracle recently introduced for 12c.
Upon further investigation, what happened was:
The Table XX.XX_ZZ_VAT_TRX_DETAILS has a Editionable view named XX_ZZ_VAT_TRX_DETAILS# that only selects a certain number of columns.
Now, the View XX_ZZ_VAT_TRX_DETAILS# has a SYNONYM named XX_ZZ_VAT_TRX_DETAILS under the schema AA, hence the confusion on the Table having a SYNONYM of the same name.
To resolve this, i modified the view XX_ZZ_VAT_TRX_DETAILS# and added the new column and successfully recompiled it.
Once this was done, the synonym now shows the newly-added column and I was able to compile the stored procedure successfully.
I believe you could be having a table or a view called YY_ZZ_VAT_TRX_DETAILS or a private synonym that points to another table?.
In oracle the preference while querying is
1)objects_in same schema
2)private synonym
3)public synonym

Execution from the statement select * into return error

Can somebody help me?
I am try execute the command below in Oracle 11 and I get this error:
SQL Error [905] [42000]: ORA-00905: keyword not found.
Code:
SELECT *
INTO SAJ.ETMP_TESTE
FROM SAJ.ESAJOBJETO O
WHERE CDOBJETO = 'P800000000J03'
I read the Oracle docs and haven't found any obvious error in my statement.
https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/selectinto_statement.htm
My objective is to create the table ETMP_TESTE with structure from ESAJOBJETO.
I checked user permission and user has permission to action.
You need create table and not select into for create a table based on the result of a query
CREATE TABLE SAJ.ETMP_TESTE
AS SELECT *
FROM SAJ.ESAJOBJETO O
WHERE CDOBJETO = 'P800000000J03'
This will create an empty table named ETMP_TESTE, with the structure of the SAJ.EASJOBJETO table.
CREATE TABLE ETMP_TESTE AS
SELECT *
FROM SAJ.EASJOBJETO
WHERE 1 = 0;
This does not handle contraints and primary keys and things like that, but it will get you the table structure. The 1 = 0 makes sure no data is copied.
If you need primary keys and the like, look into extracting the DDL for EASJOBJETO. Most SQL IDEs have that functionality built in. You can edit it to correct the table name and run the script and get everything.

Can only find table in Oracle SQL when surrounding the table name with double quotes. Why?

I'm having the following weird issue with Oracle SQL. I have a table called schema_version, but I can't run simple selects over it:
> SELECT * FROM schema_version;
ORA-00942: table or view does not exist
00942. 00000 - "table or view does not exist"
*Cause:
*Action:
Error at Line: 1 Column: 15
Now if I attempt to run the very same query but this time surrounding the table name with double quotes everything seems to run fine:
> SELECT * FROM "schema_version";
< results are shown >
From what I've read # https://stackoverflow.com/a/7425931/130758 I should be okay not using double quotes. What may I be missing? Thanks
If the table was created as
CREATE TABLE "schema_version" (...)
its name is stored in the catalog in the exact (lower) case. When you reference the name unquoted:
SELECT * FROM schema_version;
the name is converted to the upper case by default, so the table cannot be found. When you reference the name quoted:
SELECT * FROM "schema_version";
the table name is used as is (in lower case) and matches that in the catalog.

ERROR: relation "Table" does not exist in PostgreSQL

I am working on a project with Django 1.7 and PostgreSQL. When I access database tables through the Django admin it's working fine, but when I try to access those tables from the PostgreSQL console some are working fine, but some throw an error.
For example, the following query works.
select * from post_my;
id | owner_id | content
---+----------+---------
(0 rows)
However, the following query does not:
select * from Doctors_city;
ERROR: relation "doctors_city" does not exist
LINE 1: select * from Doctors_city;
I tried to search on google and stack, but not getting any use full solution.

Error creating database table using FirebirdSQL

I'm trying to add tables to a FirebirdSQL database using FlameRobin but I'm getting the following error:
Error: *** IBPP::SQLException ***
Context: Statement::Prepare( CREATE TABLE drinks
(
...
) )
Message: isc_dsql_prepare failed
SQL Message : -104
can't format message 13:896 -- message file C:\Windows\firebird.msg not found
Engine Code : 335544569
Engine Message :
Dynamic SQL Error
SQL error code = -104
Token unknown - line 3, column 5
.
I've tried googling the problem but have been unable to find a solution. Does anyone know what the issue is here?
As it stands it looks like the CREATE TABLE in the question is the actual statement. In that case you are getting the error because it is simply invalid syntax:
CREATE TABLE drinks (
...
)
If I execute this in Flamerobin, I get almost the same error (except for me at line 2, column 5 (the first .), as the parser expects a column name there. At the ... you need to specify the actual columns (and optionally constraints) of the table.
For example:
CREATE TABLE drinks (
ID INTEGER PRIMARY KEY,
NAME VARCHAR(100) NOT NULL
)