Solved

What is P1:BEGIN and P2:BEGIN do?

Posted on 2008-09-29
4
1,257 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:
daveslash earned 400 total points
ID: 22598557

According to the error message:

"INETGER" <> "INTEGER"

0
 
LVL 45

Assisted Solution

by:Kdo
Kdo earned 100 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now