I have a view 'A' in "X" database, ON either of the tables A_a and A_b which will be dynamical changes. I would like to replicate this view in another database as well dynamically. I have just created another view on top of this X.A but it yields error like below:
Error: Error while compiling statement: FAILED: SemanticException Recursive view X.A detected (cycle: Y.A -> X.A -> X.A). (state=42000,code=40000)
If the first view(X.A) created on top of X.A_a or X.A_b then it will be fine. But my automated script replaced the correct view x.A as well it should be excluded.
Related
I can't create a table from a view consisting of 2 other views connected by a minus operator. I can create a table from a view that uses a table and a view connected by a minus operator. Is this a limitation of Oracle or is there another way to use 2 views and the minus operator to create a table.
Code:
CREATE TABLE AS SELECT * FROM VIEW_1 MINUS VIEW_2
--[Error] Execution (51: 1): ORA-00600: internal error code,
arguments: [KGL-heap-size-exceeded]
All ORA-600s are bugs. You can either create an SR with My Oracle Support, or find the issue already discussed, or find your own workaround.
That being said, your SQL is incorrect - after the MINUS you would need another SELECT * FROM
If you still have trouble after fixing this, check the view definitions to make sure there's no self-referencing/loop going on or other craziness (like a 100MB SQL statement). Your error indicates that Oracle spazzed out while parsing it.
I am creating a materialised view using below command :
CREATE MATERIALIZED VIEW project-id.dataset_id.TESTING AS
SELECT COUNT(*) FROM project-id.dataset_id.table;
Below is the error:
Syntax error: Expected keyword AS but got "-" at [1:31]
I guess it's because my project id is like this : project-id (example testing-project-dev).
How to resolve this ?
Moving the answer from comments to an answer: Add backticks.
CREATE MATERIALIZED VIEW `project-id.dataset_id.TESTING` AS
SELECT COUNT(*) FROM `project-id.dataset_id.table`;
I have a simple query that runs successfully, but when I introduce a variable into the query, I am unable to save a view using that query. For example:
SELECT * FROM mytable WHERE color = 'red';
This query runs fine. Then:
DECLARE color STRING DEFAULT 'red';
SELECT * FROM mytable WHERE color = color;
This query also runs fine. Then in the BigQuery UI I click to "Save view", but I get an error saying Unexpected keyword DECLARE. Why is that?
As explained in the documentation:
BigQuery views are subject to the following limitations:
You cannot reference query parameters in views.
What you want to do is not allowed. A view is limited to a single SELECT statement.
I am using the System i Navigator in order to create a View.
My view is very simple:
SELECT MOMAST.ORDNO, MOMAST.FITEM
FROM AMFLIBT.MOMAST AS MOMAST
WHERE MOMAST.FITEM LIKE 'POS-%'
GROUP BY MOMAST.ORDNO,MOMAST.FITEM
ORDER BY MOMAST.FITEM,MOMAST.ORDNO
When clicking on OK button to creat the view, I am getting the following error:
SQL0199] Keyword ORDER not expected. Valid tokens: . Cause . . . . . : The keyword ORDER was not expected here. A syntax error was detected at keyword ORDER. The partial list of valid tokens is .
When I remove the ORDER BY statement, the view is being created successfully.
I need to create my view with the ORDER BY statement, how can I achieve this task with no errors?
A view is a relational table, and the relational model defines a table as a set of rows. Since sets are not ordered - by definition - the rows in a view are not ordered, either. Therefore, an ORDER BY clause in the view definition is meaningless. The SQL standard (SQL:2003) does not allow an ORDER BY clause in a subselect in a CREATE VIEW statement, just as it is not allowed in a CREATE TABLE statement.
In your case, I recommend creating the view without the ORDER BY statement, and using this statement when selecting from the view (not while creating it).
All of a sudden I cannot get synonyms for tables working in BigQuery, so a query like the following works fine:
select id as id, value as value
from pos_dw_api.test
But a query like the following fails:
select a.id as id, a.value as value
from pos_dw_api.test a
The error returned is the following. I have run this from the web console:
Query Failed
Error: Unknown field: a.id
Synonyms were working just fine last week ... The example table I'm using for this select is 387047224813.pos_dw_api.test.
Has the syntax for synonyms changed? Is this a bug?
Table synonyms generally only work when you're doing a JOIN. I don't know of anything that would have caused this to change. I realize that this is kind of strange, and I've filed an internal bug to fix it.