Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

What is P1:BEGIN and P2:BEGIN do?

Posted on 2008-09-29
4
Medium Priority
?
1,342 Views
Last Modified: 2012-05-05
Can someone explain P1: & P2: to me? (or maybe point me at a BONEHEAD doc?)

I found a StoredProc sample using a GLOBAL TEMPORARY TABLE and a CURSOR ... It uses P1: and P2: ..... My StoredProc (using P1: & P2:) compiles and creates the StoredProc in the library, but attempts to CALL the SP returns an error.

----------------------------------------------------------------
CREATE PROCEDURE CSIDEV.DVLCHRT ( )
      DYNAMIC RESULT SETS 3
      LANGUAGE SQL
      SPECIFIC CSIDEV.DVLCHRT
      NOT DETERMINISTIC
      MODIFIES SQL DATA
      CALLED ON NULL INPUT
      P1 : BEGIN
 
      DECLARE iYYYY INTEGER DEFAULT 0 ;
      DECLARE GLOBAL TEMPORARY TABLE ITEMS (
            LOC VARCHAR(4),
            DIVAMT INTEGER,
            MTHYR VARCHAR(50),
            YYYY INTEGER,
            MM INETGER
            ) WITH REPLACE NOT LOGGED ;

      SELECT FISCALYYYY INTO iYYYY FROM CSIDEV . YMD WHERE DAYDATE = CURRENT DATE;

      INSERT INTO SESSION . ITEMS ( LOC, DIVAMT, MTHYR, YYYY, MM)
            SELECT DISTINCT
                  '',
                  0,
                  CSIDEV.YMD.MONNAME || ' ' || CAST(YYYY AS varchar(4)) AS mthyr,
                  CSIDEV.YMD.YYYY,
                  CSIDEV.YMD.MM
            FROM CSIDEV.YMD
            WHERE FiscalYYYY = iYYYY;
      
      INSERT INTO SESSION . ITEMS ( LOC, DIVAMT, MTHYR, YYYY, MM)
            SELECT
                  CSIDEV.DVL.Loc,
                  SUM(CSIDEV.DVL.EXTENDED_TOTAL_ALLOC) AS DivAmt,
                  CSIDEV.DVL.MONNAME || ' ' || CAST(CSIDEV.DVL.YYYY AS varchar(4)) AS mthyr,
                  CSIDEV.DVL.YYYY,
                  CSIDEV.DVL.MM
            FROM
                  CSIDEV.DVL
            GROUP BY
                  CSIDEV.DVL.Loc,
                  CSIDEV.DVL.FiscalYYYY,
                  CSIDEV.DVL.MONNAME || ' ' || CAST(CSIDEV.DVL.YYYY AS varchar(4)),
                  YYYY,
                  MM
            HAVING (CSIDEV.DVL.FiscalYYYY = iYYYY);

      P2: BEGIN
            DECLARE DB2_SP_SQL1 CURSOR FOR
            select distinct LOC as ColName
                  from SESSION . ITEMS
                  where LOC>''
                  order by ColName;
            DECLARE DB2_SP_SQL2 CURSOR FOR
            select distinct mthyr as RowName, YYYY, MM
                  from SESSION . ITEMS
                  order by YYYY, MM;
            DECLARE DB2_SP_SQL3 CURSOR FOR
            Select Loc as ColName, mthyr as RowName, DivAmt as Valu
                  from SESSION . ITEMS;
            OPEN DB2_SP_SQL1 ;
            OPEN DB2_SP_SQL2 ;
            OPEN DB2_SP_SQL3 ;
      END P2 ;
END P1 ;
--------------------------------------------------------------------------------------------
Above script creates SP in my Library ...
BUT attempt to call .... results in error
---------------------------------------------------------------------------------------------
call csidev.dvlchrt

SQL State: 42704
Vendor Code: -204
Message: [SQL0204] INETGER in *LIBL type *SQLUDT not found. Cause . . . . . :   INETGER in *LIBL type *SQLUDT was not found. If this is an ALTER TABLE statement and the type is *N, a constraint or partition was not found. If this is not an ALTER TABLE statement and the type is *N, a function, procedure, or trigger was not found. If a function was not found, INETGER is the service program that contains the function.  The function will not be found unless the external name and usage name do not match exactly.  Examine the job log for a message that gives more details on which function name is being searched for and the name that did not match. Recovery  . . . :   Change the name and try the request again.  If the object is a node group, ensure that the DB2 Multisystem product is installed on your system and create a nodegroup with the CRTNODGRP CL command. If an external function was not found, be sure that the case of the EXTERNAL NAME on the CREATE FUNCTION statement exactly matches the case of the name exported by the service program.






0
Comment
Question by:volking
  • 2
4 Comments
 
LVL 5

Author Comment

by:volking
ID: 22598515
Am I , ONCE AGAIN, missing some foundational concept?
0
 
LVL 18

Accepted Solution

by:
Dave Ford earned 1600 total points
ID: 22598557

According to the error message:

"INETGER" <> "INTEGER"

0
 
LVL 46

Assisted Solution

by:Kent Olsen
Kent Olsen earned 400 total points
ID: 22598627
Hi volking,

P1: and P2: are just labels within the routine.  

"P1: BEGIN" is the label "P1:" (or "P1"), followed by a BEGIN statement the defines a logical block and must be accompanied by an END statement.

In the function (Stored Procedure) you declare a block called P1.  Within P1, you declare another block called P2.


As for the error, follow Dave's advise and correct the spelling in the DECLARE GLOBAL TABLE command.   :)


Kent
0
 
LVL 5

Author Closing Comment

by:volking
ID: 31501265
Oh my ... do I feel stupid ...
HEY! VOLKING ..... READ THE SILLY ERROR MESSAGE!
Until someone is comfortable with a particular syntax, a DWEEB like me always assumes the problem is lack-of-knowledge ... not that my fingers made a mistake ... grin ...

Thanks Dave!

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

963 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