Skip to content

Update SQL query in downloadMemberContentWithDates to handle specific…#2736

Merged
chrjorgensen merged 3 commits into
codefori:masterfrom
e1mais:master
Jun 26, 2025
Merged

Update SQL query in downloadMemberContentWithDates to handle specific…#2736
chrjorgensen merged 3 commits into
codefori:masterfrom
e1mais:master

Conversation

@e1mais

@e1mais e1mais commented Jun 16, 2025

Copy link
Copy Markdown
Contributor

Changes

Hello everyone,

This Pull Request addresses an issue that occurs when trying to open source members generated by the RTVBNDSRC (Retrieve Binder Source) command using the Code for IBM i extension.

The purpose of RTVBNDSRC is to retrieve the export symbols EXPORT SYMBOL("PROCNAME") from an object of type MODULE or SRVPGM, and write them into a source member. This source is then used as input for the CRTSRVPGM command, allowing the signature of the SRVPGM to be preserved when it is regenerated.

Problem

The source member generated by RTVBNDSRC does not contain a valid date in the SRCDAT field. As a result, when the extension tries to open the member using the ALIAS object, it fails, as shown in the image below:

imagen

The extension accesses the content of source members using this ALIAS object. However, if the SRCDAT field contains blank spaces (which is invalid for a NUMERIC(6,0) field), an SQL error occurs when attempting to read the data:

  • SQL0802 – Data conversion or data mapping error

  • SQLSTATE 01004 – Truncation warning

  • Error type: 6

Solution

To avoid these conversion or mapping errors when opening members with invalid SRCDAT values, I have modified the query used by the extension. It now returns 0 as the value for SRCDAT when blank spaces are detected, and the original value when it's valid, thus preventing the aforementioned failures.

I appreciate any feedback or suggestions you may have regarding this solution.

Steps to reproduce the issue:

  1. Create or use an existing module.

  2. Create a BND-type member in your own source file:

    ADDPFM FILE(*CURLIB/QSRCBND) MBR(BNDSRC1) TEXT('Example BND source member') SRCTYPE(BND)
  3. Use the RTVBNDSRC command to retrieve the export symbols into the created member:

    RTVBNDSRC MODULE(*CURLIB/MODULE1) SRCFILE(*CURLIB/QSRCBND) SRCMBR(BNDSRC1)
  4. Open the member using Code for IBM i and observe the error.

How to test this PR

Checklist

  • have tested my change
  • have created one or more test cases
  • updated relevant documentation
  • Remove any/all console.logs I added
  • have added myself to the contributors' list in CONTRIBUTING.md

@worksofliam

Copy link
Copy Markdown
Member

@chrjorgensen I'd love your thoughts here. You helped with something akin to this when we previously supported SEU colors.

@worksofliam
worksofliam requested a review from chrjorgensen June 24, 2025 23:48

@chrjorgensen chrjorgensen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@e1mais Thank you for your PR - good catch of what seems to be an error with the RTVBNDSRC command, not writing correct numeric dates in the source retrieved. 👍

Your change works perfectly, and I have only one request: Please add yourself to the CONTRIBUTING.md file. 🙏

Once done, we can merge your change into the master branch.

@e1mais

e1mais commented Jun 25, 2025

Copy link
Copy Markdown
Contributor Author

@chrjorgensen Done, I have now added myself to the list of contributors, thank you very much for the review

@chrjorgensen
chrjorgensen self-requested a review June 26, 2025 07:07

@chrjorgensen chrjorgensen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@e1mais Thank you - your change have now been tested once more and works fine.
I'll approve and merge this PR.

Btw, the RTVBNDSRC command has more than one flaw: If you don't create the source file beforehand, RTVBNDSRC will create the file for you - with CCSID 65535 for SRCDTA, which can't be opened in C4i...!

Not a great job by IBM here.... 😞

@chrjorgensen
chrjorgensen merged commit a2f8f01 into codefori:master Jun 26, 2025
1 check passed
@bobcozzi

Copy link
Copy Markdown
Contributor

Note the READSRC table function (in my free SQL Tools package) does read source file members with CCSID(65535).
Also. Tried out your testcase to reproduce and yes it creates a source file with binary or "no CCSID" but READSRC just works. Also not, it handles bad src change dates as well:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants