Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

Returning Status From Datatrieve (DTR)

SOLVED
Go to solution
Ramondo
Advisor

Returning Status From Datatrieve (DTR)

Hi guys, only my second post here...

I don't know if anyone uses DTR anymore, but I'd like to know if it's possible to return a status to a command procedure to indicate when an error has occurred with a DTR command. Here's the situation:

Log of DTR within a command procedure to write a record to an RMS file that has "no duplicates" (simplified version)...

$
$ DTR
DATATRIEVE V7.2A
Digital Query and Report System
Type HELP for help


ready interface_domains.svoc_interface_tracking as trf write

store trf using
begin
run_number = "000001";
file_type = "NOTEIF";
extract_date = "20061220";
batch_status = "P";
data_flag = "N";
sched_seq_number = "000001";
file_seq_number = "01";
day_seq_number = "01";
end
You cannot store a duplicate value in an RMS key field that doesn't allow duplicates.

exit
$ l_stat = $status
$!
$ if .not. l_stat
$ endif
$!
$ exit

$status always has a value %X008D8CB9 on exit from DTR, no "on error goto" or checking of $status is going to pick up the fact that the record wasn't written.

Seeing as all the data in this case is character means I could use DCL to concatenate and $write/error=[err trap], but the DTR method seems more correct.

Redirecting the output to a separate log and searching for "You cannot store..." seems like too much trouble too.

Maybe it's not designed to be used this way.

Any thoughts?

Thanks,

Ramondo.
4 REPLIES
John Gillings
Honored Contributor

Re: Returning Status From Datatrieve (DTR)

Ramondo,

%X008D8CB9 is a DTR facility message, see:

$ WRITE SYS$OUTPUT F$MESSAGE(%X008D8CB9)
%DTR-S-NOMSG, Message number 008D8CB9

Since I don't have a DTRMSG file (DTR not installed here), I can't identify the actual message, but you may be able to. Try:

$ SET MESSAGE SYS$MESSAGE:DTRMSG

and repeat the above command.

The severity is -S- which means "Success", so whatever DTR has done, it's been considered successful.

By OpenVMS conventions, an image should return a longword status code in R0 when it exits. DCL makes that value available as $STATUS. It's entirely up to DTR to decide what to place in R0. My recollection is that DTR doesn't give you anything useful. However, it's been a long time, so I may be incorrect. There may also be switches or commands within DTR to return something to DCL which you can test.
A crucible of informative mistakes
Ramondo
Advisor

Re: Returning Status From Datatrieve (DTR)

Thanks for the prompt reply.

DTR> exit
$ sh sym $status
$STATUS == "%X008D8CB9"
$ SET MESSAGE SYS$MESSAGE:DTRMSGs
$ write sys$output f$message("%X008D8CB9")
%DTR-S-EXIT, Exit from DATATRIEVE requested by operator.


It's the status of EXIT command at the end of my DTR session that it's returning.

If I remove the EXIT the last DTR command executed is the attempt to store the record - but same result. It seems there's an implied exit that returns the generic DTR Exit Status regardless of what's gone before.

I've had a look at DTR help and can't find anything relating to return of status codes...
Keith Cayemberg
Trusted Contributor
Solution

Re: Returning Status From Datatrieve (DTR)


Hi Ramondo,

Actually the Callable DTR is intended to be used when you need that type of error handling control of Datatrieve functions. However there is a way to first grab the Datatrieve Status Value and then put it into your own DCL symbol. Please see the example below that has already worked for me.

$ mc dtr32 DEC DATATRIEVE V7.2
Digital Query and Report System
Type HELP for help
DTR> show mydomain
Element "MYDOMAIN" not found in dictionary.
DTR> FN$SET_SYMBOL("DTR_STATUS",FN$STATUS)
DTR> exit
$ set message sys$message:DTRMSGS.EXE
$ say f$message("%D''DTR_STATUS'") %DTR-E-ELTNOTDIC, Element "!AS" not found in dictionary.
$ show symbol DTR_STATUS
DTR_STATUS = "9273746"
$

Note that the DTR Status returned is a Decimal base 10 value.

Cheers!

Keith Cayemberg

Keith Cayemberg
Consultant
Wipro Technologies
Ramondo
Advisor

Re: Returning Status From Datatrieve (DTR)

Cheers Keith.

I notice there's nothing in the online help about FN$STATUS, but there are lots of other functions listed.

Also, if you do nothing in a DTR session (as in no reads or writes), the status returned is zero. A value of 1 would be better, I think.

Anyhow, just what I needed.

Thanks again,

Ramondo.