Solved

PL/SQL Anonymous Block error in Oracle Apex

Posted on 2010-09-16
3
1,387 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

929 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

17 Experts available now in Live!

Get 1:1 Help Now