Error ORA-00933 on create editioning view - oracle

I'm trying to create an editioning view in Oracle 11g and it's giving the error "ORA-00933 SQL command not properly ended", I ran it with the owner of schema and sys, but the error persists.
CREATE OR REPLACE FORCE EDITIONING VIEW "CEGASV3"."VE_COML_FACTIVEL"(
"PK_FACTIVEL", "FACTIVEL", "ENDERECO", "NOMECONTATO", "TELCONTATO01", "TELCONTATO02",
"EMAIL", "SEGMENTO", "DT_DIGIT", "RESPONSAVEL", "INFOUTEIS", "NOME_TABELA_HISTORICO",
"DATA_HORA","VPD_GEMPI","ORA_GEOMETRY","ORA_GEOMETRY_GOOGLE","STATUS"
) AS
SELECT F.PK_FACTIVEL, F.FACTIVEL, F.ENDERECO, F.NOMECONTATO, F.TELCONTATO01, F.TELCONTATO02,
F.EMAIL, F.SEGMENTO, F.DT_DIGIT, F.RESPONSAVEL, F.INFOUTEIS, F.NOME_TABELA_HISTORICO,
F.DATA_HORA, F.VPD_GEMPI, F.ORA_GEOMETRY, F.ORA_GEOMETRY_GOOGLE, F.STATUS
FROM CEGASV3.COML_FACTIVEL F
LEFT JOIN CEGASV3.COML_PROSPECT P ON P.FK_FACTIVEL = F.PK_FACTIVEL
WHERE P.PK_PROSPECT IS NULL;

You can not create complex view as editioning view. It means you can not use multiple tables as a query of the view, It must be a single table view.
Editioning views are a wrapper over the base table. It can only be a
straight query of the base table, but can display a subset of the
columns and give alias to them.
Read more about editioning view here.
Cheers!!

Related

GRANT SELECT ON view TO user using script on SQL developer, than SELECT * FROM that view in SQL Plus

My script on SQL dev:
**CREATE USER C##DG IDENTIFIED BY abc123;**
**CREATE VIEW DG1_VIEW**
AS SELECT m_pms.MaPMS, m_pms.MaDG, m_pms.SoLuong, m_s.MaSach, m_s.TenSach, m_ctpm.SL
FROM PhieuMuonSach m_pms, ChiTietPhieuMuon m_ctpm, Sach m_s
WHERE m_pms.MaDG = 1 AND m_pms.MaPMS = m_ctpm.Ma_PMS AND m_ctpm.Ma_Sach = m_s.MaSach**;**
**GRANT CREATE SESSION TO C##DG;
GRANT SELECT ON DG1_VIEW TO C##DG;**
On Sql Plus, i logged in as C##DG, typed '''SQL> SELECT * FROM DG1_VIEW;'''
and received 'ORA-00942: table or view does not exists'. But this view already had data.
What is my problem and how to fix it? I'd love to hear from you guys.
You need to either specify schema this view has been created in
select * from system.dg1_view;
or you may login as system again and create a public synonym for that view in order to make it available without specifying schema

Updating rows with values from another table in ClickHouse

I have two tables, one with data about counties and another with data about states. Different states can sometimes have counties with the same exact name, so I am trying to populate a unique_name column in my counties table that is the concatenation of a county name and the abbreviation of the state where that county is located (e.g.: Honolulu County, HI).
I have come up with the following query:
ALTER TABLE counties
UPDATE unique_name =
(
SELECT concat(counties.name, ', ', states.name_abbr)
FROM counties
INNER JOIN states
ON counties.statefp = states.statefp
) WHERE unique_name = ''
However, I keep getting the following error:
DB::Exception: Unknown identifier: states.statefp, context: required_names: 'states.statefp' source_tables: table_aliases: private_aliases: column_aliases: public_columns: masked_columns: array_join_columns: source_columns: .
The inner query is working perfectly fine on its own, but I don't why this error is coming up when I try to do the update. Any ideas?
ClickHouse does not support dependent joins for ALTER TABLE UPDATE. Fortunately, there is a workaround. You have to create a special Join engine table for the update. Something like this:
CREATE TABLE states_join as states Engine = Join(ANY, LEFT, statefp);
INSERT INTO states_join SELECT * from states;
ALTER TABLE counties
UPDATE unique_name = concat(name, joinGet('states_join', 'name_abbr', statefp))
WHERE unique_name = '';
DROP TABLE states_join;
Note, it only works in 19.x versions.

SQL query parsing Issue with joining a table with a view for apex tabular form

I am using the following SQL query as a basis for an Apex tabular form:
SELECT G."INDICATOR_NAME", V.INDICATOR_TYPE, V.INDICATOR_PERIOD, V.INDICATOR_VALUE, V.METRIC_USER, V."METRIC_USER_GROUPID"
FROM STG_VALUES V, "#OWNER#"."GETMETRICGROUPID_V" G WHERE V.INDICATOR_NAME = G."INDICATOR_NAME" AND V.METRIC_USER_GROUPID = G."METRIC_USER_GROUP_ID"
and V.INDICATOR_PERIOD BETWEEN TO_DATE(TO_CHAR(ADD_MONTHS(TRUNC(SYSDATE,'MM'),-36), 'MM/DD/YYYY'), 'MM/DD/YYYY') AND TO_DATE(TO_CHAR(SYSDATE,'MM/DD/YYYY'),'MM/DD/YYYY')
Here I'm joining a table (STG_VALUES) with a view (GETMETRICGROUUPID_V)
Here's the script for the GETMETRICGROUPID_V:
CREATE OR REPLACE FORCE VIEW STG.GETMETRICGROUPID_V
(
INDICATOR_NAME,
METRIC_USER_GROUP_ID
)
AS
SELECT INDICATOR_NAME, METRIC_USER_GROUP_ID
FROM STG_MST_USER_ASSIGNED_METRICS
WHERE METRIC_USER = NVL (v ('APP_USER'), USER)
OR METRIC_USER = LOWER (NVL (v ('APP_USER'), USER));
Here's my issue:
When I ran the above SQL Query in the Apex SQL Commands area, I got the
correct results. But when I used the same SQL Query inside the Apex tabular
form, I received the following error message:
failed to parse SQL query:
ORA-01403: no data found
It looks like Apex has issues joining a table with a view when used as a basis for the tabular form. Any thoughts on this ? I've searched the Internet for
answers/solutions and could not find any.
olecramon74
ORA-01403:no data found comes when the Select query returns no result in a PL/SQL code or function. Check the output of the v ('APP_USER') function in the query, it should be returning no result when you are running the query from APEX

Like Operator is not working in oracle view

I have created a view in oracle. Now i would like to fetch data from that view. So i have written a SQL Query. But the query is not working for not having a specific condition. But if I give that condition the query executes. But the problem is not occurring if i joined the same number of tables (that were used to create view) instead of using view. In the following I am giving the oracle query.
SELECT *
FROM "920_search_report"
WHERE lm_culture = '7aacb509-271d-4aca-e040-e00adea40aae'
AND hand_person_info_guid = 'eebd4257-7856-4c6e-b6b8-9b886e89e397'
AND ( Lower(handicap_type) LIKE Lower('%DQ871J%')
OR Lower(skskodenr) LIKE Lower('%DQ871J%') );
The above query executes and returns one record but if I omit or comment the third line then the query does not return any records, but it should return one or two. the query is given below:
SELECT *
FROM "920_search_report"
WHERE lm_culture = '7aacb509-271d-4aca-e040-e00adea40aae'
--AND HAND_PERSON_INFO_GUID='eebd4257-7856-4c6e-b6b8-9b886e89e397'
AND ( Lower(handicap_type) LIKE Lower('%DQ871J%')
OR Lower(skskodenr) LIKE Lower('%DQ871J%') );
Can anyone help me to solve the problem.

How can I convert sql to linq

This is my SQL query
SELECT
sys.sysobjects.name Name,
sys.foreign_keys.*
FROM
sys.foreign_keys
inner join sys.sysobjects on
sys.foreign_keys.parent_object_id = sys.sysobjects.id
WHERE
referenced_object_id = OBJECT_ID(N'[dbo].[Country]')
I have installed Linqer to convert SQL to linq.
But I got an error:
SQL cannot be converted to LINQ: Table [foreign_keys] not found in the current Data Context.
I am a beginner in Linq. Can Anyone help me to convert SQL to Linq
The problem is that system views will not be picked up by Linqer. If you want to read these tables in your application, first create your own views on them, as was done here and write a query on these views.
CREATE VIEW SysObjectsView AS SELECT * FROM sys.sysobjects;
GO
CREATE VIEW SysForeignKeysView AS SELECT * FROM sys.foreign_keys;
GO
SELECT obj.name Name, fk.*
FROM SysForeignKeysView fk
INNER JOIN SysObjectsView obj ON fk.parent_object_id = obj.id
INNER JOIN SysObjectsView objfk ON fk.referenced_object_id = objfk.id
WHERE objfk.name = N'Country'
Linqer should be able to pick up these views.

Resources