Why Oracle weblogic server logs does not show DBMS_OUTPUT.PUT_LINE outputs? - plsql

I have included some DBMS_OUTPUT.PUT_LINE inside my PLSQL package procedure. I wanted print these output in weblogic application server logs. But it does not show my DBMS_OUTPUT in weblogic server log. Currently, I use Log4j for server logging. Is there any extra configuration needed for this ? Thanks

Did you SET SERVEROUTPUT ON? Without it, DBMS_OUTPUT.PUT_LINE won't display anything.
This is what you have:
SQL> begin
2 dbms_output.put_line('Hello, this is me!');
3 end;
4 /
PL/SQL procedure successfully completed.
When output is enabled:
SQL> set serveroutput on
SQL> begin
2 dbms_output.put_line('Hello, this is me!');
3 end;
4 /
Hello, this is me!
PL/SQL procedure successfully completed.
SQL>

Related

handler command failed after migrating mariadb from 10.5.15 to 10.5.16

I have a HANDLER command which works in MariaDB 10.5.15 but fails on 10.5.16.
HANDLER INDEX_NAME READ INDEX_NAME = (....,'......') LIMIT 1;
The failure happens in'mysql_store_result'.
is there any change in 10.5.16 causing the failure?
from 10.6.x, works again.

Aurora failover leaves connections open as read-only state

We are using MySQL in Aurora cluster
We have 2 instances - master and slave.
We are working with spring transactions on top of a c3po connection pool.
We are using mariadb jdbc driver (version 2.2.3).
Our url looks like this -
jdbc:mysql:aurora:myclaster-cluster.cluster-xxxxxx.us-east-1.rds.amazonaws.com:3306/db?rewriteBatchedStatements=true
When testing failover; every few failovers we get into a state of using a read only connection -
Caused by: org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [INSERT INTO a (a1, a2, a3, a4) VALUES (?, ?, ?, ?) on duplicate key update ]; SQL state [HY000]; error code [1290]; (conn=7) The MySQL server is running with the --read-only option so it cannot execute this statement; nested exception is java.sql.SQLException: (conn=7) The MySQL server is running with the --read-only option so it cannot execute this statement
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:84)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:645)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:866)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:927)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:937)
at com.persistence.impl.MyDao.insert(MyDao.java:52)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:75)
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
... 1 common frames omitted
Caused by: java.sql.SQLException: (conn=7) The MySQL server is running with the --read-only option so it cannot execute this statement
at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:198)
at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:110)
at org.mariadb.jdbc.MariaDbStatement.executeExceptionEpilogue(MariaDbStatement.java:228)
at org.mariadb.jdbc.MariaDbPreparedStatementClient.executeInternal(MariaDbPreparedStatementClient.java:216)
at org.mariadb.jdbc.MariaDbPreparedStatementClient.execute(MariaDbPreparedStatementClient.java:150)
at org.mariadb.jdbc.MariaDbPreparedStatementClient.executeUpdate(MariaDbPreparedStatementClient.java:183)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:410)
at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:873)
at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:866)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:629)
... 9 common frames omitted
How can we force the driver to return connections only to the master instance? Is there a way to force aurora to close all open connection upon failover?
Thanks
We solved the problem by implementing an ExceptionInterceptor, in which we closed the connection, forcing the pool to create a new one.
This workround is relevant for mysql-connector-java 5.1.47
#Override
public SQLException interceptException(SQLException sqlEx, Connection conn) {
if (sqlEx.getErrorCode() == READ_ONLY_ERROR_CODE) {
log.warn("Got read only exception closing the connection {} ", sqlEx.getMessage());
closeConnection(conn);
}
return sqlEx;
}

EXECUTE statement failed because its WITH RESULT SETS clause specified 1 result set

I'm trying to run a simple R code in SQL Server 2016:
EXEC sp_execute_external_script
#language =N'R',
#script=N'OutputDataSet<-InputDataSet',
#input_data_1 =N'SELECT 1 AS hello'
WITH RESULT SETS (([hello] int not null));
GO
I have followed this link to configure: https://tomaztsql.wordpress.com/2016/07/26/enabling-sp_execute_external_script-to-run-r-scripts-in-sql-server-2016/
I'm getting error:
Msg 39023, Level 16, State 1, Procedure sp_execute_external_script,
Line 1 [Batch Start Line 0]
'sp_execute_external_script' is disabled on this instance of SQL
Server. Use sp_configure 'external scripts enabled' to enable it.
Msg 11536, Level 16, State 1, Line 1
EXECUTE statement failed because its WITH RESULT SETS clause specified 1
result set(s), but the statement only sent 0 result set(s) at run time.
when I checked with :
EXECUTE sp_configure;
GO
The result shows like this:
name minimum maximum config_value run_value
external scripts enabled 0 1 1 0
Why the run value is still 0 (note-I have SQL Server Launchpad restarted)? What is the resolution for this?
Issue resolved. need to restart SQL Server services. Which will restart everything. And its working fine.

FAST LOAD - FDL4818 FastLoad Terminated Error

I have created Below fast load scripts which is loading data from flat file to teradata table.
fastload << EOF >> ${BASE_DIR}/Test_Load_Fastload_log
SESSIONS 4;
.logon ${TDPID}/${TD_LOGON}
SET RECORD VARTEXT " ";
Define
WSID (VARCHAR(10)),
Server_Name (VARCHAR(30)),
Technology (VARCHAR(50)),
Env (VARCHAR(10))
File=$BASE_DIR/workstation_source.dat;
BEGIN LOADING WORK_DB.WS_test
ERRORFILES WORK_DB.WS_test_Err1,WORK_DB.WS_test_Err2
;
INSERT INTO WORK_DB.WS_test VALUES
(:WSID,
:Server_Name,
:Technology,
:Env );
END LOADING;
This is loading data successfully in table but giving return code as 0.
But after that fast load is being teminated with FDL4818 FastLoad Terminated Error.
Below is the log.
06:37:08 Logging off all sessions
* 06:37:09 Total processor time used = '0.1 Seconds'
. Start : Thu Jun 6 06:37:04 2013
. End : Thu Jun 6 06:37:09 2013
. Highest return code encountered = '0'.
*** 06:37:09 FDL4818 FastLoad Terminated
Try including a .QUIT; or a .LOGOFF; command at the end of your script.
EDIT
The FDL4818 FastLoad Terminated message is a normal part of the completion message for a FastLoad job that has completed outside the Loading Phase. FastLoad jobs completing within the Loading Phase will display FDL4818 FastLoad Paused instead.
This completion message will not affect the return code that is returned to the operating system or parent process.
This a message not an error.
You should check the following part of the message to check if there was an error or not:
* Highest return code encountered = *
If the value is 0, as in your case, the job is completed successfully without any ERROR.
If value is other than 0, e.g 8 or 12, there is some error.

Error : PLS-00103: Encountered the symbol "END" when expecting one of the following

I wrote the following Package and Package body:
create or replace package discounts
is
g_id number := 7839;
discount_rate number := 0.0;
procedure display_price(p_price number);
end;
/
create or replace package body discounts
is
procedure display_price(p_price number)
is
begin
dbms_output.put_line('Discount rate 1:'||discount_rate);
dbms_output.put_line('Discounted '||to_char(p_price * nvl(discount_rate,0)));
dbms_output.put_line('Discount rate 2:'||discount_rate);
end;
begin
dbms_output.put_line('Discount rate 3:'||discount_rate);
discount_rate := 0.10;
dbms_output.put_line('Discount rate 4:'||discount_rate);
end;
/
It is written that "The value of discount_rate is set to 0.10 when the package is invoked for the first time in a session". I am not getting this point exactly that's why I checked the value each time of discount rate. I typed the following to invoke:
SQL> execute discounts.display_price(1000);
Discount rate 3:0
Discount rate 4:.1
Discount rate 1:.1
Discounted 100
Discount rate 2:.1
Then again I invoked the variable:
begin
dbms_output.put_line('Discount rate :'||discounts.discount_rate);
end;
SQL> /
Discount rate :.1
Then I typed "exit" to close the SQL *PLUS. Again I opened SQL *PLUS and typed the same code:
begin
dbms_output.put_line('Discount rate :'||discounts.discount_rate);
end;
I thought it will not initialize the variable but I got the error:
ERROR at line 3:
ORA-06550: line 3, column 1:
PLS-00103: Encountered the symbol "END" when expecting one of the following:
:= . ( % ;
The symbol ";" was substituted for "END" to continue.
What is the mistake ? I am new to PL/SQL preparing for certification exam.
Sorry, I could not reproduce the error you showed:
C:\>sqlplus user/password
SQL*Plus: Release 11.2.0.2.0 Production on Sat Mar 23 11:31:19 2013
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
SQL> set serveroutput on
SQL> execute discounts.display_price(1000);
Discount rate 3:0
Discount rate 4:.1
Discount rate 1:.1
Discounted 100
Discount rate 2:.1
PL/SQL procedure successfully completed.
SQL> begin
2 dbms_output.put_line('Discount rate :'||discounts.discount_rate);
3 end;
4 /
Discount rate :.1
PL/SQL procedure successfully completed.
SQL> exit
Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
C:\>sqlplus user/password
SQL*Plus: Release 11.2.0.2.0 Production on Sat Mar 23 11:31:50 2013
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
SQL> set serveroutput on
SQL> begin
2 dbms_output.put_line('Discount rate :'||discounts.discount_rate);
3 end;
4 /
Discount rate 3:0
Discount rate 4:.1
Discount rate :.1
PL/SQL procedure successfully completed.
SQL>

Resources