Fluent Nhibernate Oracle Identifier Too Long - Alias Name Issue - oracle

I've tried to do that.
HasManyToMany<YechidotDoarInGroup>(x => x.Col_yig)
.Table("PigToYig")
.ChildKeyColumn("YIG_GROUP_RECID")
.ParentKeyColumn("PIG_GROUP_RECID");
but I've got:
ORA-00942: table or view does not exist
I am trying to establish HasManyToMany connection not by ID , but by
some other property .
First I've got - too long message. When I've tried to enter my own Table name as an alias , it's not recognized. What should I do?

The problem may well be this:
.Table("PigToYig")
Oracle object names are, by default, in UPPER case. However, Oracle applies names in double-quotes in the given case. In other words, if your table has the default naming you may need to pass in this instead ...
.Table("PIGTOYIG")
It depends how NHibernate converts those variables into SQL (I'm not familiar with NHibernate).

Define Table() method before all of your mapping declaration.
public EmployeeMap : ClassMap<Employee>
{
public EmployeeMap()
{
Table("EMPLOYEE");
// your declaration
Id(x => x.IdEmployee);
}
}

Cause: The table or view entered does
not exist, a synonym that is not
allowed here was used, or a view was
referenced where a table is required.
Existing user tables and views can be
listed by querying the data
dictionary. Certain privileges may be
required to access the table. If an
application returned this message, the
table the application tried to access
does not exist in the database, or the
application does not have access to
it.
Action:
Check each of the following:
* the spelling of the table or view name.
* that a view is not specified where a table is required.
* that an existing table or view name exists.
source ora-code.com

Related

FireDAC "table or view does not exist" when insert into ORACLE TABLE Delphi Belin 10.1 upd 2

We are migrating our codebase from Delphi XE3 with FireDAC 8.0.5 to Delphi Berlin 10.1 Upd 2 with FireDAC 15.0.1 (Build 86746). Everything is working smoothly using MS Sql Server, but using ORACLE it has been another history.
Throughout the application source code we use lots of TAdQuery with sql instructions like
AdQuery1.Sql.Text := 'SELECT FIELD1, FIELD2 FROM TABLE1';
In order to insert a record, we use Append or Insert methods, like this
AdQuery1.Insert;
//or
AdQuery1.Append;
Just after invoking its Post method, the component internally creates an INSERT sql statement, that goes like this
INSERT INTO TABLE1 (FIELD1, FIELD2) VALUES(:FIELD1, :FIELD2)
So the record gets inserted successfully.
Now, using TFdQuery in Delphi Berlin, the component internally creates an INSERT sql statement, like this
INSERT INTO USERNAME.TABLE1 (FIELD1, FIELD2) VALUES(:FIELD1, :FIELD2)
Failing with a [FireDAC][Phys][Ora] ORA-00942: table or view does not exist
This happens because in our Oracle database, TABLE1 is created in a schema called MAIN_SCHEMA, and we access it by using a public synonym.
Trying to find a workaround, we compared FireDAC source code, finding that
in Delphi XE3, the unit uADDAptManager.pas, on its function TADDAptTableAdapter.GetUpdateRowCommand, calls oConn.CreateCommandGenerator(oCmdGen, nil);
in Delphi Berlin, the unit FireDAC.DApt.pas, on its function TFDDAptTableAdapter.GetUpdateRowCommand
calls oConn.CreateCommandGenerator(oCmdGen, GetSelectCommand);
Whenever that second parameter (called ACommand: IFDPhysCommand) is not nil, the name of the table is returned concatenating the user name (in a function called TFDPhysCommandGenerator.GetFrom).
If we add 'MetaCurSchema=MAIN_SCHEMA' to the TFdConnection params, it works with the applications that not use a pooled connection, but We have several process that use a pooled connection with the same params, even MetaCurSchema param, but it doesn't work
What can we do?
thanks for your help
What I understand is that you would do better making the connection avoid the use of any schema name, rather than specifying it. Also, keeping in mind that you already use public synonyms.
So, according to the documentation:
Full object names
FireDAC supports full object names, which include the catalog and/or schema names.
When a short object name is specified to StoredProcName, TableName, etc, they will be expanded into the full object names, using the current catalog and/or schema names. To override or avoid usage of the current catalog and/or schema names, use the MetaCurCatalog and MetaCurSchema connection definition parameters. For example:
[Oracle_Demo]
DriverID=Ora
...
MetaCurCatalog=*
MetaCurSchema=*
~ Source: Object Names (FireDAC) - docWiki
MetaCurSchema
Specifies the current schema for the application. If not specified, then its value will be received from the DBMS. When an application is asking for metadata and do not specify a schema name, then FireDAC will implicitly use the current schema.
If MetaCurSchema is '*', then schema names will be me omitted from the metadata parameters.
~ Source: Common Connection Parameters (FireDAC) - docWiki
That asterisk (*) should do the trick, let us know if that's the case.

views calls a function on a different database but crystal reports "invalid identifier" error

I've created a view (generic_view) on a database (database1) in schema (general_schema). One of the columns in this view is populated by a function (generic_function) which is stored in the same schema but on a different database (database2). I'm calling the function like:
general_schema.generic_function#database2(param1, param2, ... paramN) AS function_column
The view and function both compile, and the view generates data for the function_column function. The problem occurs when I try to use this view in crystal reports to generate a report. When I try to add the view I get the error:
ORA-00904: "general_schema"."generic_function": invalid identifier
I tried removing all of the content inside the function so that the function just returns 0, but that didn't seem to help.
I'm I calling the function wrong?
The schema names being the same in different databases doesn't mean they're the same schema. You'll need to have a database link set up in database1 to allow access to database2, and then in database2 you'll need to be sure that the user specified in the database link has been granted EXECUTE access to general_schema.generic_function.
Best of luck.

ORA-00942: table or view does not exist using iBatis

I am using MyBatis 3 to create a request (seen below) however, I am getting:
ORA-00942: table or view does not exist
where SYNONYM_A is a public Synonym for a table in another database...
I know the example doesn't really help, but the real question is, "Is there a special syntax for synonyms in Batis?" Has anyone done this, or failed, and can tell me, so I don't spend a great deal of effort, if it is not valid in Batis?
#Select("select * from SYNONYM_A where some_det_key in (SELECT DATA_KEY FROM SOME_PARENT_TABLE WHERE PARENT_KEY = 1234 AND (ATTACH_PARENT_FLG = 1 or ATTACH_PARENT_FLG is null) AND DATA_SRC = 'LV_SOME_DET') ORDER BY pair
Provide the select grant FROM the PARENT schema to the current schema once again for the table of which SYNONYM_A is a synonym of.
And is SYNONYM_A a synonym for a Table or a synonym of another SYNONYM in the PARENT schema?
In case it is, u need to provide grant from the ultimate base schema where the actual table is located once again 'WITH GRANT OPTION'
A public synonym does not mean that grants are not required from the schema in which the parent table lies(if the synonym and the table lies in two different schemas, that is). You need to clarify your concept of public synonyms :) .
But thats not the point here.
just do:
SELECT * SOME_TABLE"#"CONNECTION_TO_ANOTHER_DATABASE;
If this gives you ORA-XXXX: Table or view doesnot exist, then this is the cause.
There are two possibilities:
1.CONNECTION_TO_ANOTHER_DATABASE has got corrupted/doesnot exist.
You can check this by doing queries like :
Select sysdate from duals#CONNECTION_TO_ANOTHER_DATABASE;
Select * from user_objects#CONNECTION_TO_ANOTHER_DATABASE;
If this too gives you the same error then that's it, your CONNECTION_TO_ANOTHER_DATABASE is gone.
If this does not give any error and gives some valid o/p then:
2.Probably the "SOME_TABLE" at the remote database does not exist!
The answer is....
I was connected to the wrong database instance!! I had built extended AbstractRoutingDataSource, and was pulling the server name for the datasource from a primary database. I discovered that another individual had populated this table incorrectly, and pointed me to a database where the synonym did not exist.
Thank you for your responses, and your time.

ORMLite and Oracle - case sensitive column names

I have just started using ORMLite and was using at home to experiment on MySQL. Now I have decided to try using it on Oracle, but have noticed an issue with case sensitivity of column names.
When using the TableUtils.createTableIfNotExists() it appears to generate CREATE statements that wrap the table and column names in double quotes. For example:
CREATE TABLE "T_SUBURB" ("id" NUMERIC , "description" VARCHAR2(255)
NOT NULL , "gnaf" VARCHAR2(255) , PRIMARY KEY ("id") )
This means that when I am attempting to query the database in Oracle SQL Developer I have to use the double quotes to specify the table and column names. This doesn't seem to happen when using MySQL.
I must admit I am a SQL novice, however it doesn't seem natural to wrap every table or column name in double quotes when attempting to query them. Looking at the OracleDatabaseType implementation it would seem that the entity name is intentionally double quoted in this example.
Does anybody know of a way to turn this behaviour off?
I am currently running version 4.43 from maven-central and Oracle 11g. Cheers.
When using the TableUtils.createTableIfNotExists() it appears to generate CREATE statements that wrap the table and column names in double quotes.
That's correct. The challenge for ORMLite is that it has to protect against special characters or reserved-words as field and table names. Words like "index" or "create" might make fine field names but will cause invalid SQL.
However, according to my reading of the OracleDatabaseType is should be generating uppercase field names:
#Override
public boolean isEntityNamesMustBeUpCase() {
return true;
}
If your field is created as "description" then something is wrong. Does DESCRIPTION work instead? Is ORMLite generating your schema and using an Oracle JDBC URI? Something like:
jdbc:oracle:...
If you are not using a JDBC URI like that then ORMLite may not be using the Oracle database type to create your tables. If you need to force it to use Oracle, you can create your
ConnectionSource connectionSource =
new JdbcConnectionSource(databaseUrl, new OracleDatabaseType());
Hope this helps.

Run a Query from Linked Server (Oracle) in SQL Server2008 R2

I have the linked server set up in SQL Server 2008. But I could not run any query against the linked server.
I tried to run this simple command but it's not working
SELECT * FROM MYSERVER..ALANH.TEMP_UPDATE1
This is the error I got when I run the above command.
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "OraOLEDB.Oracle" for linked server "MYSERVER" reported an error. The provider did not give any information about the error.
Msg 7312, Level 16, State 1, Line 1
Invalid use of schema or catalog for OLE DB provider "OraOLEDB.Oracle" for linked server "MYSERVER". A four-part name was supplied, but the provider does not expose the necessary interfaces to use a catalog or schema.
Could anyone help me to connect to the OracleLinkedServer? Thanks very much.
you can be that way too:
**SELECT * FROM OPENQUERY(MYSERVER, 'SELECT * FROM ALANH.TEMP_UPDATE1')**
You can write the query like this:
select * FROM [MYSERVER]..[ALANH].[TEMP_UPDATE1]
Important: In this case, the fully qualified table name must be written in upper case.
You might try the fix from this article.
Also, this could be a problem with naming. From an MS KB article
If you receive these error messages, a table may be missing in the
Oracle schema or you may not have permissions on that table. Verify
that the schema name has been typed by using uppercase. The
alphabetical case of the table and of the columns should be as
specified in the Oracle system tables.
On the Oracle side, a table or a column that is created without double
quotation marks is stored in uppercase. If the table or the column is
enclosed in double quotation marks, the table or the column is stored
as is.
First make sure the tnsping utility works from client server, then use the below string in linked server database source setup
host[:port]/service_name
Check this link for more details :
http://www.oracledistilled.com/oracle-database/oracle-net/using-easy-connect-ezconnect-naming-method-to-connect-to-oracle-databases/
Try something like this:
SELECT * FROM ALL_TABLES#"SOME.SERVER.NAME";
In this case I'm selecting ALL_TABLES from a linked server called SOME.SERVER.NAME.
Richard's post above was critical.
I am using v12 ODP.NET odbc drivers and had to ensure that "Zero Level Only" was NOT checked and that the names supplied for table and schema were the correct case. All of the schemas and tables I access are uppercase only.
Use the query below to determine what the correct table name is, though you will have to supply the schema name in the correct case for the query to work. Try all uppercase, try all lowercase, try mixed case, or better yet get the actual name from the dba (I've heard that only table/schema names that are "" quoted will be allowed mixed case, otherwise in oracle it's all uppercase.)
sp_tables_ex #table_server=InsertLinkedServerHere, #table_schema=InsertSchemaNameHere

Resources