Errorlevel for ABAP syntax checker errors? - abap

There exists a Table in SAP for the syntax errors of the ABAP compiler (table TRMSG), but the table does not store the errorlevels. (I.E whether an error should be displayed as Error, Warning or Information ).
I tried to look what the SCI does to generate the syntax errors, but it uses a keyword based function to generate them and therefore it is not traceable where the errorlevel comes from. (Waring, Error and Information)
For completion the keyword based function to check the syntax:
syntax-check for temp_itab_loc
directory entry dic
message message
line line
word word
include include
message-id message_id
id 'ERR' table errors
id 'MSG' table warnings
id 'INFO' table infos
id 'LTXT' table longtext
id l_part table l_dummy.
Is there an other table where I can link an error with a level?

I would run GENERATE SUBROUTINE POOL , and from there know whether there is an error, if there is no error, then I would run syntax check.

Related

Hello this is my first time creating a procedure but I keep getting the SQL STATEMENT IGNORED error. Any help would be appreciated

My Procedure
The errors I am getting.
Check your schema.table_name. On your insert statement, you have MEMBER_ONLY yet on your update, you have MEMBERS_ONLY (Plural).
Also, if I am not mistaken the top part is also incorrect.
CREATE PROCEDURE procedurename
(
#paramname int
)
As
This is, obviously, Oracle.
Error stack points to exact error place, e.g.
Error(22,29): PL/SQL: ORA-00942: table or view does not exist
-- --
^ column 29
|
line 22
It would be easier to spot it if you chose to display line numbers in SQL Developer (do so; right-click the left margin and set it). I'd say that it is about member_system.member table. Another one, in the same from clause, is prospect_staging.magi_applicant.
It is unclear which user you're connected to (one, or none of these), but - comment you posted in deleted answer:
It works in the workbench but when I place it in the procedure it says the table or view isn't created
suggests that you might have got access to the table via role (and not directly to your user). Why? Because privileges acquired via roles work at SQL level or in anonymous PL/SQL blocks, but won't work in named PL/SQL procedures or functions - and that's what you have, a procedure named get_magi_applicant_data.
So, what to do? Grant privileges directly.
As of another error you got:
Error(31,9): PLS-00201: identifier 'V_INSERT_OR_UPDATE' must be declared
Looks like it is about if v_insert_or_update is null then line. Error isn't obvious; there is v_insert_or_update local variable declared in the procedure, so I can't guess what might be wrong here.

Error when using the MERGE command in DB2

I'm trying to update or insert data into a table using the MERGE command in DB2 v11. However I keep getting the error:
SQL0723N An error occurred in a triggered SQL statement in trigger "TRACE_AFTE".
Information returned for the error includes SQLCODE "-746", SQLSTATE "57053" and message tokens
"CUSTOM_AFTER_UPDAT|SP_CUSTOM_AFTER_U". SQLSTATE=09000"
I looked up the error and it said that the routine conflicted with the use of the table..that the table is already in use.
I've tried changing the query to update based on VALUES instead of table but get an error on an unexpected token
SQL0104N An unexpected token "INSERT" was found following "MATCHED THEN".
Expected tokens may include: "". SQLSTATE=42601
"
MERGE INTO TRACE target
USING IMPORT_RAW source
ON target.DETAIL_NUMBER = source.DETAIL_LINE_ID
AND target.DESC = source.TRACE_TYPE
WHEN MATCHED THEN
UPDATE SET NUMBER = source.PRO
With VALUES
MERGE TRACE AS T
USING IMPORT_RAW AS S
ON (T.DETAIL_NUMBER= S.DETAIL_LINE_ID) AND T.DESC = S.TRACE_TYPE
WHEN NOT MATCHED BY TARGET
THEN INSERT(DETAIL_NUMBER, TRACE_NUMBER) VALUES(S.DETAIL_LINE_ID, S.CARRIER_PRO)
WHEN MATCHED
THEN UPDATE SET T.NUMBER= S.PRO;
The query should update multiple records from the Import_raw table where the record exists and import where it doesn't.
What am I doing wrong?
Thanks for the help. It seems like the problem was that it was trying to merge the same record twice. My truncate table had been commented out.

Liquibase don't log errors on constraint violation

I'm working on a spring boot application where we are using liquibase to keep up to date the DB.
We have a scenario when we import some JSON data, which is kept as varchar into a table on SQL Server. This JSON contains UI configurations and sometimes the developers forget to check if the JSON is valid before importing the data, resulting on errors in UI because of invalid JSON.
In order to prevent this kind of errors we added a constraint on DB level to make sure the data contains only valid JSON, but when we run the application,
using an invalid JSON, there is no crash or errors logged - SQL error is silently ignored.
My liquibase changeset:
<changeSet author="my.name" id="02_my_script" runOnChange="true" failOnError="true" >
<sqlFile dbms="h2, oracle, mssql" encoding="utf8"
endDelimiter="\nGO"
path="classpath:sql/02_my_script.sql"
relativeToChangelogFile="false" splitStatements="true" stripComments="true"/>
02_my_script.sql - contains a sql script which contains a JSON, something like this (I cannot use the real json):
DELETE FROM My_Table WHERE ID = 1;
INSERT INTO My_Table (Json)
VALUES ('{
"name" : "Test"
"firstName" : "ABC"
}');
The constraint on My_Table:
ALTER TABLE My_Table ADD CONSTRAINT Chk_JSON_is_json CHECK (ISJSON(Json) > 0)
If I try to run the script directly on the DB then I get an error as expected.
Is there a setting we can use in order to make liquibase show an error when there is a constraint violation ? Or maybe a configuration just to log the error in a log file?
Liquibase version I use is 3.5.3
There is a bug reported in Liquibase Jira related to this behavior.
I did a little bit of debug in Liquibase source code and I found in JdbcExecutor.ExecuteStatementCallback#doInStatement method a call
stmt.execute(statement); and according to the java doc
Executes the given SQL statement, which may return multiple results.
In some (uncommon) situations, a single SQL statement may return
multiple result sets and/or update counts. Normally you can ignore
this unless you are (1) executing a stored procedure that you know may
return multiple results or (2) you are dynamically executing an
unknown SQL string. The execute method executes an SQL statement and
indicates the form of the first result. You must then use the methods
getResultSet or getUpdateCount to retrieve the result, and
getMoreResults to move to any subsequent result(s).
I think I was in the second case ("executing an unknown SQL string"), and the the exception was not thrown. When I called getMoreResults method from the debugger the exception was thrown.
I was able to workaround the problem by creating a custom liquibase extension where I validated the json using jackson library.

Informix SQL update command error 746

I tried to update the field "contract_id" in the table "contract_scan_image".
However, the update was failed and an error "746: Field contract_id and type of contract_scan_image cannot be updated!" was shown.
My SQL command is:
update contract_scan_image
set contract_id = '14864730'
where contract_id = '1486473'
and type = 'RM'
and account = '00193400944'
Does anyone know what happened and how to fix it?
Error message -746 is for user-defined errors. It typically is used in stored procedures in a RAISE EXCEPTION statement:
RAISE EXCEPTION -746, 0, "Field contract_id and type of contract_scan_image cannot be updated!"
The actual message text for error -746 in the message files is:
%s
That is, it prints the string it is given as a string.
So, you are going to need to track down the triggers and stored procedures invoked by those triggers on the contract_scan_image table, and deduce from where the error is generated what you are doing wrong. Superficially, though, it appears that you are not allowed to alter the contract ID, yet that is what you are trying to do.
First things first, I would take a look at a list of Reserved words in SQL - https://drupal.org/node/141051
I would get in the habit of surrounding fields with `` See below:
update contract_scan_image
set `contract_id` = '14864730'
where `contract_id` = '1486473'
and `type` = 'RM'
and `account` = '00193400944'
** Note - type is a reserved word
The error is caused by something being triggered. Then no table can be modified by UPDATE command.
Finally I deleted the record I want to update. Then added back the modified record.
I copy the error description here from the net for reference.
BTW, I asked my supervisor and he said he did trigger something to cause this. (He didn't tell me how to un-trigger it...)
-746
THE SQL STATEMENT IN FUNCTION, TRIGGER, OR IN STORED PROCEDURE name VIOLATES THE NESTING SQL RESTRICTION
Explanation
If a table is being modified (by INSERT, DELETE, UPDATE, or MERGE), the table can not be accessed by the lower level nesting SQL statement.
If any table is being accessed by a SELECT statement, no table can be modified (by INSERT, DELETE, UPDATE, or MERGE) in any lower level nesting SQL statement.
System action
The SELECT, INSERT, DELETE, UPDATE or MERGE SQL statement failed.
Programmer response
Remove the failing statement from the named function, trigger or the stored procedure.
SQLSTATE
57053

Strange error when using output clause on an update statement?

Firstly, a lot of people are unfamiliar with output in my experience. If so, this link is very handy: Hidden Features of SQL Server
I have the following update statement:
UPDATE lease_deal.lease_budget
SET change_type = NULL
OUTPUT inserted.*
WHERE ISNULL(change_type, '') = ''
Although I thought this would return the updated records for me I'm receiving the following error:
Msg 334, Level 16, State 1, Line 9 The target table
'lease_deal.lease_budget' of the DML statement cannot have any enabled
triggers if the statement contains an OUTPUT clause without INTO
clause.
I know I can successfully create a temporary table and redirect the updated records there using the output statement, but why can't I return it to the IDE? I'm sure (certain) I've been able to do this before but can't seem to find a suitable example anywhere to help me understand what I'm doing wrong. Is this simply not possible when you have triggers on a column that you're updating?
This
http://msdn.microsoft.com/en-au/library/ms177564.aspx
says this
If the OUTPUT clause is specified without also specifying the INTO keyword, the target of the DML operation cannot have any enabled trigger defined on it for the given DML action. For example, if the OUTPUT clause is defined in an UPDATE statement, the target table cannot have any enabled UPDATE triggers.