Running query cannot connect to vendort's database, even dblink exists - oracle

I have a simple query, which I run on sqldeveloper on put database, but it select data from different vendor database. We have db_link created. but I run, as in my Pro C program:
select some_files from mytable trd, vendordbname.vendortable
where(condition)
and I get an error:
ORA-00942: table or view does not exist
00942. 00000 - "table or view does not exist"
*Cause:
*Action:
Error at Line: 25 Column:
What kind of solution I have to find, to make it run? Use dblink name? or something else? I will appreciate any possible help
Thanks

ok, when it runs with Pro C, everything sets up on UNIX and sqlplus.
When I run it from sqldeveloper I have to add the vendor host name
select some_files from mytable trd, vendordbname.vendortable#vendorhost
where(condition)

Related

How can I get this syntax to work in Oracle?

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
simplest repo, how can I get this to work in Oracle?
SELECT 'X' NewColumn, * FROM MyTable;
I get
ORA-00936: missing expression
00936. 00000 - "missing expression"
*Cause:
*Action: Error at Line: 1 Column: 23
My actual issue is:
I'm using an ETL tool that allows automapping if I use SELECT *
I want to use ORA_ROWSCN to implement incremental loads
So the real query I'm running is:
SELECT ORA_ROWSCN, * FROM MyTable;
I get the same error for this
The syntax is valid if you alias the table and the *.
SELECT ORA_ROWSCN, t.* FROM MyTable t;
No idea whether your ETL tool knows how to do that. Of course, you could always create a view vw_table that runs this select and then use the view in the ETL tool.

PL/SQL: ORA-04063: view "OPS$DTEPROD.DTE_BLMB_TRD_ACCT_VW"

I have a view, which created (ORACLE)
CREATE OR REPLACE FORCE VIEW "OPS$DTEPROD"."DTE_BLMB_TRD_ACCT_VW"
("BB_TRD_ACCT", "DESCRIPTION", "ICI_TRD_ACCT") AS
select rtrim(STRBK_BOOK_NAME) bb_trd_acct,
rtrim(STRBK_DESCRIPTION) description,
trading_acct ici_trd_acct
from spider.sp_struct_books#spdn b1
, dte_trading_acct
where substr(rtrim(STRBK_BOOK_NAME),1,2)=ltrim(rtrim(fits_trading_Acct))
and strbk_last_update_date =
(select max(strbk_last_update_date)
from spider.sp_struct_books#spdn b2
where b2.strbk_book_number = b1.strbk_book_number)
In the package, when I compile it shows me an error
328/117 PL/SQL: ORA-04063: view "OPS$DTEPROD.DTE_BLMB_TRD_ACCT_VW" has
errors
Could you please help me to find the reason?
Thanks
Errors for PACKAGE BODY RATES_2DTE:
LINE/COL ERROR
-------- -----------------------------------------------------------------
328/1 PL/SQL: SQL Statement ignored
328/117 PL/SQL: ORA-04063: view "OPS$DTEPROD.DTE_BLMB_TRD_ACCT_VW" has
errors
Please execute following query with same user which get the outlined error:
Select * from user_errors where name like 'OPS$DTEPROD.DTE_BLMB_TRD_ACCT_VW';
This will give you errors in the view. You can post output for further investigations.
Regards
Abhi
In order to solve such problem I have to work with our DBA. Only they can give access to this database from development server. On production we have everything done.
Thank you all for trying to help me
Their are two probabilities :
1) As another member (#xQbert) suggested - user who is used to created view do not have accesses to table over dB link.
2) Database, used in database link, is not accessible.
Solution:
1) Please execute following statement by same user which is trying to select from view:
Select count(*) from spider.sp_struct_books#spdn ;
This should give same error as original error.
We want to check is read access to destination table is in place.
2) From server/command prompt on database host, where view is created, execute following :
tnsping spdn (or tnsping <database name usec by db link>)
OR
sqlplus <Username>/<Password>#spdn (or <database name usec by db link>)
We want to check if destination database on dBlink is reachable.
Abhi

How do I execute "use dbname" over Oracle dblink to Sybase?

How do I access tables in my user schema in Sybase from Oracle?
In isql I can do
use mydb
go
How do I select from mydb tables from Oracle using dblink NITSYB5?
This does not work:
select count(*) from "mydb"."lon_client_confirm_exec"#NITSYB5;
Error:
ORA-00942: table or view does not exist
[Oracle][ODBC Sybase Wire Protocol driver][SQL Server]"mydb"."lon_client_confirm_exec" not found. Specify owner.objectname or use sp_help to check whether the object exists (sp_help may produce lots of output).
{42S02,NativeErr = 208}
ORA-02063: preceding 3 lines from NITSYB5
00942. 00000 - "table or view does not exist"
*Cause:
*Action:
Error at Line: 3 Column: 30
NOTE: I don't work with Oracle and hence know nothing about Oracle's dblink, so fwiw ...
In Sybase ASE the fully qualified table name format is: <dbname>.<owner>.<table>
If you leave out the <owner> then the optimizer will first look for tables owned by the user running the query, then look for tables owned by dbo.
In your example it appears you've left out the <owner>. If the table is owned by your user or dbo then I'd suggest you try adding an additional period, eg:
select count(*) from mydb..lon_client_confirm_exec#NITSYB5;
NOTE: Add quotes as/if needed by Oracle's dblink.
SERVER 1 AND SERVER 2
open SSH server2 telnet server 1 host, its ok to done
su oracle
1) cd $ORACLE_HOME/bin
2) TNSPING database1 name
its ok done
create public database link
LINK_NAME
connect to
DB1USERNAME
identified by
111
using 'DB1NAME';
select * from dual#LINK_NAME, result x, finish.

Solve problems with external table

I have problems with some Oracle external table
create table myExternalTable
(field1, field2....)
ORGANIZATION EXTERNAL
(TYPE ORACLE_LOADER
DEFAULT DIRECTORY myDirectory
ACCESS PARAMETERS
(RECORDS DELIMITED BY NEWLINE
NOLOGFILE
NOBADFILE
NODISCARDFILE
FIELDS TERMINATED BY '$')
LOCATION ('data.dsv'));
commit;
alter table myExternalTable reject limit unlimited; --solve reject limit reached problem
select * from myExternalTable;
When I select on the table I have this error :
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04040: file data.dsv in myDirectory not found
It seems that the error description is not right because normally the table is already loaded with data.dsv when created.
Plus data.dsv exists in myDirectory.
What is going on? Can somebody help?
Note :
Instead of the select, this is what I normally do :
merge into myDatabaseTable
using
(select field1, field2,.... from myExternalTable) temp
on (temp.field1= myDatabaseTable.field1)
when matched then update
set myDatabaseTable.field1 = temp.field1,
myDatabaseTable.field2 = temp.field2,
......;
This works good on my development environment but on some other environment I have the error I said before :
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04040: file data.dsv in myDirectory not found
First I thought that, in the environment it does not work, the directory did not point where it had to but selecting on dba_directories table, I could see the path of the directory is correct.
The problem is related with the access rights of the user on the operating system side. It is defined in Oracle Support Note Create Database Directory on Remote Share/Server (Doc ID 739772.1)
For my case, I created the directory with a sysdba and then for allowing other users to accesss that external table, I created another table which is creates by Create Table as Select statement for the external table. Otherwise, I need to map the Windows Oracle Service owner user to the exact Oracle user which is already defined in the note.
So, it is more like a well fitting workaround for my case.
To sum up the steps in a nutshell:
1- Create the external table T2
2- Create a table named T1 with CTAS to external table
3- Give SELECT right to T1
Hope this helps for your case.

How to solve : SQL Error: ORA-00604: error occurred at recursive SQL level 1

When I'm trying to drop table then I'm getting error
SQL Error: ORA-00604: error occurred at recursive SQL level 2
ORA-01422: exact fetch returns more than requested number of rows
00604. 00000 - "error occurred at recursive SQL level %s"
*Cause: An error occurred while processing a recursive SQL statement
(a statement applying to internal dictionary tables).
*Action: If the situation described in the next error on the stack
can be corrected, do so; otherwise contact Oracle Support.
One possible explanation is a database trigger that fires for each DROP TABLE statement. To find the trigger, query the _TRIGGERS dictionary views:
select * from all_triggers
where trigger_type in ('AFTER EVENT', 'BEFORE EVENT')
disable any suspicious trigger with
alter trigger <trigger_name> disable;
and try re-running your DROP TABLE statement
I noticed following line from error.
exact fetch returns more than requested number of rows
That means Oracle was expecting one row but It was getting multiple rows. And, only dual table has that characteristic, which returns only one row.
Later I recall, I have done few changes in dual table and when I executed dual table. Then found multiple rows.
So, I truncated dual table and inserted only row which X value. And, everything working fine.
I know the post is old and solved, but maybe someone is facing or will face my situation, so I want to leave the aquired knowledge here, after deal with the error for a week. I was facing the error: "ORA-00604: error occurred at recursive SQL level 1" , but with the internal error: " ORA-06502: error: character string buffer too smal numeric or value", this happened only when I try to logon the database, and using an specific driver, trying to connect from an Visual Studio C# application, the weirdest thing on that moment was that I connect from SQLDeveloper or TOAD and everything worked fine.
Later I discovered that my machine name had this format "guillermo-aX474b5", then I proceed to rename it like this "guillermo" without the "-" and the other stuff, and it worked!! Looks like in some drivers and situations, ORACLE Database does'nt like the "-" in the LogOn connection.
Hope it helps!

Resources