{"id":65,"date":"2023-02-14T11:22:29","date_gmt":"2023-02-14T10:22:29","guid":{"rendered":"http:\/\/www.sepchat.com\/SC\/?p=65"},"modified":"2023-02-23T15:16:00","modified_gmt":"2023-02-23T14:16:00","slug":"ibmi-sql-lire-une-dtaara","status":"publish","type":"post","link":"http:\/\/www.sepchat.com\/SC\/index.php\/2023\/02\/14\/ibmi-sql-lire-une-dtaara\/","title":{"rendered":"IBMi\u00a0&#8211; SQL Lire une DTAARA"},"content":{"rendered":"\n<p>Depuis la V 7R2, il est possible de lire des donn\u00e9es syst\u00e8me directement depuis une instruction SQL. <\/p>\n\n\n\n<p style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0\">Il est aussi possible de lire le contenu d&rsquo;une DTAARA gr\u00e2ce \u00e0 une fonction SQL. Voici comment &#8230;.&nbsp; ** Update V7R4<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Dans un premier temps, il faut cr\u00e9er un PGM pour lire la dtaara :<\/p>\n\n\n\n<p style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0\">PGM&nbsp;&nbsp; PARM(&amp;VERSION)<\/p>\n\n\n\n<p style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0\">DCL&nbsp; &amp;VERSION *CHAR LEN(8)<\/p>\n\n\n\n<p style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0\">RTVDTAARA DTAARA(ARVERSION) RTNVAR(&amp;VERSION)<\/p>\n\n\n\n<p style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0\">ENDPGM<\/p>\n\n\n\n<p>Compiler le module :<\/p>\n\n\n\n<p style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0\">CRTCLMOD MODULE(MYLIB\/GETDTA) SRCFILE(MYLIB\/QCLLESRC)<\/p>\n\n\n\n<p>Compiler le programme de service&nbsp;<\/p>\n\n\n\n<p style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0\">CRTSRVPGM SRVPGM(MYLIB\/GETDTA) MODULE(MYLIB\/GETDTA) EXPORT(*ALL)<\/p>\n\n\n\n<p style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0\">Puis, d\u00e9finir la fonction SQL dans le membre source GETVERSION dans MYLIB\/QSQLSRC<\/p>\n\n\n\n<p>Create Function<br>GetVersion ()<\/p>\n\n\n\n<p>Returns CHAR(8)<br>Language CL<br>Specific GetVersion<br>Deterministic<br>No SQL<br>Returns Null on Null Input<br>No External Action<br>Not Fenced<br>External Name &lsquo;MYLIB\/ GETDTA(GETDTA)&rsquo;<br>Parameter Style SQL;<\/p>\n\n\n\n<p>Lancer la compilation de la fonction :<\/p>\n\n\n\n<p style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0\">RUNSQLSTM SRCFILE(MYLIB\/QSQLSRC) SRCMBR(GETVERSION)<\/p>\n\n\n\n<p style=\"margin-top:var(--wp--preset--spacing--30);margin-right:var(--wp--preset--spacing--30);margin-bottom:var(--wp--preset--spacing--30);margin-left:var(--wp--preset--spacing--30)\">\u00c0 partir de n&rsquo;importe qu&rsquo;elle session SQL connect\u00e9e \u00e0 votre IBMi lancer la requ\u00eate:<\/p>\n\n\n\n<p style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0\">SELECT&nbsp;&nbsp;GetVersion() FROM SYSIBM\/SYSDUMMY1<\/p>\n\n\n\n<p>&nbsp;Depuis la V7R4, il est possible de lire le contenu d&rsquo;une DATAARA sans avoir \u00e0 cr\u00e9er une fonction.<\/p>\n\n\n\n<p>Il suffit de passer la requ\u00e8te SQL suivante :<\/p>\n\n\n\n<p style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0\">SELECT DATA_AREA_VALUE FROM TABLE(QSYS.2.DATA_AREA8INFO(<\/p>\n\n\n\n<p style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0\">DATA_AREA8NAME =&gt; &lsquo;ARCVERSION&rsquo;,<\/p>\n\n\n\n<p style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0\">DATA_AREA_LIBRARY =&gt; &lsquo;MYLIB&rsquo;))<\/p>\n\n\n\n<p>&nbsp;(Merci Yvain pour l&rsquo;upgrade)<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized size-full has-custom-border\"><a href=\"as-400-iseries-system-i-ibm-i\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.sepchat.com\/SC\/wp-content\/uploads\/2023\/02\/fleche-r-edited.png\" alt=\"\" width=\"57\" height=\"57\"\/><\/a><\/figure>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex\">\n<div class=\"wp-block-button is-style-outline\"><a class=\"wp-block-button__link wp-element-button\" style=\"border-radius:100px\">Cet article vous a \u00e9t\u00e9 utile ? N\u2019h\u00e9sitez pas \u00e0 le partager.<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Depuis la V 7R2, il est possible de lire des donn\u00e9es syst\u00e8me directement depuis une instruction SQL. Il est aussi possible de lire le contenu d&rsquo;une DTAARA gr\u00e2ce \u00e0 une fonction SQL. Voici comment &#8230;.&nbsp; ** Update V7R4 Dans un premier temps, il faut cr\u00e9er un PGM pour lire la dtaara : PGM&nbsp;&nbsp; PARM(&amp;VERSION) DCL&nbsp; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,8],"tags":[],"_links":{"self":[{"href":"http:\/\/www.sepchat.com\/SC\/index.php\/wp-json\/wp\/v2\/posts\/65"}],"collection":[{"href":"http:\/\/www.sepchat.com\/SC\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.sepchat.com\/SC\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.sepchat.com\/SC\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.sepchat.com\/SC\/index.php\/wp-json\/wp\/v2\/comments?post=65"}],"version-history":[{"count":10,"href":"http:\/\/www.sepchat.com\/SC\/index.php\/wp-json\/wp\/v2\/posts\/65\/revisions"}],"predecessor-version":[{"id":369,"href":"http:\/\/www.sepchat.com\/SC\/index.php\/wp-json\/wp\/v2\/posts\/65\/revisions\/369"}],"wp:attachment":[{"href":"http:\/\/www.sepchat.com\/SC\/index.php\/wp-json\/wp\/v2\/media?parent=65"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.sepchat.com\/SC\/index.php\/wp-json\/wp\/v2\/categories?post=65"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.sepchat.com\/SC\/index.php\/wp-json\/wp\/v2\/tags?post=65"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}