473,795 Members | 2,391 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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


CREATE FUNCTION PEGASUS.readOrd er( wsLoadNumberCha r CHARACTER(07),
wsDispatchYearF lg 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_LOADNUMBERF OUNDFLG CHARACTER (01)
, ORD_LOADNUMBERN OTFOUNDFLG CHARACTER (01)
, ORD_ONWAREHOUSE FlG CHARACTER (01)
, ORD_CRITICALERR ORFLG CHARACTER (01))
LANGUAGE SQL
SPECIFIC PEGASUS.readOrd er
READS SQL DATA
--------------------------------------------------------------------------------------------------
-- SQL UDF (Scalar)
--------------------------------------------------------------------------------------------------
F1: BEGIN ATOMIC

DECLARE wsLoadNumberFou ndFlg CHAR(01) DEFAULT ' ';
DECLARE wsLoadNumberNot FoundFlg CHAR(01) DEFAULT ' ';
DECLARE wsCriticalError Flg 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.TO RDER"' ||
' WHERE ORD_NBR_CH = ?' ||
' AND REQ_TYP_C = ''ORDER''' ||
' WITH UR';

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

CASE SQLCODE
WHEN 0 THEN
SET wsLoadNumberFou ndFlg = '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.TO RDER_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 wsLoadNumberCha r;
FETCH loadCsrW
INTO wsOrdI
, wsPkpD
, wsDspStt
, wsLstDspNbr
, wsCurOrdSttC;
CASE SQLCODE
WHEN 0 THEN
SET wsOnWarehouseFl ag = 'Y';
SET wsLoadNumberFou ndFlg = 'Y';
WHEN +100 THEN
IF wsDispatchYearF lg = 'N' THEN
SET wsLoadNumberNot FoundFlg = 'Y';
END IF;
ELSE
SET wsCriticalError Flg = 'Y';
CLOSE loadCsrW;
CLOSE loadCsr;
END CASE;
CLOSE loadCsrW;
--END-1211A
ELSE
SET wsCriticalError Flg = '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_LOADNUMBERF OUNDFLG
, ORD_LOADNUMBERN OTFOUNDFLG
, ORD_ONWAREHOUSE FlG
, ORD_CRITICALERR ORFLG)
VALUES ( wsOrdI
, wsPkpD
, wsEmtD
, wsDspStt
, wsLstDspNbr
, wsDivC
, wsPreLoadTrlr
, wsCurOrdSttC
, wsLoadNumberFou ndFlg
, wsLoadNumberNot FoundFlg
, wsOnWarehouseFl ag
, wsCriticalError Flg);

RETURN TABLE
END
Jun 22 '07 #1
0 1082

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

Similar topics

61
24508
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 'stretch'</td> <td valign="top" width="300">some data that won't 'stetch'</td> </tr> </table>
2
2337
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. -------------------------------------REPY---------------------------------- Hi Maybe i wasn't clear. I want to dynamically check whether what the lowest date and the highest date is in the calendar table. The presented solutions has fixed dates and i don't want that. If i could store a global...
1
5711
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 of selected items has a column header and differentiation between odd and even rows. This part is trivial. Clients have the ability to re-order the list of selected items. This is also trivial: I trap the onClick event for a row to select it. ...
6
6299
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 like ZIP CODE or ADDRESS LINE. I will call the function with three parameter--UpdateAddress(5,zip_code,person_id) where 5 indicates ZIP_CODE is the fifth column in the table. If 4 is passed, it indicates the address line is to be updated. ...
1
2095
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 changes made to this are logged in an updates table which is monitored by a daemon, which if any updates are spotted propigates them to the remote servers. I have written an initial trigger that spots any changes made to the
1
2402
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. This table must be created from scratch. (The function must be reusable, and speed up the load-time: only one of the various possible picture-groups will be indexed. any other will be loaded by request. The picture-groups are defined in flexible...
21
3227
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 (i.e. the get_hash function) is borrowed from various snippets I found on the net. Thee free function could probably need some love. I have been thinking about having a second linked list of all entries so that the cost of freeing is in proportion to...
6
7998
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, call determined functions, and edit the data already present What will you need to use the grid? A table with standard markup and an ID to call the script that will turn the table into a grid Parameters: tabelaID => id of the table that will...
5
13812
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 drag&drop on the same page (which was not possible). Now i´ve a new concept of the script, more object oriented. I´ve also commented the whole code so you guys can easier understand it engine. What exactly we need when trying to make a column drag &...
4
1740
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 id=\"table1\"><tr><td>this is table 1</td></ tr></table>"; var tableHTML2 = "<table id=\"table2\"><tr><td>this is table 2</td></
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10438
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10164
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9042
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.