IBM DB2 - Can't Set Schema - sql

I am trying to use the command, SET SCHEMA. However, it does not appear to be working, I get an error message. I am able to use the schema if I use Schema.Tablename, but this can be tedious. I am perfectly connected to the database and all the schema properties appear in my schemas folder.
The error message is below:
------------------------------ Commands Entered ------------------------------
SET SCHEMA RSBALANCE;
------------------------------------------------------------------------------
SET SCHEMA RSBALANCE
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0805N Package "NULLID.SQLC2H20 0X41414141415A425A" was not found.
SQLSTATE=51002
SQL0805N Package "NULLID.SQLC2H20 0X41414141415A425A

The syntax for DB2 is (Info Center link):
SET SCHEMA = 'YOUR_SCHEMA'
If you're using the Command Line Processor (which it appears you are by the error message), you have to use double-quotes (it does matter!):
SET SCHEMA = "YOUR_SCHEMA"

Information Center has documentation on the SQL0805N error.
This is the relevant course of action:
If the DB2 utility programs need to be rebound to the database, the
database administrator can accomplish this by issuing one of the
following CLP command from the bnd subdirectory of the instance, while
connected to the database:
For the DB2 utilities:
db2 bind #db2ubind.lst blocking all grant public
For CLI::
db2 bind #db2cli.lst blocking all grant public

Turns out that my machine was missing an update from IBM. This allowed me to use the command from bhamby to work properly.
Thank you all for your input.

Related

Correct VBA Syntax for DB2 Command?

I'm attempting to connect to DB2 through VBA. I have a connection established through the ODBC provider.
Here's the string of my command text looks like:
strCmd = "INSERT INTO mySchema.myTable (Text) VALUES ('Test')"
When I run this, I get the following runtime error:
[IBM][CLI Driver][DB2/NT64] SQL0204N "MYSCHEMA.MYTABLE" is an undefined name. SQLSTATE=42704
I have validated and verified that the schema and table exist in DB2. I have validated (by using another tool - IBM Data Studio - that the credentials have access and authority to write to this table.
Is my syntax wrong? Is there something I'm missing? If I don't add the "MYSCHEMA." in front of the table name, it presumes I want the "ADMIN" schema, which I don't (it doesn't even exist).
How do I successfully execute an insert command to DB2 LUW?
This is frequently asked.
Db2 automatically folds unquoted object names into uppercase.
This makes programming easier because being forced to quote objects is not so friendly.
It means that "myTable"."mySchema" is a different object than MYTABLE.MYSCHEMA.
So in general it is easier to configure your toolset to not quote object names when creating the objects, and so allow them to be folded to uppercase. It also allows subsequent queries to avoid having to quote table names and column names.
But sometimes you don't have a choice.

Postgresql job scheduler using pgagent giving error with update query

I have created a job scheduler using pgagent in postgresql:
What I did is mentioned as screen shots
I had created like this to update name in my database field in a certain time. But when I check it is getting failed.
The failed status as follows:
What I did wrong? How can I correct it?
I have also faced the same problem exactly. By trial and error, I changed the Connection Type from Local to Remote and gave the following connection string
user=some_user password=some_password host=localhost port=5432 dbname=some_database
in the properties of the Step. And, it worked. So, the trick is to treat even the local server as a remote server.

Oracle DB & SQL Developer: "Error report: execution completed with warning" - How do I *see* the warning?

I'm setting up a local oracle (11g) database - a clone of another database we have running already. I'm running a bunch of generated PL/SQL commands in SQL Developer.
I get the output
Error starting at line x in command:
*long-ass SQL statement here*
Error report:
SQL Command: force view "someViewName"
Failed: Warning: execution completed with warning
How do I read the warning that has been generated without modifying the script?
when I use the show errors immediately after this command, I get the output no errors
If show errors doesn't give you anything:
select line, position, text
from user_errors
where type = 'VIEW'
and name = 'someViewName'
order by sequence;
That assumes you're creating it under your own schema; if not you can look in all_errors instead.
The columns are in the documentation:
ALL_ERRORS describes the current errors on the stored objects accessible to the current user.
DBA_ERRORS describes the current errors on all stored objects in the database.
USER_ERRORS describes the current errors on the stored objects owned by the current user. This view does not display the OWNER column.
The cause of the error is just simply forgetting your semi-colon at the end of your code. Or if it is PL/SQL you are forgetting your forward slash at the end.

Validate Hive HQL syntax?

Is there a programmatic way to validate HiveQL statements for errors like basic syntax mistakes? I'd like to check statements before sending them off to Elastic Map Reduce in order to save debugging time.
Yes there is!
It's pretty easy actually.
Steps:
1. Get a hive thrift client in your language.
I'm in ruby so I use this wrapper - https://github.com/forward/rbhive (gem install rbhive)
If you're not in ruby, you can download the hive source and run thrift on the included thrift configuration files to generate client code in most languages.
2. Connect to hive on port 10001 and run a describe query
In ruby this looks like this:
RBHive.connect(host, port) do |connection|
connection.fetch("describe select * from categories limit 10")
end
If the query is invalid the client will throw an exception with details of why the syntax is invalid. Describe will return you a query tree if the syntax IS valid (which you can ignore in this case)
Hope that helps.
"describe select * from categories limit 10" didn't work for me.
Maybe this is related to the Hive version one is using.
I'm using Hive 0.8.1.4
After doing some research I found a similar solution to the one Matthew Rathbone provided:
Hive provides an EXPLAIN command that shows the execution plan for a query. The syntax for this statement is as follows:
EXPLAIN [EXTENDED] query
So for everyone who's also using rbhive:
RBHive.connect(host, port) do |c|
c.execute("explain select * from categories limit 10")
end
Note that you have to substitute c.fetch with c.execute, since explain won't return any results if it succeeds => rbhive will throw an exception no matter if your syntax is correct or not.
execute will throw an exception if you've got an syntax error or if the table / column you are querying doesn't exist. If everything is fine, no exception is thrown but also you'll receive no results, which is not an evil thing
In the latest version hive 2.0 comes with hplsql tool which allows us to validate hive commands without actually running them.
Configuration:
add the below XML in hive/conf folder and restart hive
https://github.com/apache/hive/blob/master/hplsql/src/main/resources/hplsql-site.xml
To Run the hplsql and validate the query , please use the below command:
To validate Singe Query
hplsql -offline -trace -e 'select * from sample'
(or)
To Validate Entire File
hplsql -offline -trace -f samplehql.sql
If the query syntax is correct , the response from hplsql would be something like this:
Ln:1 SELECT // type
Ln:1 select * from sample // command
Ln:1 Not executed - offline mode set // execution status
if the query Syntax is wrong , the syntax issue in the query will be reported
If the hive version is older, we need to manually place the hplsql jars inside the hive/lib and proceed.

ORA-00980 error when attempting export using the EXP command

I'm trying to export a schema in an oracle 10 database using the EXP command. Let's call the schema "myschema" and the tns name "mydb" to protect the names of the innocent. Anyway, here's the command line that I'm using
exp myschema/mypassword#mydb file=myschema.dmp grants=y
This works when I try to run an export on other instances, but I get the following error when I try against "mydb".
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
server uses UTF8 character set (possible charset conversion)
. exporting pre-schema procedural objects and actions
. exporting foreign function library names for user MYSCHEMA
. exporting PUBLIC type synonyms
EXP-00008: ORACLE error 980 encountered
ORA-00980: synonym translation is no longer valid
EXP-00000: Export terminated unsuccessfully
Anybody have any ideas? If any further info is needed let me know and I'll edit this question accordingly.
This can happen if the JVM installation is corrupted. Try:
SELECT comp_id, schema, status, version, comp_name
FROM dba_registry
ORDER BY 1;
If this returns a row with the comp_id of JAVAVM with a status of 'INVALID' you'll need to reinstall the java VM.
Metalink document 276554.1 has the procedure for doing so. If you can recover easily, it might be easier to recreate the database and reload it.
EDIT: I found Oracle-base link where a poster claims this will uninstall and reinstall the JVM (on Unix), I presume it works on windows with slight mods:
(WARNING! You can seriously hose your database if things go wrong here. BACKUP first!)
cd $ORACLE_HOME/javavm/install
sqlplus / as sysdba
#rmjvm.sql
#initjvm.sql
-- Recompile invalid objects
#?/rdbms/admin/utlrp
The metalink note is quite a bit more involved.