Click here to Skip to main content
15,303,516 members
Home / Discussions / Database
   

Database

 
QuestionSQL server query Pin
Swap96-Oct-15 4:04
MemberSwap96-Oct-15 4:04 
AnswerRe: SQL server query Pin
Richard Andrew x646-Oct-15 7:10
professionalRichard Andrew x646-Oct-15 7:10 
AnswerRe: SQL server query Pin
RNA Team10-Oct-15 8:33
MemberRNA Team10-Oct-15 8:33 
QuestionHOW TO COPY DBF Files in VB.NET Pin
sunil8800891-Oct-15 22:17
Membersunil8800891-Oct-15 22:17 
AnswerRe: HOW TO COPY DBF Files in VB.NET Pin
phil.o1-Oct-15 23:55
mvephil.o1-Oct-15 23:55 
AnswerRe: HOW TO COPY DBF Files in VB.NET Pin
Patrice T2-Oct-15 0:56
mvePatrice T2-Oct-15 0:56 
GeneralRe: HOW TO COPY DBF Files in VB.NET Pin
sunil8800893-Oct-15 21:50
Membersunil8800893-Oct-15 21:50 
Questionreturn the results from Query union the external proc in DB2 Pin
sudevsu30-Sep-15 8:49
Membersudevsu30-Sep-15 8:49 
Hello experts,

I am pretty new to DB2. I have a query that returns some result. For each row of the results, I should pass a value from results to external Procedure. Now I want an union of both the results. Here is what I have tried. And I am banging my head to wall since last three days. Can someone please help me with this? It is really really important now.
BEGIN

DECLARE EOF_COND INTEGER DEFAULT 0 ;
DECLARE @ITEM CHAR ( 30 ) ;
DECLARE @BIN CHAR ( 10 ) ;
DECLARE @SIZE CHAR ( 30 ) ;
DECLARE @TIRERACK CHAR ( 10 ) ;
DECLARE @RACKSBIN CHAR ( 10 ) ;
DECLARE @DESC CHAR ( 100 ) ;
DECLARE @DESC1 CHAR ( 100 ) ;
DECLARE @ONHAND CHAR ( 10 ) ;
DECLARE @COMTD CHAR ( 10 ) ;
DECLARE @USEDRACKS CHAR ( 10 ) ;
DECLARE @OPENRACKS CHAR ( 10 ) ;
DECLARE @TEMP CHAR ( 10 ) ;
DECLARE RESULT INTEGER DEFAULT 0 ;


DECLARE CR1 CURSOR WITH RETURN FOR

SELECT T2 . ICITEM , T2 . BABLOC , C . ISSIZE , D . UNITSPER
, E . NBRRCKBINB , F . ICDSC1 , F . ICDSC2 , T2 . TQOH , T2 . TQCM
, CEIL ( INTEGER ( ( T2 . TQOH ) ) / D . UNITSPER )
NBR_USED_RACKS
, E . NBRRCKBINB - ( CEIL ( INTEGER ( ( T2 . TQOH ) ) / D . UNITSPER ) )
NBR_OPEN_RACKS , ( E . NBRRCKBINB * D . UNITSPER ) - T2 . TQOH
FROM (
SELECT A . BACMP , A . BALOC , MIN ( A . BAITEM ) ICITEM
, A . BABLOC , INTEGER ( SUM ( A . BAQOH ) ) TQOH ,
INTEGER ( SUM ( A . BAQCM ) ) TQCM
FROM TESTDATA . VINBINI A WHERE A . BALOC = '13' AND 1 = A . BACMP AND
A . BAQOH - A . BAQCM > 0 GROUP BY A . BACMP , A . BALOC , A . BABLOC HAVING
MIN ( A . BAITEM ) = MAX ( A . BAITEM )
AND SUM ( A . BAQOH - A . BAQCM ) > 0
) AS T2
, TESTDATA . PALITMLOC B , TESTDATA . VINITEMSIZ C , TESTDATA . PALSIZQTY D , TESTDATA . PALBINPF E
, TESTDATA . VINITEM F
WHERE T2 . BACMP = B . TACOMP AND T2 . ICITEM = B . ICITEM
AND T2 . BALOC = B . IALOC AND T2 . ICITEM = F . ICITEM
AND T2 . ICITEM = C . ISITEM
AND B . PALLETID = D . PALLETID
AND C . ISSIZE = D . ISSIZE
AND E . TACOMP = T2 . BACMP
AND E . IALOC = T2 . BALOC
AND E . IMBLOC = T2 . BABLOC
AND E . PALLETID = B . PALLETID
ORDER BY 1 , 2 ;


OPEN CR1 ;
SET EOF_COND = 0 ;
FETCH CR1 INTO @ITEM , @BIN , @SIZE , @TIRERACK , @RACKSBIN , @DESC , @DESC1 , @ONHAND , @COMTD , @USEDRACKS , @OPENRACKS , @TEMP ;

CALL TESTDATA . PARECR24SP ( '01' , '13' , @BIN , RESULT ) ;

RETURN ;

END 

Your help is much appreciated.
Thanks
Happy Coding!

QuestionDatabase relationship for tables Pin
maugonza30-Sep-15 8:43
Membermaugonza30-Sep-15 8:43 
AnswerRe: Database relationship for tables Pin
Jörgen Andersson1-Oct-15 2:12
professionalJörgen Andersson1-Oct-15 2:12 
SuggestionRe: Database relationship for tables Pin
Nathan Minier1-Oct-15 7:15
professionalNathan Minier1-Oct-15 7:15 
QuestionMSaccess query to access random value from database Pin
Member 1202314130-Sep-15 4:50
MemberMember 1202314130-Sep-15 4:50 
QuestionMusic Database Pin
morrism3530-Sep-15 2:30
Membermorrism3530-Sep-15 2:30 
AnswerRe: Music Database Pin
Richard MacCutchan30-Sep-15 3:05
mveRichard MacCutchan30-Sep-15 3:05 
QuestionQuery is not producing the correct results(SOLVED) Pin
samflex28-Sep-15 5:45
Membersamflex28-Sep-15 5:45 
AnswerRe: Query is not producing the correct results Pin
Richard Deeming28-Sep-15 6:22
mveRichard Deeming28-Sep-15 6:22 
GeneralRe: Query is not producing the correct results Pin
samflex28-Sep-15 7:32
Membersamflex28-Sep-15 7:32 
QuestionMove GROUP_CONCAT's comma values to columns Pin
Jassim Rahma22-Sep-15 22:03
MemberJassim Rahma22-Sep-15 22:03 
Questionpostgresql database issues Pin
Member 1191972221-Sep-15 22:09
MemberMember 1191972221-Sep-15 22:09 
AnswerRe: postgresql database issues Pin
Richard MacCutchan21-Sep-15 22:50
mveRichard MacCutchan21-Sep-15 22:50 
GeneralRe: postgresql database issues Pin
Member 1191972221-Sep-15 23:23
MemberMember 1191972221-Sep-15 23:23 
GeneralRe: postgresql database issues Pin
Richard MacCutchan21-Sep-15 23:27
mveRichard MacCutchan21-Sep-15 23:27 
GeneralRe: postgresql database issues Pin
Member 1191972221-Sep-15 23:31
MemberMember 1191972221-Sep-15 23:31 
GeneralRe: postgresql database issues Pin
Member 1191972221-Sep-15 23:34
MemberMember 1191972221-Sep-15 23:34 
GeneralRe: postgresql database issues Pin
Richard MacCutchan21-Sep-15 23:52
mveRichard MacCutchan21-Sep-15 23:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.