I am running Oracle APEX 21.1 (build 21.1.3.r1531102) on the 21c express database and for some reason I cannot execute server side code with the JavaScript MLE option.
In the develpment environment it does not show the option at all.
In the SQL commands screen I can only execute pure sql or PL/SQL. If I try to execute the following example
SET SERVEROUTPUT ON;
DECLARE
ctx dbms_mle.context_handle_t;
user_code clob := q'~
console.log('Hello World!');
~';
BEGIN
ctx := dbms_mle.create_context();
dbms_mle.eval(ctx, 'JAVASCRIPT', user_code);
dbms_mle.drop_context(ctx);
EXCEPTION
WHEN others THEN
dbms_mle.drop_context(ctx);
RAISE;
END;
I get the following message:
ORA-00922: missing or invalid option
ORA-06512: at "SYS.WWV_DBMS_SQL_APEX_210100", line 673
ORA-06512: at "SYS.DBMS_SYS_SQL", line 1703
ORA-06512: at "SYS.WWV_DBMS_SQL_APEX_210100", line 659
ORA-06512: at "APEX_210100.WWV_FLOW_DYNAMIC_EXEC", line 1854
A few weeks ago we solved this and I forgot to update this question.
After some work we found out that user needed to be granted access to MLE. I was not that one who fixed, but I've asked the code to post here, check below:
GRANT MLE JAVA
GRANT EXECUTE DYNAMIC MLE to XYZ;
GRANT EXECUTE ON JAVASCRIPT TO XYZ;
Remove the first line or comment this out, I suppose this is for on premise DB version support but not allowed in ADB.
Related
When I execute the following statement that involves a UTL_HTTP.REQUEST call, I get ORA-29024: Certificate validation failure:
SELECT UTL_HTTP.REQUEST('https://www.google.com') from DUAL;
ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1620
ORA-29024: Certificate validation failure
ORA-06512: at "SYS.UTL_HTTP", line 380
ORA-06512: at "SYS.UTL_HTTP", line 1560
ORA-06512: at line 1
According to the Autonomous Database doc, UTL_HTTP is among the supported PL/SQL packages. Why is this query not working?
This error is a result of not completing the prerequisite steps for UTL_HTTP in Autonomous Database. As mentioned in the example from the doc, before calling the UTL_HTTP.REQUEST() procedure, we need to first create an Access Control List (ACL) for the host via the DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE() and set the wallet location via UTL_HTTP.SET_WALLET():
-- Create an Access Control List for the host
BEGIN
DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
host => 'www.google.com',
ace => xs$ace_type(privilege_list => xs$name_list('http'),
principal_name => 'ADMIN',
principal_type => xs_acl.ptype_db));
END;
/
PL/SQL procedure successfully completed.
-- Set Oracle Wallet location (no arguments needed)
BEGIN
UTL_HTTP.SET_WALLET('');
END;
/
PL/SQL procedure successfully completed.
SELECT UTL_HTTP.REQUEST('https://www.google.com') from DUAL;
utl_http.request('https://www.google.com')
-------------------------------------------------------------------------------------
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en"> ...
Disclaimer: I’m a Product Manager at Oracle.
I have XE on my computer, using Oracle Database 18c. Earlier, I was able to execute function dbms_output.put_line(); even I logged in as sysadmin or with default role. Now, I only can run dbms_output.put_line() when I am logged in as sysadmin/sysdba. As a default user, I get the following message:
PLS-00201: identifier ‘DBMS_OUPUT.PUT_LINE’ must be declared
I tried to add privilege to execute dbms_output with command
grant execute on DBMS_OUTPUT to username;, however, I got this message when I execute a command including dbms_output.put_line():
ORA-04067: not executed, package body "PERFSTAT.DBMS_OUTPUT" does not exist
ORA-06508: PL/SQL: could not find program unit being called: "PERFSTAT.DBMS_OUTPUT"
Using sqlplus, I get the following error as default user:
PLS-00201: identifier 'DBMS_OUTPUT.ENABLE' must be declared
How can I solve this problem?
That's probably because you misnamed it:
No : DBMS_OUPUT.PUT_LINE (not "ouput" but "output")
Yes: DBMS_OUTPUT.PUT_LINE
As of the 2nd message; well, this: PERFSTAT.DBMS_OUTPUT doesn't make sense, PERFSTAT doesn't own that package. It is called just as
begin
dbms_output.put_line('Hello');
end;
/
and works for any user, no special grants required.
I want to be able to call a procedure in an Oracle database using Clojure.
I have a connection to an Oracle database and I can query the tables of the db using select queries with parameters.
E.g.: If I run "SELECT * FROM user_tables" I get the list of tables as the result. So the connection is working and I do have the correct credentials to make this connection.
I'm using the following dependencies:
[org.clojure/clojure "1.10.1"]
[org.clojure/java.jdbc "0.7.11"]
and as oracle driver I tried these
[oracle.jdbc/oracledriver "11.2.0.2"] (ojdbc6 driver I installed locally under this name)
[oracle.jdbc/ojdbc7 "12.1.0.2"]
[com.oracle/ojdbc8 "19.3.0.0"] or [oracle.jdbc/ojdbc8 "12.2.0.1"]
My java version is:
java version "1.8.0_271"
Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.271-b09, mixed mode)
Using the ojdbc6 driver results in:
Execution error (SQLException) at oracle.jdbc.driver.T4CTTIoer/processError (T4CTTIoer.java:440).
ORA-29481: Implicit results cannot be returned to client.
ORA-06512: at "SYS.DBMS_SQL", line 2785
ORA-06512: at "SYS.DBMS_SQL", line 2779
ORA-06512: at "<My procedure name>", line 157
ORA-06512: at line 1
Using the version 7 or 8 result in:
#:next.jdbc{:update-count -1}
Can anyone help me to solve this in such a way that I can see the same result set as in SQL-Developer?
Clojure code used to make the connection:
(defstate ^:dynamic *oracle*
"This variable has the database connection to the Oracle Database"
:start
(if-let [jdbc-url (:oracle (env :database-url))]
(conman/connect! {:jdbc-url jdbc-url})
(do
(log/warn "database connection URL was not found, please set :database-url for oracle in your config, e.g: dev-config.edn")
*oracle*))
:stop
(conman/disconnect! *oracle*))
(conman/bind-connection *oracle* "sql/queries-oracle.sql")
In resources/sql there is the file queries-oracle.sql which contains the procedure to be called. I tried several ways to call it:
EXEC schema_name.procedure_name :param1, :param2, :param3;
EXEC schema_name.procedure_name(:param1, :param2, :param3);
BEGIN EXEC schema_name.procedure_name :param1, :param2, :param3; END;
BEGIN schema_name.procedure_name :param1, :param2, :param3; END;
All these have a :name through which they are called. Which I'm now trying from a REPL.
The result of these tries is:
Invalid SQL-Statement
Invalid SQL-Statement
Encountered the symbol "schema_name" when expecting one of the follwing:...
#:next.jdbc{:update-count -1}
I'm using strimzi Kafka operator to work with a Confluent Cluster to achieve an Oracle2Kafka type KafkaConnector with JdbcSourceConnector from confluent.
The KafkaConnector spec
# connector
connection.url: jdbc:oracle:thin:#HOST:PORT/SERVICE
connection.user: USER
connection.password: PASS
dialect.name: OracleDatabaseDialect
topic.prefix: test-topic-
mode: bulk
db.timezone: Europe/Madrid
table.whitelist: TEST_TABLE
But I get the following error in the strimzi-cluster-operator logs.
io.strimzi.operator.cluster.operator.assembly.ConnectRestException: PUT /connectors/confluent-cluster-int-20200706-02/config returned 400 (Bad Request): Connector configuration is invalid and contains the following 2 error(s):
Invalid value java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 43
for configuration Couldn't open connection to jdbc:oracle:thin:#***:1534/***
Invalid value java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 43
for configuration Couldn't open connection to jdbc:oracle:thin:#***:1534/***
You can also find the above list of errors at the endpoint `/connector-plugins/{connectorType}/config/validate`
at io.strimzi.operator.cluster.operator.assembly.KafkaConnectApiImpl.lambda$null$2(KafkaConnectApi.java:208) ~[io.strimzi.cluster-operator-0.18.0.jar:0.18.0]
If I modify the source I get a much specific stacktrace
2020-07-14 09:33:46,636 ERROR SQLException (io.confluent.connect.jdbc.source.JdbcSourceConnectorConfig) [qtp742672280-21]
java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 43
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:509)
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:456)
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:451)
at oracle.jdbc.driver.T4CTTIfun.processError(T4CTTIfun.java:1123)
at oracle.jdbc.driver.T4CTTIoauthenticate.processError(T4CTTIoauthenticate.java:552)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:553)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:269)
at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:501)
at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:1292)
at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:1025)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:747)
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:793)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:57)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:747)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:562)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
at io.confluent.connect.jdbc.dialect.GenericDatabaseDialect.getConnection(GenericDatabaseDialect.java:223)
at io.confluent.connect.jdbc.source.JdbcSourceConnectorConfig$TableRecommender.validValues(JdbcSourceConnectorConfig.java:606)
at io.confluent.connect.jdbc.source.JdbcSourceConnectorConfig$CachingRecommender.validValues(JdbcSourceConnectorConfig.java:653)
at org.apache.kafka.common.config.ConfigDef.validate(ConfigDef.java:607)
at org.apache.kafka.common.config.ConfigDef.validate(ConfigDef.java:622)
at org.apache.kafka.common.config.ConfigDef.validate(ConfigDef.java:530)
at org.apache.kafka.common.config.ConfigDef.validateAll(ConfigDef.java:513)
at org.apache.kafka.common.config.ConfigDef.validate(ConfigDef.java:495)
at org.apache.kafka.connect.connector.Connector.validate(Connector.java:135)
Some things I already checked
KafkaConnect image is a self-made one with the required addons for the JdbcSourceConnector with an OracleDriver
Dockerfile
FROM strimzi/kafka:0.18.0-kafka-2.5.0
USER root:root
COPY ./kafka-connect-jdbc-5.4.0.jar /opt/kafka/plugins/
COPY ./ojdbc6.jar /opt/kafka/libs/
USER 1001
KafkaConnect resource is deployed successfully, as KafkaConnect topics are being populated on confluent cluster (connect-cluster-configs, connect-cluster-configs, ...)
Oracle driver seems to be successfully loaded. If I add a typo in the credentials or connection chain the error is self-explanatory and makes sense. I also tried other versions of oracle drivers.
Back in time (4 months ago), this same config was working (both on a local strimzi-deployed-cluster and confluent). Now the local cluster works fine, but confluent one fails with the described error.
Tried several upgraded latest versions of strimzi operator and kafka-jdbc-connector
(edit) As suggested in strimzi slack, tried the PUT /connector-plugins/JdbcSourceConnector/config/validate rest endpoint of KafkaConnect and got same 2 errors, in the whitelist and blacklist fields
result
"value": {
"name": "table.blacklist",
"value": "",
"recommended_values": [],
"errors": ["Invalid value java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1\nORA-06502: PL/SQL: numeric or value error: character string buffer too small\nORA-06512: at line 43\n for configuration Couldn't open connection to jdbc:oracle:thin:#***:1534/***"],
"visible": true
}
(edit) I've tried to leave whitelist field empty and error is the same. The database seems not have been changed and the connection chain works fine from source code spring-data access.
I'm out of ideas, any hint is welcome x)
I don't know tools you use, but - the error you got means this:
SQL> declare
2 l_var varchar2(1); -- note length, only 1 character
3 begin
4 l_var := 'Littlefoot'; -- I'm little, but can't fit
5 end;
6 /
declare
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 4
SQL>
What to do?
SQL> declare
2 l_var varchar2(20); -- is that enough?
3 begin
4 l_var := 'Littlefoot';
5 end;
6 /
PL/SQL procedure successfully completed. --> Yes, it is!
SQL>
Therefore, check the sizes in your code.
I was trying to execute PL/SQL scripts on SQuirrel but it doesn't seem to work.
I configured Oracle Thin Driver by adding ojdbc7.jar on "Extra Class Path", was able to connect to the database but when tried to run a simple code it gives an error:
-- code
BEGIN
dbms_output.put_line('Hello World');
END;
/
-- error
Error: ORA-06550: line 2, column 37:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
:= . ( % ;
SQLState: 65000
ErrorCode: 6550
Error occurred in:
BEGIN
dbms_output.put_line('Hello World')
Am I doing anything wrong?
This statement worked for me (the / is necessary for SQuirrel SQL Client):
BEGIN
dbms_output.put_line('Hello World');
END;
/
However, you won't see the output in the usual Results tab. You need to open the Oracle Database Output window. As far as I can see you can only open it with a button on the toolbar. You'll also need to enable auto refresh or manually refresh the output.
can you try this:
BEGIN
dbms_output.put_line('Hello World');
END;
by removing /
When installing the SQuirreL, try including the Oracle Plugin. This works for me in version 3.8.1.
Oracle plugin for Squirrel is needed for executing queries in BEGIN - END;
Had the same problem untill reinstalled squirrel with Oracle plugin.