473,378 Members | 1,162 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

is this table function possible for IBM DB2 v8.2?

21
is this table function possible for IBM DB2 v8.2?


CREATE FUNCTION PEGASUS.readOrder( wsLoadNumberChar CHARACTER(07),
wsDispatchYearFlg CHARACTER(01) )
RETURNS TABLE (ORD_ORDI INTEGER
, ORD_PKPD CHARACTER (10)
, ORD_EMTD CHARACTER (10)
, ORD_DSPSTT CHARACTER (01)
, ORD_LSTDSPNBR INTEGER
, ORD_DIVC CHARACTER (10)
, ORD_PRELOADTRLR INTEGER
, ORD_CURORDSTTC CHARACTER (10)
, ORD_LOADNUMBERFOUNDFLG CHARACTER (01)
, ORD_LOADNUMBERNOTFOUNDFLG CHARACTER (01)
, ORD_ONWAREHOUSEFlG CHARACTER (01)
, ORD_CRITICALERRORFLG CHARACTER (01))
LANGUAGE SQL
SPECIFIC PEGASUS.readOrder
READS SQL DATA
--------------------------------------------------------------------------------------------------
-- SQL UDF (Scalar)
--------------------------------------------------------------------------------------------------
F1: BEGIN ATOMIC

DECLARE wsLoadNumberFoundFlg CHAR(01) DEFAULT ' ';
DECLARE wsLoadNumberNotFoundFlg CHAR(01) DEFAULT ' ';
DECLARE wsCriticalErrorFlg CHAR(01) DEFAULT ' ';
DECLARE wsPkpD CHAR(10) DEFAULT ' ';
DECLARE wsEmtD CHAR(10) DEFAULT ' ';
DECLARE wsDspStt CHAR(01) DEFAULT ' ';
DECLARE wsDivC CHAR(10) DEFAULT ' ';
DECLARE wsCurOrdSttC CHAR(10) DEFAULT ' ';
DECLARE wsOrdI INTEGER DEFAULT 0;
DECLARE wsLstDspNbr INTEGER DEFAULT 0;
DECLARE wsPreLoadTrlr INTEGER DEFAULT 0;
DECLARE CsrStmt VARCHAR (256);
DECLARE loadCsr CURSOR FOR v_SQL_stmt;
DECLARE loadCsrW CURSOR FOR v_SQL_stmt;

SET CsrStmt = 'SELECT ORD_I' ||
' , DATE(PKP_BEG_S)' ||
' , DATE(DEL_BEG_S)' ||
' , DSP_STT' ||
' , LST_DSP_NBR' ||
' , DIV_C' ||
' , PRL_TRL_EQP_I' ||
' , CUR_ORD_STT_C' ||
' FROM PEGASUS."ALI.TORDER"' ||
' WHERE ORD_NBR_CH = ?' ||
' AND REQ_TYP_C = ''ORDER''' ||
' WITH UR';

PREPARE v_SQL_stmt FROM CsrStmt;
OPEN loadCsr USING wsLoadNumberChar;
FETCH loadCsr
INTO wsOrdI
, wsPkpD
, wsEmtD
, wsDspStt
, wsLstDspNbr
, wsDivC
, wsPreLoadTrlr
, wsCurOrdSttC;

CASE SQLCODE
WHEN 0 THEN
SET wsLoadNumberFoundFlg = 'Y';
WHEN +100 THEN
--1211A-READ-ORDER-WHSE
SET CsrStmt = 'SELECT ORD_I' ||
' , DATE(PKP_BEG_S)' ||
' , DSP_STT' ||
' , LST_DSP_NBR' ||
' , CUR_ORD_STT_C' ||
' FROM PEGASUS."ALI.TORDER_W"'||
' WHERE ORD_NBR_CH = ?' ||
' AND REQ_TYP_C = ''ORDER''' ||
' AND DIV_C IN (''HJBT JBVAN'', ''HJBT JBDCS'', ''HJBT JBHA'')' ||
' WITH UR';
PREPARE v_SQL_stmt FROM CsrStmt;
OPEN loadCsrW USING wsLoadNumberChar;
FETCH loadCsrW
INTO wsOrdI
, wsPkpD
, wsDspStt
, wsLstDspNbr
, wsCurOrdSttC;
CASE SQLCODE
WHEN 0 THEN
SET wsOnWarehouseFlag = 'Y';
SET wsLoadNumberFoundFlg = 'Y';
WHEN +100 THEN
IF wsDispatchYearFlg = 'N' THEN
SET wsLoadNumberNotFoundFlg = 'Y';
END IF;
ELSE
SET wsCriticalErrorFlg = 'Y';
CLOSE loadCsrW;
CLOSE loadCsr;
END CASE;
CLOSE loadCsrW;
--END-1211A
ELSE
SET wsCriticalErrorFlg = 'Y';
CLOSE loadCsr;
END CASE;
CLOSE loadCsr;

INSERT INTO TABLE
( ORD_ORDI
, ORD_PKPD
, ORD_EMTD
, ORD_DSPSTT
, ORD_LSTDSPNBR
, ORD_DIVC
, ORD_PRELOADTRLR
, ORD_CURORDSTTC
, ORD_LOADNUMBERFOUNDFLG
, ORD_LOADNUMBERNOTFOUNDFLG
, ORD_ONWAREHOUSEFlG
, ORD_CRITICALERRORFLG)
VALUES ( wsOrdI
, wsPkpD
, wsEmtD
, wsDspStt
, wsLstDspNbr
, wsDivC
, wsPreLoadTrlr
, wsCurOrdSttC
, wsLoadNumberFoundFlg
, wsLoadNumberNotFoundFlg
, wsOnWarehouseFlag
, wsCriticalErrorFlg);

RETURN TABLE
END
Jun 22 '07 #1
0 1055

Sign in to post your reply or Sign up for a free account.

Similar topics

61
by: Toby Austin | last post by:
I'm trying to replace <table>s with <div>s as much as possible. However, I can't figure out how to do the following… <table> <tr> <td valign="top" width="100%">some data that will...
2
by: Hennie de Nooijer | last post by:
Because of an error in google or underlying site i can reply on my own issue. Therefore i copied the former entered message in this message....
1
by: dschectman | last post by:
I have an interesting issue. I need to implement a dynamic table to mimic a select list. Each time you double click from the master list, a row is added to the list of selected items. The list...
6
by: dharmadam | last post by:
Is it possible to pass a column name or the order of the column name in the DB2 table table function. For example, I want to update the address of a person by passing one of the address column name...
1
by: Graeme Hinchliffe | last post by:
Hiya, Not had much experience with tiggers under postgres but am liking them so far. My problem is this. I am writing an updates system, postgres holds the master copy of the database, any...
1
by: Rako | last post by:
My problem is: I want to create an index to any of the available picture-groups. This index is a table of thumbs with a scrollbar. If you click on the thumb, you get the full picture displayed. ...
21
by: Johan Tibell | last post by:
I would be grateful if someone had a minute or two to review my hash table implementation. It's not yet commented but hopefully it's short and idiomatic enough to be readable. Some of the code...
6
by: Romulo NF | last post by:
Greetings again to everyone, Im back to show this grid componenet i´ve developed. With this grid you can show the data like a normal table, remove the rows that you need, add rows, import data,...
5
by: Romulo NF | last post by:
Greetings, I´m back here to show the new version of the drag & drop table columns (original script ). I´ve found some issues with the old script, specially when trying to use 2 tables with...
4
by: SirCodesALot | last post by:
Hi All, I am trying to dynamically replace a table in the dom, anyone have an idea on how to do this. here is some sample suedo code of what I want to do. var tableHTML = "<table...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.