Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to pass a boolean parameter to an oracle PL/SQL procedure

Re: How to pass a boolean parameter to an oracle PL/SQL procedure

From: D Rolfe <dwrolfeFRUITBAT_at_orindasoft.com>
Date: Wed, 28 Apr 2004 07:53:52 +0100
Message-ID: <408F5500.6090408@orindasoft.com>


Cindy,

>> 
>> ERROR at line 1:
>> 
>> ORA-06553: PLS-306: wrong number or types of arguments in call to 'BOUNCE'
>> 
>> 
>> 
>> How do I pass the second parameter as a boolean?


You have two options:

  1. Write a another procedure which takes a number (0 or 1) and uses it to call the first procedure. This is ugly.
  2. Use an anonymous block of PL/SQL in the PreparedStatement. Below is an example of code which shows how to do this. It calls a function which takes a boolean (in_param) and returns another boolean. The SIGNTYPE datatype is an obscure PL/SQL subtype of NUMBER that can be -1, 0 or 1 and thus lends itself to representing booleans. This code has two parameters both of which are numbers.
     return("DECLARE \n" // 1

+"/* Generated By OrindaBuild 4.0.1875 */ \n" // 2
+"/* Which can be obtained at www.orindasoft.com */ \n" // 3
+"functionResult BOOLEAN := null; \n" // 4
+"functionResult_SN SIGNTYPE := null; \n" // 5
+"in_param BOOLEAN := null; \n" // 6
+"in_param_SN SIGNTYPE := ?; \n" // 7
+"BEGIN \n" // 8
+" \n" // 9
+"IF (in_param_SN IS NULL OR in_param_SN = 0) THEN \n" // 10
+" in_param := null; \n" // 11
+"ELSIF in_param_SN = -1 THEN \n" // 12
+" in_param := FALSE; \n" // 13
+"ELSIF in_param_SN = 1 THEN \n" // 14
+" in_param := TRUE; \n" // 15
+"END IF; \n" // 16
+"functionResult := DATATYPE_TEST.BOOLEAN_FUNC(in_param); \n"
// 17
+" \n" // 18
+"IF functionResult IS NULL THEN \n" // 19
+" functionResult_SN := 0; \n" // 20
+"ELSIF functionResult = FALSE THEN \n" // 21
+" functionResult_SN := -1; \n" // 22
+"ELSIF functionResult = TRUE THEN \n" // 23
+" functionResult_SN := 1; \n" // 24
+"END IF; \n" // 25
+"? := functionResult_SN; \n" // 26
+"END; "); // 27 656 characters
This may look more complicated but avoids the creation of a wrapper procedure for your original one. Because it's an anonymous block it stops existing when you finish, and thus doesn't change the design of your DB by adding new procedures to it. David Rolfe Orinda Software Dublin, Ireland ------------------------------------------------------------------- OrindaBuild - Writing Java to Run PL/SQL www.orindasoft.com
Received on Wed Apr 28 2004 - 01:53:52 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US