Copy data from one database to another using SQLPLUS/shell - sql

I need to copy data from one of the remote database to data base in my server. But I am getting eroor below.
insert into table_here#oprdb select * from view_on_remote#AISPRD where rownum<10;
*
ERROR at line 1:
ORA-02019: connection description for remote database not found
I also tried connecting to both before query:
conn schema/password#host:port/srvc_name;
conn schema/password#host:port/srvc_name1;
Trying the COPY command failed as well:
Array fetch/bind size is 15. (arraysize is 15)
Will commit when done. (copycommit is 0)
Maximum long size is 80. (long is 80)
CPY-0012: Datatype cannot be copied
But still it says connection description not found.
Can anyone help me where I am getting this wrong.

Use COPY command
--connect to target db
sqlplus schema/password#host:port/oprdb
sqlplus>copy from schema/password#host:port/AISPRD insert table_here using -
select * from view_on_remote where rownum<10;

Related

R read a local .mdf file

I have a database file (a .mdf file from a microsoft SQL server) that I copied on my disk. It comes from a device, and I would like to read the data, preferably in R. I am totally new to SQL, and I don't understand how to deal with a local file.
I tried
library(RMySQL)
con <- dbConnect(RMySQL::MySQL(), dbname = "MGCDBase")
which gave me
Error in .local(drv, ...) :
Failed to connect to database: Error: Can't connect to MySQL server on 'localhost' (0)
I don't get if it is because there is a password, if I am doing it wrong, or if I should use something else than R or RMySQL.
Any help or advise would be welcome

Running db2 from bash script not working?

I'm currently using bash on CentOS. DB2 is installed and db2 is on my path.
I have a few lines in a script which are supposed to update my db2 database, but they aren't working. As a minimal reproduction, I can do the exact same thing right in the bash command line and get the same error. Here's that reproduction:
$ db2 connect to PLT02345 user uni using uni; db2 update USM_USER set STATUS = 1 where NAME = 'asm_admin'
I expect this to set STATUS to 1 for everything in PLT02345.USM_USER where the NAME is currently asm_admin.
Instead, I get an error about "ASM_ADMIN" not being valid in the context where it's used. Here's the full output:
Database Connection Information
Database server = DB2/LINUXX8664 10.1.2
SQL authorization ID = UNI
Local database alias = PLT02345
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0206N "ASM_ADMIN" is not valid in the context where it is used.
SQLSTATE=42703
I'm confused - what about this makes it not valid? Is bash somehow mutilating the command and not passing everything as it should to db2?
If you're running this from the command line, Bash will drop the 's off 'asm_admin' because it simply assumes you're passing a string. The end result is the SQL becoming WHERE name = asm_admin which is invalid.
To correct this, you need to quote your whole command:
db2 "update USM_USER set STATUS = 1 where NAME = 'asm_admin'"

How do I fix "datasource serviceImpl.error_0009" in pentaho?

I log into pentaho using the administrator's username and password, then go into file > new > datasource select "SQL QUERY", then type in my database and test it for database connection, it is successful. When I try to test the new datasource with the sql query, I type in "select 1 from mytable" and it gives me this error:
datasourceServiceImpl.error_0009
query validation failed: query validation failed {0}
This is all that it is giving me and I don't know how to fix this.
I have biserver-ce-5.1.0.0-752 running
I fixed the issue by removing ";" at the end of my query.
Stop the server.
Change the mysql driver folder .. \ tomcat \ lib "mysql-connector-java-5.1.17.jar" the driver "mysql-connector-java-5.1.25-bin.jar".
Restart the server and it will work.
I got this error and found that it was as simple as having 2 columns named the same thing in my SELECT statement.
Install mysql-connector-java-gpl-x.x.x.msi
Put into lib folder mysql-connector-java-x.x.x.jar

sqlTool.rc contais password in plain text

I want to stop my HSQL DB from command line using command
java -jar hsqldb/lib/sqltool.jar --rcfile=sqltool.rc --sql "shutdown;" localhost-sa-myPassword
This command expects sqlTool.rc file which contains DB related information like user id and password. This RC file contains password in plain text.
Is there any way to hide that password in RC file?
Or is there any way to encrypt this RC file and use it?
Or is it possible to forcibly stop the server without giving id/pwd?
Any other approach is also welcome as long as password is not visible in plain text
Thanks in advance
I got alternative approach for this.
Connection c = DriverManager.getConnection(
"jdbc:hsqldb:file:/opt/db/testdb;shutdown=true", "SA", "");
create the connection as mentioned above.
Then execute sql query as given below
stmt.execute("shutdown");
This will shutdown the HSQL DB

SQL Agent File could not be found

This SQL job has been working for years on SQL Server 2000. I decided to move this SQL job to SQL server 2012.
I ran the job as normal, but keep getting the following error:
Error Code: 0 Error Source= Microsoft Word Error Description: This
file could not be found. Error on Line 21. The step failed. It
cannot locate the .dot file which is on a separate server.
Am I missing something now that it's on an update server?
oA2.Open "SELECT ID, Field1, Field2, Field2 FROM tblAppMapping WHERE Field2 is NOT NULL ORDER BY ID"
Set oW = CreateObject("Word.Application")
If oA("FileID") = "2" Then
oW.Documents.Add "\\fileserver\WordTemplates\Template App V1.dot"
Else
oW.Documents.Add "\\fileserver\WordTemplates\Template App V2.dot"
End If
Looks to me like a permissions / Access issue on the file location. I would check that the file physically exists and that the Database user (Service Agent) has correct permissions to the file location.