Oracle Pl/SQL trigger compilation error via SQL*PLUS - oracle
I have a problem with compiling an Oracle trigger via SQL*PLUS - I don't think I'm being dumb but I can't see what the problem is.
We have an installer script which is essentially a batch file which creates/refreshes all the objects in the database by calling SQLPLUS on multiple scripts, each containing one view, trigger, etc. The tables and views are created first, then then triggers. The V_BS_GRIDFIELDS view below may or may not be created at this point, or may be created later by a different process. The view is an updatable view, so we have a trigger placed on it to push updates to different tables, as below:
CREATE OR REPLACE FORCE TRIGGER TR_INSTUPD_BS
INSTEAD OF INSERT OR UPDATE OR DELETE
ON V_BS_GRIDFIELDS
FOR EACH ROW
BEGIN
IF INSERTING OR DELETING THEN
NULL;
END IF;
IF UPDATING THEN
-- Can only change these fields
IF (:OLD.VISIBLE <> :NEW.VISIBLE) OR (:OLD.COMPULSORY <> :NEW.COMPULSORY) THEN
-- Source Table = BS_GRIDFIELDS
IF (:OLD.SOURCE_TYPE = 0) THEN
UPDATE BS_GRIDFIELDS BS_GF
SET BS_GF.VISIBLE = :NEW.VISIBLE,
BS_GF.COMPULSORY = :NEW.COMPULSORY
WHERE BS_GF.FIELD_NAME = :OLD.FIELD_NAME;
END IF;
END IF;
END IF;
END;
The issue is that oracle SQL*PLUS seems to stop compiling the trigger after the first blank line, on line 6:
SQL> #"TR_INSTUPD_BS.sql";
SP2-0734: unknown command beginning "IF INSERTI..." - rest of line ignored.
SP2-0042: unknown command "NULL" - rest of line ignored.
SP2-0042: unknown command "END IF" - rest of line ignored.
SP2-0734: unknown command beginning "IF UPDATIN..." - rest of line ignored.
SP2-0044: For a list of known commands enter HELP
and to leave enter EXIT.
SP2-0734: unknown command beginning "IF (:OLD.V..." - rest of line ignored.
SP2-0734: unknown command beginning "IF (:OLD.S..." - rest of line ignored.
SP2-0552: Bind variable "OLD" not declared.
SP2-0042: unknown command "END IF" - rest of line ignored.
SP2-0042: unknown command "END IF" - rest of line ignored.
SP2-0042: unknown command "END IF" - rest of line ignored.
SP2-0042: unknown command "END" - rest of line ignored.
SP2-0044: For a list of known commands enter HELP
and to leave enter EXIT.
If you remove the blank line on line 6, it seems to stop compiling at the first semicolon, on line 7:
SQL> #"TR_INSTUPD_BS.sql";
Warning: Trigger created with compilation errors.
SP2-0042: unknown command "END IF" - rest of line ignored.
SP2-0734: unknown command beginning "IF UPDATIN..." - rest of line ignored.
SP2-0734: unknown command beginning "IF (:OLD.V..." - rest of line ignored.
SP2-0734: unknown command beginning "IF (:OLD.S..." - rest of line ignored.
SP2-0552: Bind variable "OLD" not declared.
SP2-0042: unknown command "END IF" - rest of line ignored.
SP2-0042: unknown command "END IF" - rest of line ignored.
SP2-0042: unknown command "END IF" - rest of line ignored.
SP2-0042: unknown command "END" - rest of line ignored.
SP2-0044: For a list of known commands enter HELP
and to leave enter EXIT.
SQL>
We have lots of triggers created in this way, and all of them have spaces, semicolons, etc, and get created OK. I've tested and seen the same issue on Oracle 9, 10, 11. Can anyone shed light on this?
Thanks.
in its default setting SQL*Plus won't deal properly with blank lines, you need to issue the following command:
SQL> SET SQLBLANKLINES on
See this other SO.
Update: I answered too fast, the blank line doesn't seem to be the problem here. I tried your code on my database and the issue seems to come from the FORCE keyword. The 10gR2 documentation doesn't mention this keyword. The trigger compiles when you remove it.
Related
Call a PL/SQL package from shell script - Error "identifier must be declared"
am calling a plsql package from shell script as sqlplus -s <<! $userpass set pagesize 0 feedback off verify off heading off echo off exec POEXT.PO_ACK_UPDATE("$worfile",$ftpvendornum,"$org_code",$req_id,"$ftpgrp","$vendor_name"); exit; ! The value of the parameters as follows worfile=R12POAUS220171025#230307.ZIP ftpvendornum=15163 org_code=US2 req_id=53004007 ftpgrp=DCU vendor_name=Empty when i run - I get an error message like below ERROR at line 1: ORA-06550: line 1, column 35: PLS-00201: identifier 'R12POAUS220171025#230307.ZIP' must be declared ORA-06550: line 1, column 7: PL/SQL: Statement ignored I executed the same block in sqldeveloper using anonymous block its getting executed. can someone help me to figure out what could be the possible issue?
How is it when you write the statement with single ' around the parameters? exec POEXT.PO_ACK_UPDATE('$worfile',$ftpvendornum,'$org_code',$req_id,'$ftpgrp','$vendor_name');
Hive error when declaring hivevar
Trying to declare a variable in Hive using Hue online. Using the following code: SET hivevar:TABLE1=location.tablename; I am getting the following error message: Error while compiling statement: FAILED: ParseException line 1:12 missing KW_ROLE at 'hivevar' near 'hivevar' line 1:19 missing EOF at ':' near 'hivevar'. Can anyone tell me what this error message means or even what the KW_ROLE statement means?
Do you by any chance have a comment above that instruction ? Are you running that line and that line only ? For example, the following will raise a similar Exception : --This is a comment SET hivevar:TABLE1=location.tablename; But it works fine without the comment.
I guess you are making changes in MAC/Windows and moving the script to the server, Double dash "--" in MAC is a different from double dash "--" on Linux server, make changes on server itself and run the script...
PLS-00103: Encountered the symbol " " when expecting one of the following
For some reason this wont work. I have got it down to the most basic operation to try and troubleshoot. BEGIN FOR rec IN ( select REGISTRATION_UID from DIM_REGISTRATION_SET ) LOOP dbms_output.put_line('Testing 123'); END LOOP; end; / My error is as below: Error starting at line 1 in command: BEGIN FOR rec IN ( select REGISTRATION_UID from DIM_REGISTRATION_SET ) LOOP dbms_output.put_line('Testing 123'); END LOOP; end; Error report: ORA-06550: line 4, column 6: PLS-00103: Encountered the symbol " " when expecting one of the following: loop 06550. 00000 - "line %s, column %s:\n%s" *Cause: Usually a PL/SQL compilation error. *Action:
You seem to have an unexpected character in your code. If you copy and paste the rendered output from this question then it runs fine. If you copy the question source code (from the edit dialogue) then it gets that error. Dumping the code (again copied from the source, not the rendering) shows: select dump('( select REGISTRATION_UID from DIM_REGISTRATION_SET ) ', 16) from dual; DUMP('(SELECTREGISTRATION_UIDFROMDIM_REGISTRATION_SET) ',16) -------------------------------------------------------------------------------- Typ=96 Len=73: 28,a,20,20,20,20,20,20,20,20,20,20,73,65,6c,65,63,74,20,52,45,47, 49,53,54,52,41,54,49,4f,4e,5f,55,49,44,20,66,72,6f,6d,20,44,49,4d,5f,52,45,47,49 ,53,54,52,41,54,49,4f,4e,5f,53,45,54,a,20,20,20,20,20,20,20,20,29,c2,a0 So the space after the closing parenthesis isn't actually a space, it's Unicode character c2a0, which is a non-breaking space. The error message shows that too, if you dump that: select dump ('Encountered the symbol " "', 16) from dual; DUMP('ENCOUNTEREDTHESYMBOL" "',16) -------------------------------------------------------------------------------- Typ=96 Len=27: 45,6e,63,6f,75,6e,74,65,72,65,64,20,74,68,65,20,73,79,6d,62,6f,6c ,20,22,c2,a0,22 I would guess you copied that code from somewhere (Word?) and it picked up that character, and it hasn't been translated to a normal space. Just replace it with a space, or remove it as it's redundant whitespace anyway. Actually, there are several others; two at the start of the LOOP line (followed by two normal spaces), and two immediately before END LOOP; (preceded by two normal spaces), and one after that statement; so those all need to be replaced too. (I'd be tempted to retype the whole thing, but that might not be practical for your full code).
"unknown command" for dbms_lob.open command in Sql+
I am a total beginner when it comes to PL/SQL and Sql+. I am trying to write a function that will extract the contents of a text file into a CLOB (following this as an example). When I issue the following command in Sql+: dbms_lob.open( 'c:\temp\test.txt', dbms_lob.lob_readonly ); I get the following error message: SP2-0734: unknown command beginning "dbms_lob.o..." - rest of line ignored. Is there something wrong with the syntax of the command, or something else entirely? Thanks much!
I'm not an expert in oracle. For me the problem is that for launch this command in sqlplus you may declare an anonymous block like this: DECLARE -- variables BEGIN --- your commands here dbms_lob.open...... END; To launch the execution you have to digit / and then return
Error when trying to load data from Unix script
when i am trying to execute the SQL script from Unix server its showing error but the same SQL i am running from sql navigator its working fine .. kindly help me on it.. INSERT INTO t_csocstudent_course_local (SELECT tsct.student_id, tsct.object_lookup_id, tsct.course_id, tsct.xcourse_id, clt.NAME, tsct.course_type, FROM temp_stud_course tsct join course_local clt on tsct.COURSE_ID = clt.COURSE_ID WHERE TO_CHAR (sc_timestamp, 'YYYYMMDDHH24MISS') > (SELECT TO_CHAR (MAX (sc_timestamp), 'YYYYMMDDHH24MISS') FROM t_student_course_local) AND tsct.xcourse_id IN ('EX1','EX2')); Error : Error in loading main table Enter password: SP2-0734: unknown command beginning "WHERE TO..." - rest of line ignored. AND tsct.xcourse_id IN * ERROR at line 3: ORA-00933: SQL command not properly ended Thanks in advance !!
I can't remember if the Oracle command line client permits extra whitespace linebreaks. Remove the extra linebreak before the WHERE clause. Update From the documentation, an empty line terminates a SQL statement by default in SQLplus. SQLT[ERMINATOR] {;|c|OFF|ON}| Set the char used to end and execute SQL commands to c. OFF disables the command terminator - use an empty line instead. ON resets the terminator to the default semicolon (;). You can change the behavior to use semicolons instead of empty lines: SET SQLTERMINATOR ON