Quantcast
Channel: IBM Mainframe Computers Forums
Viewing all 8500 articles
Browse latest View live

DB2 :: RE: SQL Query optimization.

$
0
0
Author: Akatsukami
Posted: Mon Sep 05, 2016 12:13 am (GMT 5.5)

arunsoods wrote:
Nic - If i create INDEX as below on the table

CREATE INDEX INX_SEQ_ID
ON test_table (SEQ_ID)

and then run this query

EXEC SQL
SELECT MAX(SEQ_ID)
INTO :DCLTB99-TRANS.SEQ-ID
:SOF-TRANS-SEQ-ID
FROM TEST_TABLE
END-EXEC

Will this reduce the cost...??

Almost certainly.
Quote:
Bill - "Can't you store the value somewhere when you know it, rather than lazily rummaging about for the highest one?."

By the above do you mean that if I select all SEQ_ID using below query.

SELECT SEQ_ID FROM TEST_TABLE

and store the values in a PS file and then applying SORT to find the highest...

Will this work...???

I believe that what Mr. Woodger meant was to run the query once, and then to reuse either DCLTB99-TRANS.SEQ-ID OR SOF-TRANS-SEQ-ID , whichever you decide to derive directly from the DB2 table.
_________________
Data is not information.
Information is not knowledge.
Knowledge is not wisdom.


COBOL Programming :: RE: Wildcard logic in COBOL

$
0
0
Author: enrico-sorichetti
Subject: Reply to: Wildcard logic in COBOL
Posted: Mon Sep 05, 2016 4:02 am (GMT 5.5)

here is REXX solution

Code:

#! /usr/bin/env rexx

Trace "O"
signal  on  novalue name novalue
signal  on  halt    name halt
numeric digits 12

???.char = "%"
???.mult = "*"
???.null = "00"x
???.fail = -1

if 1 = 0 then do
    k = 0
    do  while lines("wctest.txt") > 0
        data = linein("wctest.txt")
        if  left(data,1) = "*" then ,
            iterate
        if  space(data)  = ""  then ,
            iterate
        k +=1
        data.0 = k
        data.k = data
    end
end
else do

    data.1  = 'patt = "12*5*78" ;           word = "12578" ;'
    data.2  = 'patt = "12*5*78" ;           word = "123578" ;'
    data.3  = 'patt = "12*5*78" ;           word = "12345678" ;'
    data.4  = 'patt = "12*5*78" ;           word = "123478" ;'
    data.5  = 'patt = "12*5*78" ;           word = "125789" ;'
    data.6  = 'patt = "12*5*78" ;           word = "1234567" ;'
    data.7  = 'patt = "%" ;                  word = "ABC" ;'
    data.8  = 'patt = "*%" ;                 word = "ABC" ;'
    data.9  = 'patt = "*" ;                  word = "ABC" ;'
    data.10 = 'patt = "A*" ;                 word = "ABC" ;'
    data.11 = 'patt = "A%" ;                 word = "ABC" ;'
    data.12 = 'patt = "A*%" ;                word = "ABC" ;'
    data.13 = 'patt = "*A" ;                 word = "ABC" ;'
    data.14 = 'patt = "*A*" ;                word = "ABC" ;'
    data.15 = 'patt = "A*B" ;                word = "ABC" ;'
    data.16 = 'patt = "AB*" ;                word = "ABC" ;'
    data.17 = 'patt = "*AB" ;                word = "ABC" ;'
    data.18 = 'patt = "*AB%" ;               word = "ABC" ;'
    data.19 = 'patt = "*%BC" ;               word = "ABC" ;'
    data.20 = 'patt = "*AB*C" ;              word = "ABC" ;'
    data.21 = 'patt = "*%A%B*CEND" ;         word = "xAyBzCEND" ;'
    data.22 = 'patt = "A*%BC*%%DEF*" ;       word = "AyBCzzDEF" ;'
    data.0  = 6
end

do  k = 1 to data.0
    interpret data.k

    objs = compile(patt)
    say left(">>"patt"<<", 20) ">>"objs"<<"

    word = word || ???.null
    wlen = length(word)
    wptr = 1
    do while ( objs \= "" )
        parse var objs func parm objs

        interpret "wptr = "func"('"word"','"wlen"','"parm"','"wptr"')"
        if  wptr == ???.fail then ,
            leave
    end
    if  wptr \= ???.fail then ,
        say "****** word >>"word"<< matches >>"patt"<<"
end

exit

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
wcleng:procedure expose ???.
    parse arg word, wlen, leng, wptr
    if  wlen < leng then ,
        return ???.fail
    return  1

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
wcmatch:procedure expose ???.
    parse arg word, wlen, parm, wptr
    plen = length(parm)

    if  wptr + plen - 1 > wlen  then ,
        return ???.fail
    if  substr(word, wptr, plen) == parm then ,
        return wptr + plen
    else ,
        return ???.fail

return ???.fail

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
wcskip:procedure expose ???.
    parse arg word, wlen, parm, wptr
    plen = length(parm)

    if  wptr + parm - 1 > wlen then ,
        return ???.fail
    else ,
        return wptr + parm

return ???.fail

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
wcfind:procedure expose ???.
    parse arg word, wlen, parm, wptr
    plen = length(parm)

    wptr = pos(parm, word, wptr, wlen)

    if  wptr == 0 then ,
        return ???.fail
    else ,
        return wptr + plen

return ???.fail


/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
compile:procedure expose ???.
    parse arg patt

    patt = patt || ???.null
    plen = length(patt)

    leng = 0

    objs = ""

    find = 0
    skip = 0

    tokn = ""
    do  p = 1 to plen
        ch = substr(patt, p, 1)
        select
            when ( ch == ???.mult ) then do
                if  tokn \= "" then do
                    objs = objs "wcmatch" tokn
                    tokn = ""
                end
                find += 1
            end
            when ( ch == ???.char) then do
                leng += 1
                if  tokn \= "" then do
                    objs = objs "wcmatch" tokn
                    tokn = ""
                end
                skip += 1
            end
            otherwise do
                leng += 1
                if  skip > 0 then do
                    objs = objs "wcskip" skip
                    skip = 0
                end
                if  find > 0 then do
                    objs = objs "wcfind" ch
                    find = 0
                    iterate
                end
                tokn = tokn || ch
            end
        end
    end
    if  tokn \= "" then ,
        objs = objs "wcmatch" tokn
    objs = "wcleng" leng objs
    return objs
return  ???.fail

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
logic_error:
say  "** "copies("- ",35)
say  "** Logic error at line '"sigl"' "
say  "** "
exit

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
novalue:
say  "** "copies("- ",35)
say  "** Novalue trapped, line '"sigl"' var '"condition("D")"' "
say  "** "
exit

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
halt
say  "** "copies("- ",35)
say  "** Halt    trapped, line '"sigl"' var '"condition("D")"' "
say  "** "
exit





a bit more elegant IMO

it compiles the pattern
and the executes the object
_________________
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort icon_cool.gif

COBOL Programming :: RE: Wildcard logic in COBOL

$
0
0
Author: dudenithy
Posted: Mon Sep 05, 2016 3:49 pm (GMT 5.5)

Thanks for the above suggestions. Too simple, but unfortunately I cannot use it, since I have to do it in COBOL only icon_cry.gif.
I'm trying to build the logic in COBOL. This will work to a extent with some complicated Wildcard combinations must be restricted in Parameters. I will post when ready.
In the meantime, if anyone already smart have a logic in COBOl, always be welcome icon_biggrin.gif.

COBOL Programming :: RE: Wildcard logic in COBOL

$
0
0
Author: enrico-sorichetti
Subject: Reply to: Wildcard logic in COBOL
Posted: Mon Sep 05, 2016 4:22 pm (GMT 5.5)

my snippets were not a direct suggestion for You to use them,


the question tickled my mathematics oriented mind - and I posted them

there should be a section dedicated to algorithm and code snippets - not/loosely related to questions asked

but really FIRST THE LOGIC and after that the programming language,
if You have a good logic the programming language will just be a lowly technicality

the rexx approach should work with cobol
and it will be easier because it splits the problem in two
the first half will be concerned only with the mask/pattern
the second one only with the string to be matched

all should be easy to implement with string reference and a couple of arrays
_________________
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort icon_cool.gif

TSO/ISPF :: RE: Increase the screen size after split

$
0
0
Author: mistah kurtz
Posted: Mon Sep 05, 2016 4:34 pm (GMT 5.5)

Thanks Robert. I got what I needed.

CICS :: Get system time in micro second or clock uint.

$
0
0
Author: lind sh
Subject: Get system time in micro second or clock uint.
Posted: Mon Sep 05, 2016 11:14 pm (GMT 5.5)

Dear friends
How can I get CICS or system time in micro-second unit. I need to take the time in high precision.
I know it's possible by STCK in assembly but I need a sample to understand it.
When I run the following program, the system take abend 0C4.!!!
Code:
STCKCON1 CSECT                                                           
STCKCON1 AMODE 31                                                         
STCKCON1 RMODE 24                                                         
         STM   14,12,12(13)                                               
         LR    12,15                                                     
         USING STCKCON1,12                                               
         LA    15,SAVE                                                   
         ST    15,8(13)                                                   
         ST    13,4(15)                                                   
         LR    13,15                                                     
         STCK TODCLOCK                                                   
TODCLOCK DS XL8                                       TOD CLOCK VALUE     
*#         WTO   TODCLOCK                                                 
         L     13,4(13)                                                   
         XC    8(4,13),8(13)                                             
         LM    14,12,12(13)                                               
         DROP  12                                                         
         SR    15,15                                                     
         BR    14                                                         
         END                                                               

Thanks.

TSO/ISPF :: Truncated error message after VERIFY with LISTV

$
0
0
Author: David Sde
Subject: Truncated error message after VERIFY with LISTV
Posted: Mon Sep 05, 2016 11:26 pm (GMT 5.5)

Hi,

I hope someone can guide me. I need to validate an input field against a list of forty possible values. In the INIT section, I have:

Code:
&VALUES = 'VALUE1    +
           VALUE2    +
           VALUE3    +
<etc>
           VALUE40'   


In the )PROC section, I say:

Code:
VER (&FIELD1,NB,LISTV,&VALUES)


The VER is working perfectly, but my issue is with the error message displayed when the user enters an invalid value. The displayed "short message" is INVALID VALUE, which is fine. But when I hit PF1 to display the "long message," I get a box with the message: "Enter one of the listed values ('VALUE1,VALUE2,VALUE3,..'), and the list is incomplete. Instead of showing all forty valid values, it only appears to show as many values as will fit on a single row of the panel.

Is there a way I force the panel to display the entire list of valid values? It would probably take up about three panel rows, but I'm willing to do that if it's possible.

Thanks so much,

David

TSO/ISPF :: RE: Truncated error message after VERIFY with LISTV

$
0
0
Author: enrico-sorichetti
Subject: Reply to: Truncated error message after VERIFY with LISTV
Posted: Tue Sep 06, 2016 12:07 am (GMT 5.5)

read the ISPF manuals for the format of the short and long messages
_________________
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort icon_cool.gif


CICS :: RE: Get system time in micro second or clock uint.

$
0
0
Author: Robert Sample
Posted: Tue Sep 06, 2016 12:18 am (GMT 5.5)

Where is the S0C4 showing up? And you do NOT want to use the WTO on that value -- it is a 64-bit binary value with bit 51 representing 1 microsecond, so without some work you won't see anything human-readable from the WTO.

I suspect you're probably getting the S0C4 right after the STCK instruction, because it is unlikely that the value represents valid z/OS OP codes. You need to move the TODCLOCK definition after your return.
_________________
TANSTAAFL

The first rule of code reuse is that the code needs to be worth re-using.

"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." -- Donald Knuth

TSO/ISPF :: RE: Truncated error message after VERIFY with LISTV

$
0
0
Author: David Sde
Subject: Reply to: Truncated error message after VERIFY with LISTV
Posted: Tue Sep 06, 2016 12:22 am (GMT 5.5)

Enrico,

I have already been through the "ISPF Dialog Developer's Guide and Reference," and I did read what I thought were the relevant sections pertaining to long and short messages. It may well be that I missed something, or that there is another manual I should consult. If that is the case, I would appreciate any information (from anyone) which would help me more precisely locate the answer.

David

TSO/ISPF :: RE: Truncated error message after VERIFY with LISTV

$
0
0
Author: David Sde
Subject: Reply to: Truncated error message after VERIFY with LISTV
Posted: Tue Sep 06, 2016 12:36 am (GMT 5.5)

Okay, fair enough: I did find something. In the "ISPF Messages and Codes" manual, in response to the "Enter one of the listed values" messages, I see:

"Programmer response: If the listchoices occupy more than 72 bytes, provide help via a customized message using the MSG keyword on the VER statement."

I will look into that; thank you.

David

TSO/ISPF :: RE: Truncated error message after VERIFY with LISTV

$
0
0
Author: David Sde
Subject: Reply to: Truncated error message after VERIFY with LISTV
Posted: Tue Sep 06, 2016 12:42 am (GMT 5.5)

Yup, it's a wrap. That did it; thank you.

David

CICS :: RE: Get system time in micro second or clock uint.

$
0
0
Author: steve-myers
Posted: Tue Sep 06, 2016 1:50 am (GMT 5.5)

Robert Sample wrote:
... And you do NOT want to use the WTO on that value -- it is a 64-bit binary value with bit 51 representing 1 microsecond, so without some work you won't see anything human-readable from the WTO.
Agreed.
Robert Sample wrote:
Where is the S0C4 showing up? ... I suspect you're probably getting the S0C4 right after the STCK instruction, because it is unlikely that the value represents valid z/OS OP codes. You need to move the TODCLOCK definition after your return.
In general, I agree. However, it is quite possible it will be a valid operation. I just got D14D84B2 83332000 (or MVN 1202(78,R8),819(R8)) running on Hercules. Depending on what's in register 8, the odds are this will 0C4. Of course, what you will get depends on the actual time, though it I think it will be MVN for a while.

DB2 :: RE: SQL Query optimization.

$
0
0
Author: Rohit Umarjikar
Posted: Tue Sep 06, 2016 5:06 am (GMT 5.5)

1. Avoid hitting the same query multiple times in the same call.
2.if the table is every day populated by a batch then insert or update a new row with the max count so that online don't have to do the same work again and again. This is what I guess Bill say's.
3. As long as you have a index you could try order by desc clause "with ur and fetch first 1 row only or optimize for 1 row only"
4.Look for OLAP, if that does the trick.
5 BMC cost is not true alway so try executing the query and see for issues
6 Have you spoken to DBA as yet?
_________________
Regards,
Rohit Umarjikar
"Knowledge is knowing that a tomato is a fruit, but Wisdom is knowing not to put it in a fruit salad."icon_razz.gif

CICS :: RE: Get system time in micro second or clock uint.

$
0
0
Author: PeterHolland
Posted: Tue Sep 06, 2016 10:54 am (GMT 5.5)

Code:

         STCK TODCLOCK                                                   
TODCLOCK DS XL8                                       TOD CLOCK VALUE     
*#         WTO   TODCLOCK                                                 
         L     13,4(13)                                                   
 


Executing the TODCLOCK value?

Sorry Robert, you mentioned that already.


COBOL Programming :: RE: Wildcard logic in COBOL

$
0
0
Author: Rohit Umarjikar
Posted: Tue Sep 06, 2016 11:27 am (GMT 5.5)

Quote:
Thanks for the above suggestions. Too simple, but unfortunately I cannot use it, since I have to do it in COBOL only.
I'm trying to build the logic in COBOL. This will work to a extent with some complicated Wildcard combinations must be restricted in Parameters. I will post when ready.
May we know why? But then did you understand both the logic? What in cobol doesn't let you mimic the above logic?
_________________
Regards,
Rohit Umarjikar
"Knowledge is knowing that a tomato is a fruit, but Wisdom is knowing not to put it in a fruit salad."icon_razz.gif

All Other Mainframe Topics :: EBCDIC to ASCII conversion using OCOPY

$
0
0
Author: mistah kurtz
Subject: EBCDIC to ASCII conversion using OCOPY
Posted: Tue Sep 06, 2016 2:26 pm (GMT 5.5)

I'm using the OCOPY command to to convert an EBCDIC data to ASCII using the following OCOPY command:
Code:
OCOPY INDD(INPUT) OUTDD(OUTPUT) TEXT CONVERT((BPXFX311)) FROM1047

The above command uses the CCSID 1047 for conversion.

I want to know if there are any utilities/commands to convert the data using other CCSIDs tables EBCDIC CCSID 37 and EBCDIC CCSID 500.

Basically we want to capture the difference in code points between these three tables. IBM has documented these differences here.

I want to know if we can validate the differences by running any utilities in Mainframe. Is there any way to find what is the defualt CCSID table used for conversion from EBCDIC to ASCII.

Thanks
K.

All Other Mainframe Topics :: RE: EBCDIC to ASCII conversion using OCOPY

$
0
0
Author: Robert Sample
Posted: Tue Sep 06, 2016 4:33 pm (GMT 5.5)

Research iconv in the UNIX System Services Commands manual. Since defaults depend upon your site, ask your site support group for that information.
_________________
TANSTAAFL

The first rule of code reuse is that the code needs to be worth re-using.

"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." -- Donald Knuth

All Other Mainframe Topics :: RE: EBCDIC to ASCII conversion using OCOPY

$
0
0
Author: mistah kurtz
Posted: Tue Sep 06, 2016 5:10 pm (GMT 5.5)

Thanks Robert. I found the iconv command.

What I understood from the above link that it will convert the characters set from one code set to another.

I have created a file in mainframe with 256 byte ( from X'00' to X'FF'). And the output should be converted to ASCII using the code table: 1047, 037 and 500.

So what should I do:
1. FTP the file from Mainframe to UNIX in binary mode.
2. Then to convert it into ASCII, I should use the following command in UNIX:
Code:
iconv –t IBM-1047 EBCDIC.DATA > ASCII.1047.DATA

Is this the correct approach.

All Other Mainframe Topics :: RE: EBCDIC to ASCII conversion using OCOPY

$
0
0
Author: Robert Sample
Posted: Tue Sep 06, 2016 5:40 pm (GMT 5.5)

For consistency, use
Code:
 iconv -f <from type> -t <to type> <source file> ><target file>

_________________
TANSTAAFL

The first rule of code reuse is that the code needs to be worth re-using.

"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." -- Donald Knuth

Viewing all 8500 articles
Browse latest View live