Solved

PL/SQL Anonymous Block error in Oracle Apex

Posted on 2010-09-16
3
1,379 Views
Last Modified: 2012-06-21
Hello experts:

I am running a pl/sql process in Oracle Apex and need to bind a variable :P1_READ_WRITE_AUTH

Running the sql process returns an error PLS-00103.

Can you please tell me what I am doing wrong? The query should at least run in a console or sql developer.

Many thanks,

skahlert2010


DECLARE
SCHREIBRECHT varchar2();
LESERECHT varchar2();
BEGIN
SCHREIBRECHT := 'Write Privileges';
LESERECHT := 'Read Only';
IF :F_READ_WRITE_AUTH = 'write' then 
:P1_READ_WRITE_AUTH := SCHREIBRECHT;
ELSIF :F_READ_WRITE_AUTH = 'read' then
:P1_READ_WRITE_AUTH := LESERECHT;
END IF;
END;

Open in new window

0
Comment
Question by:skahlert2010
3 Comments
 
LVL 28

Accepted Solution

by:
Naveen Kumar earned 500 total points
ID: 33690287
try :

DECLARE
SCHREIBRECHT varchar2();
LESERECHT varchar2();
BEGIN
SCHREIBRECHT := 'Write Privileges';
LESERECHT := 'Read Only';
IF F_READ_WRITE_AUTH = 'write' then
P1_READ_WRITE_AUTH := SCHREIBRECHT;
ELSIF F_READ_WRITE_AUTH = 'read' then
P1_READ_WRITE_AUTH := LESERECHT;
END IF;
END
0
 
LVL 7

Expert Comment

by:sumit2906
ID: 33690300
you need to specify the size fo variables you have declared, after this, if you are running it from sqlplus, you can declare other variables and this code should run fine.

var P1_READ_WRITE_AUTH varchar2(100);
var F_READ_WRITE_AUTH varchar2(100);

DECLARE  
SCHREIBRECHT varchar2(100);  
LESERECHT varchar2(100);  
BEGIN  
SCHREIBRECHT := 'Write Privileges';  
LESERECHT := 'Read Only';  
IF :F_READ_WRITE_AUTH = 'write' then  
:P1_READ_WRITE_AUTH := SCHREIBRECHT;  
ELSIF :F_READ_WRITE_AUTH = 'read' then  
:P1_READ_WRITE_AUTH := LESERECHT;  
END IF;  
END;
0
 

Author Closing Comment

by:skahlert2010
ID: 33690746
Thanks nav_kum_v! I was able to solve my problem. I didn't notice that my variable (an Apex Page Item) was already bound, as it didn't return the value when displayed! I modified the code to bind the item while returning the strings of the function!

Best regards,

Skahlert2010
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now