?
Solved

PL/SQL Anonymous Block error in Oracle Apex

Posted on 2010-09-16
3
Medium Priority
?
1,409 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 28

Accepted Solution

by:
Naveen Kumar earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that useā€¦
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

765 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