Discussion:
SQL Code 0842, SQL State 8002
(too old to reply)
Michael Ryan
2014-10-21 17:59:43 UTC
Permalink
Raw Message
Ok...I seem to be getting this more frequently. I'm issuing a remote
connect, and occasionally receive a 0842 error code. I can't seem to get a
lot of info by googling, but it appears that the connection already exists.
I am making a lot of calls. Should I use SET CONNECTION when this happens?
Anyone encounter this? Thanks.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L-Zwy7GipZuJhWk0Htik3J/***@public.gmane.org
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request-Zwy7GipZuJhWk0Htik3J/***@public.gmane.org
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
CRPence
2014-10-21 18:25:40 UTC
Permalink
Raw Message
Post by Michael Ryan
Ok...I seem to be getting this more frequently. I'm issuing a remote
connect, and occasionally receive a 0842 error code. I can't seem to
get a lot of info by googling, but it appears that the connection
already exists. I am making a lot of calls. Should I use SET
CONNECTION when this happens? Anyone encounter this? Thanks.
The results of a request to Display Message Description (DSPMSGD) of
the corresponding SQLCODE is often helpful to review; though IIRC the
identical information should be in the InfoCenter\KnowledgeCenter under
SQL codes and messages:
DSPMSGD SQL0842 QSQLMSG

As I recall for my few programs using DRDA coded to utilize or allow
for more than one hard-coded connection, I would just issue a SET
CONNECTION for the specified RDB when that was the condition for a
CONNECT statement.
--
Regards, Chuck
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L-Zwy7GipZuJhWk0Htik3J/***@public.gmane.org
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request-Zwy7GipZuJhWk0Htik3J/***@public.gmane.org
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
Michael Ryan
2014-10-21 19:15:28 UTC
Permalink
Raw Message
Is it an error message (as in not connecting) or a warning message (as in
you're already there)? Thanks!
Post by Michael Ryan
Ok...I seem to be getting this more frequently. I'm issuing a remote
connect, and occasionally receive a 0842 error code. I can't seem to
get a lot of info by googling, but it appears that the connection
already exists. I am making a lot of calls. Should I use SET
CONNECTION when this happens? Anyone encounter this? Thanks.
The results of a request to Display Message Description (DSPMSGD) of the
corresponding SQLCODE is often helpful to review; though IIRC the identical
information should be in the InfoCenter\KnowledgeCenter under SQL codes and
DSPMSGD SQL0842 QSQLMSG
As I recall for my few programs using DRDA coded to utilize or allow for
more than one hard-coded connection, I would just issue a SET CONNECTION
for the specified RDB when that was the condition for a CONNECT statement.
--
Regards, Chuck
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L-Zwy7GipZuJhWk0Htik3J/***@public.gmane.org
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request-Zwy7GipZuJhWk0Htik3J/***@public.gmane.org
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
CRPence
2014-10-22 13:38:44 UTC
Permalink
Raw Message
Post by Michael Ryan
Is it an error message (as in not connecting) or a warning message
(as in you're already there)?
Before attempting to answer that, I want to clarify the terminology I
will use. There is an important distinction between having a CONNECTION
that is merely established [there can be many], and a CONNECTION that is
[what might be called] _active_. The _active_ connection implies the
remote DB to which [most recently] an implicit or explicit SET
CONNECTION has transpired successfully. While there can be many remote
connections established, there is only one remote DB [connection] on
which work can be performed at the moment, and that connection is where
"you are"; again, the _active_ connection.

As the SQLCODE is -842 [the msg SQL0842], that is most definitely an
error rather than just a warning. However the error is IMO less about
"not connecting" than about the implicit SET CONNECTION not having been
established as part of the failed CONNECT TO request. So although the
requested connection "already exists", that implies nothing about the
currently _active_ connection. In that sense, the message might be
perceived more as a warning than an error; a warning that the user\pgmr
must recognize that the active connection remains unchanged, that the
[implicitly or explicitly] requested connection is already
_established_, but that the connection that "already exists" may or may
not be the _active_ connection. Thus if the condition of "connection
... already exists" is desirable, and if the currently active connection
is irrelevant [improbable, except if the next statement is a SET
CONNECTION], then the error condition can be ignored; treated
effectively as being purely informational.

For an example:

• Given: The active connection is currently SET to RDB2
• An [implicit or explicit] request made to: CONNECT TO RDB1
• If the prior request fails with the -842, then an implicit SET
CONNECTION RDB1 [that would have transpired as part of a successful
CONNECT TO RDB1] essentially also has failed; i.e. the connection
remains SET to RDB2.

In that example then, the error implying that a connection to RDB1
_already exists_ is *not* meant to imply also, that the _active_
connection is _already RDB1_. Because as shown, the connection remains
active to RDB2.

FWiW, in the Start SQL Interactive Session (STRSQL), a request to
perform a CONNECT [without any clauses\parameters] will log a msg
SQL7971 that will reveal connection details. I expect the SQLDA or GET
DIAGNOSTICS could be used to obtain the same information in a program.
--
Regards, Chuck
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L-Zwy7GipZuJhWk0Htik3J/***@public.gmane.org
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request-Zwy7GipZuJhWk0Htik3J/***@public.gmane.org
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
Michael Ryan
2014-10-22 13:44:13 UTC
Permalink
Raw Message
Thank you for the great explanation. I believe that I need to try my
CONNECT TO <remoteRDB>, and if I receive a -0842 SQL code as a result, use
the SET CONNECTION <remoteRDB> statement. Is that correct?
Post by CRPence
Post by Michael Ryan
Is it an error message (as in not connecting) or a warning message
(as in you're already there)?
Before attempting to answer that, I want to clarify the terminology I
will use. There is an important distinction between having a CONNECTION
that is merely established [there can be many], and a CONNECTION that is
[what might be called] _active_. The _active_ connection implies the
remote DB to which [most recently] an implicit or explicit SET CONNECTION
has transpired successfully. While there can be many remote connections
established, there is only one remote DB [connection] on which work can be
performed at the moment, and that connection is where "you are"; again, the
_active_ connection.
As the SQLCODE is -842 [the msg SQL0842], that is most definitely an
error rather than just a warning. However the error is IMO less about "not
connecting" than about the implicit SET CONNECTION not having been
established as part of the failed CONNECT TO request. So although the
requested connection "already exists", that implies nothing about the
currently _active_ connection. In that sense, the message might be
perceived more as a warning than an error; a warning that the user\pgmr
must recognize that the active connection remains unchanged, that the
[implicitly or explicitly] requested connection is already _established_,
but that the connection that "already exists" may or may not be the
_active_ connection. Thus if the condition of "connection ... already
exists" is desirable, and if the currently active connection is irrelevant
[improbable, except if the next statement is a SET CONNECTION], then the
error condition can be ignored; treated effectively as being purely
informational.
• Given: The active connection is currently SET to RDB2
• An [implicit or explicit] request made to: CONNECT TO RDB1
• If the prior request fails with the -842, then an implicit SET
CONNECTION RDB1 [that would have transpired as part of a successful CONNECT
TO RDB1] essentially also has failed; i.e. the connection remains SET to
RDB2.
In that example then, the error implying that a connection to RDB1
_already exists_ is *not* meant to imply also, that the _active_ connection
is _already RDB1_. Because as shown, the connection remains active to RDB2.
FWiW, in the Start SQL Interactive Session (STRSQL), a request to
perform a CONNECT [without any clauses\parameters] will log a msg SQL7971
that will reveal connection details. I expect the SQLDA or GET DIAGNOSTICS
could be used to obtain the same information in a program.
--
Regards, Chuck
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-***@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-***@midrange.com
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange
CRPence
2014-10-22 14:33:34 UTC
Permalink
Raw Message
<<SNIP>> I believe that I need to try my CONNECT TO <remoteRDB>, and
if I receive a -0842 SQL code as a result, use the SET CONNECTION
<remoteRDB> statement. Is that correct?
That is probably the most likely scenario, as a reflection of the
most likely coding and [probably static] RDB configuration. IIRC, that
is always what my code did. However I can imagine code that might not
do that, for example if the code is just acquiring several connections,
perhaps even some that may already exist, but connections for which the
actual SET CONNECTION is postponed until needed; in that scenario the
-842 can be viewed as merely an FYI, so effectively just ignored.
--
Regards, Chuck
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L-Zwy7GipZuJhWk0Htik3J/***@public.gmane.org
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request-Zwy7GipZuJhWk0Htik3J/***@public.gmane.org
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
Loading...