Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GENERATE_SQL generating lines too long #59

Open
worksofliam opened this issue Jul 18, 2023 · 7 comments
Open

GENERATE_SQL generating lines too long #59

worksofliam opened this issue Jul 18, 2023 · 7 comments
Milestone

Comments

@worksofliam
Copy link
Contributor

CALL QSYS2.GENERATE_SQL('ACTIVESACTIVESACTIVESACTIVESACTIVESACTIVESACTIVESACTIVESACTIVESACTIVESACTIVESACTIVESACTIVESACTIVESACTIVES', 'SAMPLE', 'ALIAS', CREATE_OR_REPLACE_OPTION => '1', PRIVILEGES_OPTION => '0')
image

Possible fix is using the parameter to write to the IFS, then read in the IFS contents with a vscode-ibmi API.

https://www.ibm.com/docs/en/i/7.3?topic=services-generate-sql-procedure

@worksofliam worksofliam added this to the 0.5.0 milestone Jul 21, 2023
@ThePrez
Copy link
Collaborator

ThePrez commented Jul 21, 2023

Root cause is that the result set returns a column which is a CHAR(80). I suspect we will also run into problems using a temporary QSYS file.

I have verified that the results are correct when writing to a stream file. This appears to work

CALL QSYS2.GENERATE_SQL('ACTIVESACTIVESACTIVESACTIVESACTIVESACTIVESACTIVESACTIVESACTIVESACTIVESACTIVESACTIVESACTIVESACTIVESACTIVES', 'SAMPLE', 'ALIAS', CREATE_OR_REPLACE_OPTION => '1', PRIVILEGES_OPTION => '0',DATABASE_SOURCE_FILE_NAME =>'*STMF', SOURCE_STREAM_FILE =>'/home/LINUX/.vscode/my_ddl.sql');

SELECT LINE FROM TABLE(QSYS2.IFS_READ(PATH_NAME => '/home/LINUX/.vscode/my_ddl.sql',
                                   END_OF_LINE => 'LF')) ORDER BY LINE_NUMBER ASC;

@lgiammattei
Copy link

Hellò everybody, I am the author of issue #89 , if i may offer any suggestion it would be to create stream file under the /home/USER folder (maybe creating anothere folder named DDL or Generated DDL and the stream file should be named after the database object). Then let the user do what they want with the generated ddl files. i.e. I usually run generate ddl to build docs for my pgms documenting the database side of the procedure. I'll go closing #89 if you are ok with it.

@worksofliam worksofliam modified the milestones: 0.5.0, 0.6.0 Sep 22, 2023
@worksofliam
Copy link
Contributor Author

@ThePrez Looks like this is throwing a null pointer exception:

    await JobManager.runSQL(
      `CALL QSYS2.GENERATE_SQL(?, ?, ?, CREATE_OR_REPLACE_OPTION => '1', PRIVILEGES_OPTION => '0', DATABASE_SOURCE_FILE_NAME => '*STMF', SOURCE_STREAM_FILE => ?);`,
      { parameters : [object, schema, internalType, tempFile] }
    );

    const content = await getInstance().getContent().downloadStreamfile(tempFile);

@ThePrez
Copy link
Collaborator

ThePrez commented Dec 5, 2023

@ThePrez Looks like this is throwing a null pointer exception:

    await JobManager.runSQL(
      `CALL QSYS2.GENERATE_SQL(?, ?, ?, CREATE_OR_REPLACE_OPTION => '1', PRIVILEGES_OPTION => '0', DATABASE_SOURCE_FILE_NAME => '*STMF', SOURCE_STREAM_FILE => ?);`,
      { parameters : [object, schema, internalType, tempFile] }
    );

    const content = await getInstance().getContent().downloadStreamfile(tempFile);

Get me a server trace. It's on by default

@worksofliam
Copy link
Contributor Author

This is currently using Server Component 1.2.0...going to try 1.4.5 next.

image
java.lang.NullPointerException
	at com.github.theprez.codefori.requests.PreparedExecute.go(PreparedExecute.java:63)
	at com.github.theprez.codefori.requests.PrepareSql.go(PrepareSql.java:70)
	at com.github.theprez.codefori.ClientRequest.run(ClientRequest.java:80)
	at java.lang.Thread.run(Thread.java:825)

@worksofliam
Copy link
Contributor Author

Using 1.4.5

{"id":"query7","type":"prepare_sql_execute","sql":"CALL QSYS2.GENERATE_SQL(?, ?, ?, CREATE_OR_REPLACE_OPTION => '1', PRIVILEGES_OPTION => '0', DATABASE_SOURCE_FILE_NAME => '*STMF', SOURCE_STREAM_FILE => '/tmp/vscodetemp-O_4NJsijOe')","rows":2147483647,"parameters":["MANZANMSG","LIAMA","TABLE"]}

[ERR]: 2023-12-04.22.30.51.905
java.lang.NullPointerException
	at com.github.theprez.codefori.requests.PreparedExecute.go(PreparedExecute.java:63)
	at com.github.theprez.codefori.requests.PrepareSql.go(PrepareSql.java:70)
	at com.github.theprez.codefori.ClientRequest.run(ClientRequest.java:81)
	at java.lang.Thread.run(Thread.java:825)

@worksofliam
Copy link
Contributor Author

worksofliam commented Dec 5, 2023

This still works in 1.4.5:

{"id":"query4","type":"prepare_sql_execute","sql":"CALL QSYS2.GENERATE_SQL(?, ?, ?, CREATE_OR_REPLACE_OPTION => '1', PRIVILEGES_OPTION => '0')","rows":2147483647,"parameters":["MANZANPAL","LIAMA","TABLE"]}

I should note.. this is oss73dev.

Edit: tested on oss74dev with the same results.

@worksofliam worksofliam modified the milestones: 0.6.0, 0.7.0 Dec 5, 2023
@worksofliam worksofliam modified the milestones: 0.9.0, 1.0.0 Mar 7, 2024
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

No branches or pull requests

3 participants