[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

01/26/2007 at 04:01PM PST, ID: 22138770
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.4

AS400/SQL procedure - CHAR Function question - how to convert decimal to character

Asked by Jeanniem in Programming for iSeries / AS400

Tags: sql, as400, convert, char

I am trying to create a stored procedure using SQL/400.  I need to compare a date that I have converted to a character using the character function: CHAR(YEST2,ISO) (character version of yesterdays date) to an AS400 Date defined as DEC(8,0) also converted to Character.  My reference book says that I should be able to use the CHAR function to convert my decimal date to character, but when I try to do that I get a 'MSGSQL0312' error.  I have also tried defining my AS400 date variable as NUMERIC and then trying to use the CHAR function.  I still get the same error when I try to compile the SQL procedure using the RUNSQLSTM command.  My SQL procedure is listed below.
Please help.  Thank you!!

 CREATE PROCEDURE NAME_CHG5                    
 LANGUAGE SQL                                  
 MODIFIES SQL DATA                            
 BEGIN                                        
 DECLARE YEST  CHAR(8);                        
 DECLARE HOSP DEC(3,0);                        
 DECLARE SPID  CHAR(20);                      
 DECLARE PREVLN CHAR(35);                      
 DECLARE NEWLN CHAR(35);                      
 DECLARE PREVFN CHAR(35);                      
 DECLARE PREVMN CHAR(35);                      
 DECLARE NEWFN CHAR(35);                      
 DECLARE NEWMN CHAR(35);                      
 DECLARE CHGDATE NUMERIC(8,0);                
 DECLARE CCHGDATE CHAR(8);                    
 DECLARE CHGBY CHAR(4);                        
 DECLARE YEST2 DATE;                          
 DECLARE CPNNMDT NUMERIC(10);                  
 DECLARE DYEST2 DEC(8,0);                      
 CREATE PROCEDURE NAME_CHG5                    
 LANGUAGE SQL                                  
 MODIFIES SQL DATA                            
 BEGIN                                        
 DECLARE YEST  CHAR(8);                        
 DECLARE HOSP DEC(3,0);                        
 DECLARE SPID  CHAR(20);                      
 DECLARE PREVLN CHAR(35);                      
 DECLARE NEWLN CHAR(35);                      
 DECLARE PREVFN CHAR(35);                      
 DECLARE PREVMN CHAR(35);                      
 DECLARE NEWFN CHAR(35);                      
 DECLARE NEWMN CHAR(35);                      
 DECLARE CHGDATE NUMERIC(8,0);                
 DECLARE CCHGDATE CHAR(8);                    
 DECLARE CHGBY CHAR(4);                        
 DECLARE YEST2 DATE;                          
 DECLARE CPNNMDT NUMERIC(10);                  
 DECLARE DYEST2 DEC(8,0);                      
DECLARE NOT_FOUND CONDITION FOR SQLSTATE '02000';          
DECLARE EOF_COND CHAR(1) DEFAULT '0';                      
DECLARE CSR1 CURSOR FOR                                    
    SELECT PNHSP, PNSPID, PNLSTN,                          
    PNFSTN,  PNMIDN, PELSTN,                                
         PEFSTN, PNNMDT, PNLMBY                            
    FROM BADMPNU, BADMPEU                                  
 WHERE PNHSP = PEHSP AND PNSPID = PESPID AND PNNMDT <> 0    
 AND CPNNMDT = DYEST2;                                      
 DECLARE CONTINUE HANDLER FOR NOT_FOUND SET EOF_COND = '1';
 SET CPNNMDT = CHAR(PNNMDT);                                                    
SET YEST2 = CURDATE() - 1 DAY;                                                  
SET DYEST2 = CHAR(YEST2,ISO);                                                  
DELETE FROM NAMECHG;                                                            
OPEN CSR1;                                                                      
RPT: REPEAT                                                                    
  FETCH CSR1                                                                    
  INTO  HOSP, SPID, PREVLN, PREVFN, PREVMN, NEWLN, NEWFN, NEWMN,                
   CHGDATE, CHGBY;                                                              
    INSERT INTO NAMECHG VALUES(HOSP, SPID, PREVLN, PREVFN, PREVMN, NEWLN, NEWFN,
                             NEWMN, CHGDATE, CHGBY);        
UNTIL EOF_COND = '1'                                        
END REPEAT RPT;                                              
CLOSE CSR1;                                                  
END;                                                        
[+][-]01/29/07 10:04 AM, ID: 18421397

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Programming for iSeries / AS400
Tags: sql, as400, convert, char
Sign Up Now!
Solution Provided By: daveslash
Participating Experts: 3
Solution Grade: A
 
 
[+][-]01/26/07 06:35 PM, ID: 18408751

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]01/29/07 07:17 AM, ID: 18419875

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/29/07 08:13 AM, ID: 18420349

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/29/07 08:34 AM, ID: 18420557

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/29/07 08:48 AM, ID: 18420701

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/29/07 09:07 AM, ID: 18420900

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/29/07 09:31 AM, ID: 18421104

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/29/07 09:45 AM, ID: 18421216

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/29/07 09:54 AM, ID: 18421303

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/29/07 09:57 AM, ID: 18421339

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/29/07 10:15 AM, ID: 18421487

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/29/07 10:16 AM, ID: 18421503

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/29/07 10:24 AM, ID: 18421571

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/29/07 10:33 AM, ID: 18421648

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091028-EE-VQP-86