How to suppress script display after PLSQL Error in SQL Developer (disable command/code output) - plsql

When i run PLSQL block with an error, SQL Developer repeats/duplicates the whole script before giving error details. This is very gruesome as i for long script, i end up scrolling down after each error.
I need to find a way to disable writing the whole script into the script console. I checked Preferences and help, but didn't spot anything related.
Error starting at line : 1 in command -
BEGIN
xx;
END**;
Error report -
ORA-06550: line 2, column 5:
PLS-00201: identifier 'XX' must be declared
ORA-06550: line 2, column 5:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
I can also confirm that sqlplus does not do this - it only shows single line containing the error.

I guess, you didn't understand my comment clearly.
I advised you doing something like this:
BEGIN
...
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Call stack:');
DBMS_OUTPUT.PUT_LINE(DBMS_UTILITY.FORMAT_CALL_STACK);
DBMS_OUTPUT.PUT_LINE(CHR(10)||'Error stack:');
DBMS_OUTPUT.PUT_LINE(DBMS_UTILITY.FORMAT_ERROR_STACK);
DBMS_OUTPUT.PUT_LINE(CHR(10)||'Error backtrace:');
DBMS_OUTPUT.PUT_LINE(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
END;
/

Related

SQR - how to use FROM [dynamic table name} within BEGIN-SELECT?

I have to create an SQR that generates a list of EEIDs, if there were any changes to the Pension data in the past day. The SQR compiles and works perfectly when I hardcode in the table names.
However, when I tried using variables for the table names, I get a compile error
I've pasted the portion of SQR that I'm trying to fix
When I start using $tableName and $auditTableName as table variables, that's when I get the error and I'm not sure what is going wrong
Can anyone help?
Please and Thank You
!***************************
begin-procedure Process-Main
!***************************
let $tableName = 'PS_PENSION_PLAN'
let $auditTableName = 'PS_AUDIT_PENSION_PLN'
let $dummy-dyn-variable = ''
begin-SELECT DISTINCT
L.EMPLID
L.EMPL_RCD
do someProcName(&L.EMPLID, &L.EMPL_RCD)
FROM [$dummy-dyn-variable]
(
SELECT DISTINCT
PP.EMPLID,
PP.EMPL_RCD,
PP.EFFDT,
'1901-01-01 12:00:00' AS AUDIT_STAMP
FROM [$dummy-dyn-variable] [$tableName] PP
UNION
SELECT DISTINCT
A.EMPLID,
A.EMPL_RCD,
A.EFFDT,
A.AUDIT_STAMP
FROM [$dummy-dyn-variable] [$auditTableName] A
)L
WHERE DATEDIFF(DAY,CAST(L.AUDIT_STAMP AS DATE),SYSDATE) = 1
ORDER BY 1,2
end-SELECT
end-procedure
Edit:
does the UNION have anything to do with this?
I keep receiving is this error:
(SQR 5528) ODBC SQL dbdesc: SQLNumResultCols error 102 in cursor 1:
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'FROM'.
(SQR 5528) ODBC SQL dbdesc: SQLNumResultCols error 8180 in cursor 1:
[Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared.
Edit2:
Ok, initial problem solved with [$dummy-dyn-variable], which led to the next problem with the DO command. I've updated the code above with DO someProcName(param_a, param_b)
I am now getting an error saying:
(SQR 2002) DO arguments do not match procedure's
Weird part, if I remove the dynamic table variables and hardcode the table names in the FROM section, then it compiles properly without errors. This makes me believe that the error is not related to my someProcName (maybe?)
am I missing something here?

How to refer tests to source/test files in utPLSQL?

I could use a little hand with utPLSQL.
I am trying to produce the test results so that Sonar would pick it up and scan them. so far, Sonar is picking up the report file, but the test executions are ignored because they are not referencing to the appropriate source files.
I am trying to make a reference to the source and test files when running ut.run(ut_sonar_test_reporter()); and our Jenkins does not have utPLSQL-cli installed. Short version: They said they will not install it.
To get a result for a single test, I tried the following:
spool sonar_results.xml;
exec ut.run('test_get_something');
exec ut.run(ut_sonar_test_reporter(), a_source_file_mapping => ut_file_mappings(ut_file_mapping(file_name => 'this_dir/get_something.fnc', object_owner=> 'GET_SOMETHING_OWNER', object_name=> 'GET_SOMETHING', object_type=>'FUNCTION'));
spool off;
And got the following error message:
Error starting at line : 4 in command -
BEGIN ut.run(ut_sonar_test_reporter(), a_source_file_mapping => ut_file_mappings(ut_file_mapping(file_name => 'this_dir/get_something.fnc', object_owner=> 'GET_SOMETHING_OWNER', object_name=> 'GET_SOMETHING', object_type=>'FUNCTION'));
Error report -
ORA-06550: line 1, column 219:
PLS-00306: wrong number or types of arguments to call to 'RUN'
ORA-06550: line 1, column 219
PL/SQL: Statement ignored
utPLSQL's documentation doesn't provide anything about referencing parameters like a_source_file_mapping or a_test_file_mapping.
I am a little stumped.

Make SQLite abort on first error (and sing songs)

I wanted to name this post Make SQLite abort on first error but StackOverflow's AI overlords decided it doesn't fit their conception of intelligent human behavior. For the record, I was googling exactly that, but perhaps even Google AI considered my question unworthy and didn't bother to help me. Mods, feel free to change the title according to what your AI bosses desire (if you can figure it out).
I have this script
create if not exists table entries (
id integer primary key,
start datetime not null,
end datetime not null
);
delete from entries;
insert into entries values (1, '2018-08-01 10:00', '2018-08-01 15:00');
insert into entries values (2, '2018-08-01 17:00', '2018-08-01 20:00');
insert into entries values (1, '2018-08-02 19:00', '2018-08-02 00:00');
insert into entries values (1, '2018-08-03 00:00', '2018-08-03 04:00');
insert into entries values (1, '2018-08-03 14:00', '2018-08-03 18:00');
There is a mistake in create statement. When I run the script I get
% sqlite3 db.sqlite3 <ddl.sql
Error: near line 1: near "if": syntax error
Error: near line 7: no such table: entries
Error: near line 8: no such table: entries
Error: near line 9: no such table: entries
Error: near line 10: no such table: entries
Error: near line 11: no such table: entries
Error: near line 12: no such table: entries
How do I make SQLite exit executing the script on first error it encounters? I'm looking for equivalent of set -e in Bash.
From the documentation, it looks like you can turn on the dot command .bail.
.bail on|off Stop after hitting an error. Default OFF
See also - O'Reilly Using Sqlite
Edit
To exit, you can use the .exit dot command.

ORACLE-06512 error while running utlpwdmg.sql

I am trying to increase the complexity of password rules for the databases I manage. As a result, I made few additions to the utlpwdmg.sql file.
This file does not result in compilation errors but while running it, I get the following error messages.
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at "ISU_DBA_SCHED.VERIFY_FUNCTION_11G", line 49
ORA-06512: at line 11
At Line 49
-- Check if the password is same as the username reversed
FOR i in REVERSE 1..length(username) LOOP
reverse_user := reverse_user || substr(username, i, 1);
END LOOP;
IF NLS_LOWER(password) = NLS_LOWER(reverse_user) THEN
raise_application_error(-20004, 'Password same as username reversed');
END IF;
At Line 11
-- ispunct boolean;
Note:
I use SQL Developer to run utlpwdmg.sql
I checked the entire program for data type mismatches and data length issues but found nothing that could cause ORACLE-06502
It is unclear while my code results in ORA-06512

Execute Immediate with multiple SQL Statements

Here is my PL/SQL.
execute immediate '
create table Alex_Test2(col1 varchar2(100));
/
drop table Alex_Test2;
/
';
In the dynamic SQL, a table is created and then dropped immediately. The funny thing is that the table is successfully created and dropped but I got error.
Error starting at line 1 in command:
execute immediate '
Error report:
ORA-06550: line 1, column 17:
PLS-00103: Encountered the symbol "; END;" when expecting one of the following:
:= . ( # % ;
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
table ALEX_TEST2 created.
table ALEX_TEST2 dropped.
Error starting at line 6 in command:
'
Error report:
Unknown Command
The SQL statements actually typed by user. I cannot avoid the symbols like ; and /. How can I fixed this problem? Or how can I bypass this error?
However, I still need to keep the log. I expect the log is just
table ALEX_TEST2 created.
table ALEX_TEST2 dropped.
Thanks!
You are unable to manipulate the query string before executing it? If you don't have the ability to do that then what do you have the ability to do?
Sounds like you just need to do a find and replace on the query string before running it.

Resources