ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

sql0804 - sqlda or descriptor area not valid

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • sql0804 - sqlda or descriptor area not valid

    can someone please clarify the below assignment of sqldabc...??
    sqldabc
    SQLDABC
    INTEGER Length of the SQLDA, equal to SQLNx * 44+16. Length of the SQLDA, greater than or equal to SQLNx* 44+16.
    what is 44? what is 16?

    i'm getting an error code 6 when I attempt to do

    execute s1_write using descriptor :descName;

    error code is...

    6 -- The value specified for SQLDABC is not valid. The value is either not
    large enough for the number of entries specified in SQLN or the value is
    greater than the maximum allowed.

    in debug at time of error my sqlda looks like...

    EVAL sqlda
    SQLDA.SQLDAID = ' '
    SQLDA.SQLDABC = 960
    SQLDA.SQLN = 16
    SQLDA.SQLD = 16

    calculate based on sqlda.sqldabc = sqlda.sqln * 59 + 16;

    59 because that is my record length... somewhere in documentation i read I thought that is what it was referring to... regardless, the 44 doesn't work and my tutorial shows 80 and and that didn't work either.
    Last edited by jayvaughn; October 12, 2017, 07:39 AM.

  • #2
    Originally posted by jayvaughn View Post
    can someone please clarify the below assignment of sqldabc...??
    sqldabc
    SQLDABC
    INTEGER Length of the SQLDA, equal to SQLNx * 44+16. Length of the SQLDA, greater than or equal to SQLNx* 44+16.
    what is 44? what is 16?.
    It can be clarified except for "44". It doesn't seem that "44" could be a correct value. I don't know where "44" comes from.

    A SQLDA consists of these fields: SQLDAID, SQLDABC, SQLN, SQLD and SQLVAR. The SQLVAR field is an array of a data structure and consists of these fields: SQLTYPE, SQLLEN, SQLRES, SQLDATA. SQLIND and SQLNAME.

    So, the length of SQLDA consists of the lengths of the first four fields plus (the length of SQLVAR multiplied by how many SQLVARs are used). The SQLN field tells SQL how many SQLVARs there are, so the formula actually is SQLN*LENGTH(SQLVAR) + 16 as a minimum value.

    Initial SQLDA field lengths: SQLDAID + SQLDABC + SQLN + SQLD = 16
    That is, the lengths of those is: 8 + 4 + 2 + 2 = 16

    That's where the "16" comes from. The "16" must be added to the rest.

    SQLVAR field lengths: SQLTYPE + SQLLEN + SQLRES + SQLDATA + SQLIND + SQLNAME = 80
    Those lengths are: 2 + 2 + 12 + 16 + 16 + (32) = 80

    The length of SQLNAME should allow for 30 characters even if names are shorter since column names may be 30 long. And because SQLNAME is variable-length field, there is a 2-byte length prefix.

    There should be an SQLVAR structure for each column, so it repeats that many times.

    The minimum would then be: SQLN*80 + 16
    Tom

    There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

    Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

    Comment

    Working...
    X