Focal Point
Accessing PL/SQL Return Value

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/2121057092

July 07, 2008, 12:35 PM
smiths
Accessing PL/SQL Return Value
When I call a PL/SQL procedure that returns a character string, I don't know how I can access the string in my WebFocus program.

I am running the following code:
-SET &PASSWORD = 'MYPASSWORD';

SQL SQLORA SET SERVER MRS_SEC

SQL SQLORA
EX MRS_SEC.PASSWORD_ENCRYPTION2.GET_ENCRYPTED_PASSWORD '&PASSWORD', ?;
END



Here is the PL/SQL procedure:
   PROCEDURE get_encrypted_password (
      p_password VARCHAR2,
      v_encrypt OUT VARCHAR2
   )     
   IS  

   BEGIN  
      v_encrypt := encrypt(p_password);
   END;

  


And I get this output:
FILE=@@@@0016 ,SUFFIX=FIX SEGNAME=@@@@0016 FIELDNAME=V_ENCRYPT ,E01 ,A2000 ,A2000 ,$ 7E6EA28391C98C890B9F474165466AF3 


The value 7E6EA28391C98C890B9F474165466AF3 is what I need to access, but I don't know how to get a handle on it.

I also tried TABLE FILE SQLOUT at the end of the EX call, but I got an error message.

Can anyone please help me iron out my syntax to enable me to access the string?

Thanks very much,
Sean


------------------------------------------------------------------------
PROD: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
TEST: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
July 07, 2008, 02:39 PM
Francis Mariani
The manual "Adapter Administration..." shows you how to call the stored procedure, but not what to do after the call.

Silly question, but have to tried TABLE FILE @@@@0016?


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
July 07, 2008, 02:56 PM
smiths
Hey Francis,

Definitely not a silly question (and I don't think you would ever ask one!) Smiler

I have tried that, and I get
(FOC205) THE DESCRIPTION CANNOT BE FOUND FOR FILE NAMED: @@@@0016
BYPASSING TO END OF COMMAND

Thanks for the suggestion though.

I have found a way using REFCURSOR such that I can get the string into an amper variable when accessing the data from a table in the PL/SQL procedure. And for this particular problem, I can get it to work using select of encrypt(p_password) from DUAL, but I find that very clumsy.

So I'm still hoping to find a more straightforward way to do this. It must exist!!

Thanks,
Sean


------------------------------------------------------------------------
PROD: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
TEST: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
July 07, 2008, 03:15 PM
smiths
Francis,

I reread the section on the Oracle adapter that you referred to (I had a copy from the Tech Support section which also contained an example), and it looks like I can only accomplish this with the cursor method. In other words, I can't just assign a value to a variable and process it in WF. Although as indicated above, I do get a line of text containing the string that I had hoped to be able to assign into an amper variable, so it's unfortunate I can't access it!

Thanks again,
Sean


------------------------------------------------------------------------
PROD: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
TEST: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
July 07, 2008, 03:24 PM
Danny-SRL
smiths,

quote:
SQL SQLORA
EX MRS_SEC.PASSWORD_ENCRYPTION2.GET_ENCRYPTED_PASSWORD '&PASSWORD', ?;
END


In my experience one should write:
  
SQL SQLORA
EX MRS_SEC.PASSWORD_ENCRYPTION2.GET_ENCRYPTED_PASSWORD '&PASSWORD';
TABLE FILE SQLOUT
PRINT *
ON TABLE HOLD AS SMITHS
END
TABLE FILE SMITHS
PRINT *
END



Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

July 07, 2008, 03:41 PM
smiths
Daniel,

Yeah, I thought that something like that should work. I modified your version slightly to include the '?' (because it failed with lack of parameters otherwise) that is required for the return parameter, plus I've changed the proc name slightly:
 -SET &PASSWORD = 'XX';

SQL SQLORA SET SERVER MRS_SEC

SQL SQLORA
EX MRS_SEC.PASSWORD_ENCRYPTION2.XX_GET_ENCRYPTED_PASSWORD '&PASSWORD', ?;
TABLE FILE SQLOUT
PRINT *
ON TABLE HOLD AS SMITHS
END
TABLE FILE SMITHS
PRINT *
END
 


I get the following error:
 (FOC1400) SQLCODE IS 6550 (HEX: 00001996) 
: ORA-06550: line 1, column 67:                                           
: PLS-00103: Encountered the symbol ")" when expecting one of the         
: following:                                                              
:    ( - + case mod new not null others                    
:      avg         
:    count current exists max min prior sql stddev sum variance           
:    execute forall merge time timestamp interval date                    
:                      
:      pipe                         
:    
(FOC1405) SQL PREPARE ERROR. 
(FOC205) THE DESCRIPTION CANNOT BE FOUND FOR FILE NAMED: SMITHS  
BYPASSING TO END OF COMMAND

 


I was able to get it working with the following code:
 -SET &ECHO = ALL;

SQL SQLORA SET SERVER MRS_SEC

SQL SQLORA
EX MRS_SEC.PASSWORD_ENCRYPTION2.get_encrypted_password 'SMITHS';
TABLE FILE SQLOUT
PRINT *
ON TABLE HOLD AS H_ENCRYPT
END
-RUN

DEFINE FILE H_ENCRYPT
ENCRYPT_PSWD/A32 = EDIT(PASSWORD_ENCRYPTION2_ENCRYPT_:B, '99999999999999999999999999999999');
END

TABLE FILE H_ENCRYPT
PRINT ENCRYPT_PSWD
ON TABLE HOLD AS H_2
ON TABLE SET ASNAMES ON
END

-RUN

-READ H_2 &ENCRPTPSWD.A32

-SET &ENCRPTPSWD = TRUNCATE(&ENCRPTPSWD);

-TYPE ENCRPTPSWD: (&ENCRPTPSWD)
 


against this PL/SQL procedure:
    PROCEDURE get_encrypted_password (
      p_password VARCHAR2,
      c_histtable OUT rectype
   )     
   IS  

   BEGIN  
   OPEN c_histtable FOR SELECT encrypt(p_password) 
            FROM dual
                 ;   
   END;
 


A bit kludgey, but it seems to work.

But I would prefer something simple like you suggested would work without the need for a cursor in the PL/SQL proc.

Thanks for your time!
Sean

This message has been edited. Last edited by: smiths,


------------------------------------------------------------------------
PROD: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
TEST: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode