Note: I do not have this problem when using Oracle SQL Developer:: - But it is not the Standard here. So i must find a way to do this in PL/SQL Developer
When attempting to use PL/SQL developer (PL/SQL Developer - the program) to dynamically drop tables then create new ones using a create statement I consistently run into the error:
PLS-00103: ENCOUNTERED THE SYMBOL "/" THE SYMBOL "/" WAS IGNORED PLSQL
This is due to the "/" at the end of the dynamic sql.
If I remove the "/" from the end I receive an error:
ENCOUNTERED THE SYMBOL "CREATE"
What is the best method to get around this error inside PL/SQL Developer?
Thank You:
DECLARE
VE_TABLENOTEXISTS EXCEPTION;
PRAGMA EXCEPTION_INIT(VE_TABLENOTEXISTS, -942);
PROCEDURE DROPTABLE(PIS_TABLENAME IN VARCHAR2) IS
VS_DYNAMICDROPTABLESQL VARCHAR2(1024);
BEGIN
VS_DYNAMICDROPTABLESQL := 'DROP TABLE ' || PIS_TABLENAME;
EXECUTE IMMEDIATE VS_DYNAMICDROPTABLESQL;
EXCEPTION
WHEN VE_TABLENOTEXISTS THEN
DBMS_OUTPUT.PUT_LINE(PIS_TABLENAME || ' NOT EXIST, SKIPPING....');
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
RAISE;
END DROPTABLE;
BEGIN
DROPTABLE('foo.foo_table');
END DROPTABLE;
/
CREATE TABLE foo.foo_table AS
(
SELECT STUFF, MORE_STUFF FROM not_foo_table
)
;
SELECT * FROM foo.foo_table
;
I have too PLSQL Developer.
I try to compile your procedure the way you post it and I get the same error, but if I remove the blank spaces before the "/" it works fine; like it don't recognize the "/".
So, I recommend you to change this:
END DROPTABLE;
/
For this:
END DROPTABLE;
/
Related
When I executed the code below i got the message "anonymous block completed" without any results back. Can anyone help me out?
BEGIN
FOR r IN
(SELECT DBMS_METADATA.GET_DDL
(object_type => 'VIEW', name => view_name, schema => USER)
AS view_text
FROM USER_VIEWS)
LOOP
IF INSTR (r.view_text, 'Project') > 0 THEN
DBMS_OUTPUT.PUT_LINE (r.view_text);
END IF;
END LOOP;
END;
Before running this piece of code, you have to enable output. In SQL*Plus and SQL Developer, it is done by running
set serveroutput on
PL/SQL Developer must have something similar, either by explicitly running that statement (if it is supported), or by clicking somewhere in the output window so that DBMS_OUTPUT has something to display the result to.
I have also found this (in case someone needed):
SQL Developer seems to only output the DBMS_OUTPUT text when you have explicitly turned on the DBMS_OUTPUT window pane.
Go to (Menu) VIEW -> Dbms_output to invoke the pane.
Click on the Green Plus sign to enable output for your connection and then run the code.
Hi I am trying to see if this code would work for Apex 5.0.1
I have a data loading procedure that end users are using both upper and lower case, but in some cases they need to and in some other cases they don't.
So to remove the need for them to know when to use it on the upload I was trying to create this data transformation rule.
Data transformation rule page
DECLARE
V_ASSET_NA (Varchar2);
BEGIN
CASE
WHEN :ASSET_DLVRY_MTHD IN ('MEDIA REPOSITORY', 'PRIVATENET') THEN
UPPER(ASSET_NA);
ELSE
LOWER(ASSET_NA);
END CASE;
END;
If someone could check the PL/SQL I would be very grateful.
I got it to work
DECLARE
V_ASSET_NA (Varchar2);
BEGIN
CASE
WHEN :ASSET_DLVRY_MTHD IN ('MEDIA REPOSITORY', 'PRIVATENET') THEN
UPPER(ASSET_NA);
ELSE
LOWER(ASSET_NA);
END CASE;
RETURN V_ASSET_NA;
END;
I was missing a return value... :(
I have data in an interface table that I need to copy over to the application table based on a set of criteria (project #, task_Number). I am able to access everything I need in a select statement. I am unsure of how to start the script. Any pointers would be wonderful. I havent written a PL/SQL script before.
Welcome to PLSQL!
How you write your script depends on the context from which it will be run.
If I am running a script through sqlplus I have some bolier plate which I have below which you might find starts you off.
set define off;
set serveroutput on;
declare
l_error varchar2(4094);
begin
dbms_output.put_line('Start of script named XXX');
--Select/Insert statements here
--commit
dbms_output.put_line('End of script named XXX');
EXCEPTION WHEN OTHERS THEN
l_error := NVL(SUBSTR(SQLERRM,0,990),'NULL');
dbms_output.put_line(l_error || ':-' || NVL(SUBSTR(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE,0,3000),'NULL'));
rollback;
end;
I need to trim instance name from complete dblink name .For example The select query returns result like HHVISDEV.TRINITI.COM. I need to get HHVISDEV. And ofcourse There are such multiple results. So I need to use cursor and print the final result. I am getting Warning: Procedure created with compilation errors., when I compile. And when I call the procedure I am getting ERROR at line 1:
ORA-06575: Package or function DELETEDBLINKS1 is in an invalid state. Can any one please guide me.
create or replace procedure DeleteDBLinks1 is
cursor mycursor is
SELECT SUBSTR(DB_LINK, 1, INSTR(DB_LINK, '.', 1, 1) - 1)
FROM dba_db_links;
myvar dba_db_links.dblinks%TYPE;
BEGIN
OPEN mycursor;
LOOP
FETCH mycursor
INTO myvar;
EXIT WHEN mycursor%NOTFOUND;
DBMS_OUTPUT.put_line(myvar);
END LOOP;
CLOSE mycursor;
end;
/
If you see Warning: Procedure created with compilation errors, then, I can guess, you compile your procedure in SQL*Plus. In SQL*Plus you can run command
show errors
and you will see errors list. Your procedure looks OK, so I think problem is - you have no access to dba_db_links view. Try to use all_db_links or user_db_links instead.
Along with what Dmitry said about you probably not having access to dba_db_links table, you also had a typo in the myvar variable definition. It should have been:
myvar dba_db_links.db_link%TYPE;
SQL*Plus> SHOW ERRORS will help you in your PL/SQL endeavors, until you start using a PL/SQL IDE like SQL Developer or (my favorite) PL/SQL Developer, which will show you the errors automatically.
I am trying to make a trigger that when data is inserted, it trims the data that is being inserted.
Here is what I am trying ..
CREATE OR REPLACE TRIGGER trig_trim
BEFORE INSERT ON triggertest
FOR EACH ROW
BEGIN
TRIM(:new.testchar);
END;
/
I do an insert like this
INSERT INTO triggertest (testnum, testchar) VALUES (9, ' r9 ');
and I am getting this error...
04098. 00000 - "trigger '%s.%s' is invalid and failed re-validation"
*Cause: A trigger was attempted to be retrieved for execution and was
found to be invalid. This also means that compilation/authorization
failed for the trigger.
*Action: Options are to resolve the compilation/authorization errors,
disable the trigger, or drop the trigger.
When I just run the code to create the trigger I get this
TRIGGER TRIG_TRIM compiled
Errors: check compiler log
and in the compiler log it says "'TRIM' is not a procedure or is undefined"
Is my syntax wrong or my logic? I don't know why this is failing.
Your assignment syntax is wrong. Try this:
:new.testchar := TRIM(:new.testchar);
TRIM has to return the result to something. I think you want:
:new.testchar := TRIM(:new.testchar);