Oracle triggers error on sqldeveloper export script - oracle

I had built a few tables with sequences and triggers, since I need to share the script with my team at uni I did an export with sqldeveloper, now when I try to import/execute the resulted .sql I'm getting errors with triggers.
This is the error message:
"Error starting at line 250 in command:
CREATE OR REPLACE EDITIONABLE TRIGGER "TRG_ACCOUNTS"
BEFORE INSERT ON ACCOUNTS
FOR EACH ROW
BEGIN
SELECT SEQ_ACCOUNTS.NEXTVAL INTO :NEW.ACCOUNT_ID FROM DUAL
Error report:
SQL Command: editionable TRIGGER
Failed: Warning: execution completed with warning
Error starting at line 258 in command:
END
Error report:
Unknown Command
trigger "TRG_ACCOUNTS" altered."
This is the part of the script it's complaining about. I have a few other triggers and it's giving me the same error on all of them. I've checked how the triggers are created after executing the script, and all of them seem to be missing a semi colon and the "END;" at the end.
Example:
create or replace
TRIGGER "TRG_FL_AR"
BEFORE INSERT ON FLOOR_AREAS
FOR EACH ROW
BEGIN
SELECT SEQ_FL_AR.NEXTVAL INTO :NEW.FLOOR_AREA_ID FROM DUAL <-- missing ";" here
<missing "END;" here>
Could you please help me?
Thank you.

Try to put a back slash / after line 258 and check again

Related

Problem execute procedure in oracle ORA-06550

I try to execute a package in oracle that it works when call him with software, but in sql developer no
show me the following error:
ORA-06550: Line 2 column 11
PLS-00103 Encountered the symbol "package name" when expection one the following
:= . ( # % ; was substituted form "package name" to continue.
06550. 000000 - "line%s column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action
Vendor code 6550 Error at Line:1
the line 11 start of name package
begin
execute packageName.procedureName(parameter1,parameter2,parameter3,...);
end
Remove EXECUTE. It is used when you want to run a procedure at SQL*Plus prompt. In PL/SQL, you don't use it.
Code that should work is:
begin
packageName.procedureName(parameter1,parameter2,parameter3,...);
end;
/

in SQuirrel SQL - unable to use old or new in oracle trigger

using Oracle DB 10 and SQuirrel 3.7.1
I need to access inserted-fields
If I write in an Oracle trigger script - :new.fieldName,
when running the script - I get an input window that says:
"Please input the parameter values
Value for ' :new' ___________ "
the trigger is compiled with a warning - "EDT violation detected"
when the trigger is executed (using an insert) , there's an error:
" Error: ORA-04098: trigger 'schemeName.triggerName' is invalid and failed re-validation
SQLState: 42000
ErrorCode: 4098
Position: 2172 "
what am I missing ?
trigger script:
CREATE OR REPLACE TRIGGER schemeName.triggerName
AFTER INSERT ON schemeName.tableName1
FOR EACH ROW
BEGIN
Insert into schemeName.tableName2 (fieldName1, fieldName2) values (:new.fieldName, 'someString');
END;
/
Your tool (SQuirrel 3.7.1) understands : as if you wanted to enter a substitution variable.
There should be an option which turn that OFF (at least temporarily) so that you could create a trigger.
goto plugins -> summary, disable sqlparam-plugin and restart squirrel.

Getting error - Unknown Command , while deleting view if exists in oracle

IF EXISTS(select 1 from sys.views where name='release_testcase_count')
DROP VIEW ITCC.release_testcase_count4;
i am able to delete this view but it is saying -
Error starting at line : 1 in command -
IF EXISTS(select 1 from sys.views where name='release_testcase_count')
Error report -
Unknown Command
View ITCC.RELEASE_TESTCASE_COUNT4 dropped.
so in this case 1 line have a error, it is not checking it exist or not.
IF EXISTS command is valid in SQL Server or other databases but not in ORACLE.
Your first line is completely ignored and signaled as unknown command as Oracle does not recognize any command starting with IF EXIST.
Second line is a valid command, so the view is dropped as a result.

Dynamic query error "invalid character" [duplicate]

i got a little problem in Oracle. I try to create a sequence for generating IDs in a table that already has data in it. I try to use the following anonymous block.
declare y varchar2(2000);
BEGIN
SELECT 'CREATE SEQUENCE ID_SEQ MINVALUE 1 MAXVALUE 9999999999 START WITH ' || (max(ID)+1) || ' INCREMENT BY 1 CACHE 20;' INTO y FROM TEST_TABLE;
--dbms_output.put_line(y);
execute immediate y;
end;
I get the following error:
Error report:
ORA-00911: invalid character
ORA-06512: at line 5
00911. 00000 - "invalid character"
If I execute the value of the y variable it works perfectly. I'm using SQL Developer as input interface and working on a 11g r2 Oracle server. I found similar codes where 'INCREMENT BY' parameter were script generated. Can someone explain my error?
When you execute immediate, the command you run should not have a semi-colon on the end; that is a command separator in SQL Developer (and SQL*Plus, and other clients), not part of the SQL statement itself.
SELECT 'CREATE SEQUENCE ID_SEQ MINVALUE 1 MAXVALUE 9999999999 START WITH '
|| (max(ID)+1) || ' INCREMENT BY 1 CACHE 20' INTO y FROM TEST_TABLE;
This is shown in the examples for plain SQL. Just to help confuse you though, if you are using PL/SQL within the dynamic SQL, you do still need semi-colons appropriate to PL/SQL itself - though not the executing / you'd use to run it directly from a client. This is shown in other examples.

run string as query in oracle

i got a little problem in Oracle. I try to create a sequence for generating IDs in a table that already has data in it. I try to use the following anonymous block.
declare y varchar2(2000);
BEGIN
SELECT 'CREATE SEQUENCE ID_SEQ MINVALUE 1 MAXVALUE 9999999999 START WITH ' || (max(ID)+1) || ' INCREMENT BY 1 CACHE 20;' INTO y FROM TEST_TABLE;
--dbms_output.put_line(y);
execute immediate y;
end;
I get the following error:
Error report:
ORA-00911: invalid character
ORA-06512: at line 5
00911. 00000 - "invalid character"
If I execute the value of the y variable it works perfectly. I'm using SQL Developer as input interface and working on a 11g r2 Oracle server. I found similar codes where 'INCREMENT BY' parameter were script generated. Can someone explain my error?
When you execute immediate, the command you run should not have a semi-colon on the end; that is a command separator in SQL Developer (and SQL*Plus, and other clients), not part of the SQL statement itself.
SELECT 'CREATE SEQUENCE ID_SEQ MINVALUE 1 MAXVALUE 9999999999 START WITH '
|| (max(ID)+1) || ' INCREMENT BY 1 CACHE 20' INTO y FROM TEST_TABLE;
This is shown in the examples for plain SQL. Just to help confuse you though, if you are using PL/SQL within the dynamic SQL, you do still need semi-colons appropriate to PL/SQL itself - though not the executing / you'd use to run it directly from a client. This is shown in other examples.

Resources