Midrange News for the IBM i Community


Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
Chicagoland
Fun with Embedded SQL
has no ratings.
Published: 02 Nov 2012
Revised: 23 Jan 2013 - 1979 days ago
Last viewed on: 24 Jun 2018 (3828 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Fun with Embedded SQL Published by: Bob Cozzi on 02 Nov 2012 view comments(3)

Here's some potpourri of using Embedded SQL in RPG IV that I've put together.

 

 /free                                                               
    exec SQL set option commit = *none;                              
                                                                     
     // Convert 1 or more characters to hex                          
         exec SQL SET :myHex = hex( :Symbol );                       
     // Get end-of-month date                                        
         exec SQL SET :endOfMonth = last_day( :today);               
     // Get the name of the month                                    
         exec SQL set :szMonth = monthName(:today);                  
     // Encrypt using RC2                                            
         exec SQL SET ENCRYPTION PASSWORD = :pwd;                    
         name = 'Robert Cozzi, Jr.';                                 
         exec SQL set :enc_name = encrypt_rc2( :name );              
     // Decrypt using RC2                                            
         exec SQL set :decrypted_name = DECRYPT_CHAR( :enc_Name);    
     // Find next Friday's date                                      
         exec SQL set :nextFriday = next_day(:today ,'FRIDAY');      
     // Convert all blanks in szURL with plus signs.                 
         szURL = 'www.midrangeNews.com/find?kwd=IBM i';
         exec SQL set :szURL = replace(:szURL , ' ' , '+');  

 

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS