ALTER SESSION SET NLS_TERRITORY=ITALY throws ORA-00911 - plsql

If I try to execute the statement ALTER SESSION SET NLS_TERRITORY=ITALY in SQL Developer, I get no errors. But if I run it through a Win Forms application of mine, connecting through the System.Data.OracleClient provider, I get the "ORA-0911: invalid character" error. Why? My version of Oracle is 10.2.0.1.0

Solved it. I was executing
ALTER SESSION SET NLS_TERRITORY=ITALY;
pl/sql block: DECLARE ... BEGIN ... END;
/
I removed the semicolon and replaced it with
ALTER SESSION SET NLS_TERRITORY=ITALY
/
pl/sql block: DECLARE ... BEGIN ... END;
/
and it works now

Try to wrap it in execute immediate:
execute immediate 'ALTER SESSION SET NLS_TERRITORY=ITALY';

Related

How to run pl/sql statements in Control M for database job/task(execution type :- Embedded Query)

I have pl/sql statement something like mentioned below, which executes successfully in oracle sql developer but same when am trying to execute through control M database task (execution type :- Embedded Query) am getting error "Invalid SQL statements"
SQL statements :-
TRUNCATE TABLE TEST;
COMMIT;
EXECUTE USP_LOADTESTTables;
COMMIT;
create a query file named plsql_query.ql then use it to execute from controlM as command line job.
Sqlcmd -E -server\instance_name -Q "EXEC plsql_query.ql"

using pl/sql external package and getting error with declaration

I need to run a procedure in a package external to my script. The script is in an APEX page:
begin
idsud.segyload.loaddataset(p_dataset_id => :p40_dset, p_mode => 'INIT');
end;
When I try to use this I get an error saying that I must declare the "idsud.segyload" package. How to do this?
Have you added the appropriate permissions?
e.g. GRANT EXECUTE ON idsud.segyload TO {apex_schema};

Oracle trigger error, 10g to 11g export

i am trying to export a 10g database to 11g and receieving error(execution completed with warning) at the row that tries to create the trigger.
--------------------------------------------------------
-- DDL for Trigger TR_INS_DATACARD
--------------------------------------------------------
CREATE OR REPLACE TRIGGER "AFTARSIV"."TR_INS_DATACARD" BEFORE INSERT ON fichas REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW BEGIN SELECT fichas_seq.NEXTVAL INTO :NEW.clave FROM DUAL; END;
/
ALTER TRIGGER "AFTARSIV"."TR_INS_DATACARD" ENABLE;
SQL command works fine with 10g, it even creates the trigger at 11g but the trigger has this error:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: ;

NOHUP Command In Linux

I am issuing a command
$nohup sqlplus "/ as sysdba" #script.sql &
And on executing this nohup.out file contains this error:
Error 45 initializing SQL*Plus
How to resolve it?
Check the command terminators. If you have anonymous plsql blocks, typically they would look like
DECLARE
some stuff
BEGIN
sql statements;
END;
You have to add another line with a lone "/" after it, or you will get this error.

oracle 10g and define instruction

I want to compile this PL/SQL program in the SQL window that belongs to the Database Home page:
DEFINE p_annual_sal=60000
DECLARE
v_sal NUMBER(9,2):=&p_annual_sal;
BEGIN
v_sal:=v_sal/12;
DBMS_OUTPUT.PUT_LINE('The monthly salary is '|| TO_CHAR(v_sal));
END;
When I hit run I got the following message:
ORA-00900: invalid SQL statement
Even though it works under SQL*Plus of the command line, what it could be the issue?
It works in SQL*Plus because DEFINE is a SQL*Plus command.
When you refer to the "database home page" I believe you're referring to Oracle Apex's SQL Commands window, which can run SQL and PL/SQL code, but not SQL*Plus commands.
You can do this instead - Apex will prompt you for the input bind variables, if any:
DECLARE
v_sal NUMBER(9,2):= :p_annual_sal;
BEGIN
v_sal:=v_sal/12;
dbms_output.put_line('The monthly salary is '|| TO_CHAR(v_sal));
END;

Resources