User:Heiko: Difference between revisions

From Try-AS/400
Jump to navigation Jump to search
(About to remove extension)
 
(25 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= About =
== About ==
This is [[User:Heiko|Heiko]]s personal page, in which he maybe shares some private information or collects bits for new articles.
This is [[User:Heiko|Heiko]]s personal page, in which he maybe shares some private information or collects bits for new articles.


== Personal information ==
=== Personal Information ===
[[User:Heiko|Heiko]] has been in IT since the 90s, but never worked with an AS/400…until 2019. He'll document his first steps in the hope they will be useful to others.
[[User:Heiko|Heiko]] has been in IT since the 90s, but never worked with an AS/400…until 2019. He'll document his first steps in the hope they will be useful to others.


= Ideas for new articles =
== Ideas for new articles ==
 
 
= Project: Access database with ODBC =
== Create a database ==
I suggest you try [[Beginners Project: 99 Bottles Of Beer (using REXX)]] and [[Beginners Project: Hello World (using database, display file and RPG)]] before you try this!<ref>[[User:Heiko|Heiko]] made this pretty brief, f.e. not every <code>F3</code> or <code>&#x23CE;</code> is noted.</ref><br/>
 
=== Create a database to play with ===
* This is the third project [[User:Heiko|Heiko]] did, so his personal Library was getting a bit cluttered. Therefore, let's create a library just for this niew project:
** <code>CRTLIB LIB(ODBC) TEXT(Library for ODBC project source)</code>
* <code>CRTSRCPF FILE(ODBC/ODBCDB) RCDLEN(112) TEXT('Project ODBC and Database')</code> to create new physical file to hold the DDS.
* <code>WRKMBRPDM FILE(ODBC/ODBCDB)</code> Work with this file.
* <code>F6</code> to create new member, insert member's name and type <code>PF</code>:<br/>[[Image:ODBCDB01.png|666px]]
* Enter this DDS: ([https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_72/rzakc/rzakcdatel.htm Learn what the below means] [https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_74/rzasb/cpdtex.htm Especially time- and dateformats] [https://www.db2tutorial.com/db2-basics/db2-time/ Even more about wibbly-wobbly-timey-wimey-stuff] [https://www.ibm.com/support/knowledgecenter/en/SSEPEK_11.0.0/intro/src/tpc/db2z_datetimetimestamp.html and more])
        ***************** Datenanfang *******************************************************************************************
0001.00      A          R CALLS                                                                                  191002         
0002.00      A            CALLER        42A                                                                      191002         
0003.00      A            CALLED        42A                                                                      191002         
0004.00      A            DATE            L                TIMFMT(*ISO)                                          191002         
0005.00      A            TIME            T                                                                      191002         
0006.00      A            TIMESTAMP      Z                                                                      191002         
        ******************Datenende *********************************************************************************************
* <code>14</code> to compile&#x2026;<br/>[[Image:ODBCDB02.png|666px]]<br/>&#x2026;I failed again. Stupid me. I can't create a new physical database file in the same place, where source physical file (with the same name!) exists.
** Just rename the DDS member from <code>ODBCDB</code> to <code>ODBCDBPF</code>:<br/>[[Image:ODBCDB03.png|666px]]<br/>[[Image:ODBCDB04.png|666px]]
** And try again.
** Check with <code>DSPMSG</code><ref>or use [[Compile Sources Without Queuing]]</ref> whether the compile was successful or not. If it did, you find the new PF in the library:<br/>[[Image:ODBCDB10.png|666px]]
 
=== Insert content into the database ===
* <code>STRSQL</code> + <code>F4</code>
** Enter the library name, in this example <code>ODBC</code><ref>Shortcut: <code>STRSQL LIBOPT(ODBC)</code></ref>
* In the interactive SQL session, enter:<br/><code>INSERT INTO CALLS (CALLER, CALLED, DATE, TIME, TIMESTAMP) VALUES ('Ernie', 'Bert', '2019-10-05', '23.23', '2019-10-05 23:23:42')</code><ref>Timestamp format: https://www.ibm.com/support/knowledgecenter/SSFMBX/com.ibm.swg.im.dashdb.sql.ref.doc/doc/r0007107.html</ref><ref>You can use either <code>.</code> or <code>:</code> as delimiter in time fields. The proper way, according to the documentation I found, is: <code>.</code></ref>
* There are many ways to display the result:
** If you're still in STRSQL, enter: <code>SELECT * FROM CALLS</code>
** On command line, try this: <code>DSPF FILE(ODBC/ODBCDBPF)</code>
** Or use <code>STRDFU</code>, select option 5 and fill out the displayed form.
[[Image:ODBC_DSPF01.png|666px|Displayed using <code>DSPF</code>]]
 
== ODBC Queries ==
Make sure you've set up <tt>/etc/odbc.ini</tt> correctly.
=== Perl ===
Here is a nice [https://www.ibm.com/developerworks/data/library/techarticle/dm-0512greenstein/index.html HowTo] from IBM. Worth reading.
==== Script Source Code ====
#!/usr/bin/perl
use strict;
use DBI;
my $db_cfg="YOURCONFIG"; # See your /etc/odbc.ini
my $db_pwd="YOURUSER";
my $db_user="YOURPASSWORD";
printf("Connecting to source database on $db_cfg...\n");
my $dbh = DBI->connect('DBI:ODBC:' . $db_cfg, $db_user, $db_pwd, {PrintError => 1, AutoCommit => 1}); # Connecting to Db2 database
if ( $dbh )
{
my $sth = $dbh->prepare ("SELECT * FROM ODBC/ODBCDBPF");
if (!$sth->execute)
{
printf("Error: Preparing select on source failed.\n");
die;
}
my $fCaller;
my $fCalled;
my $fDate;
my $fTime;
my $fTS;
while ( ($fCaller, $fCalled, $fDate, $fTime, $fTS) = $sth->fetchrow ) # Read one row from source table
{
printf("%s, %s, %s, %s, %s\n", $fCaller, $fCalled, $fDate, $fTime, $fTS);
}
# Clean up last statements
$sth->finish;
# Disconnect from database
if ( $dbh )
{
print("Disconnecting from $db_cfg...\n");
$dbh->disconnect;
}
}
else
{
printf("Error: Connection to database (%s) failed:\n%s\n%s\n%s\n", $db_cfg, $DBI::err, $DBI::errstr, $DBI::state);
die;
}
 
==== Output ====
$ ./as400-odbc.pl
Connecting to source database on YOURCONFIG...
Ernie                                      Bert                                      2019-10-05 23:24:00 2019-10-05 23:23:42.000000
Bob                                        Heppo                                      2019-11-06 05:05:05 2019-10-05 23:23:42.000000
Disconnecting from YOURCONFIG...
 
=== PHP ===
I found several possible approaches:
* Use <code>odbc_</code> command set
** [https://www.ibm.com/developerworks/library/os-php-odbc/index.html HowTo use PHP and ODBC]<ref>Sadly this is for mySQL. Db2 would be much more appreciated.</ref>
* Use <tt>PDO</tt>
** [https://www.php.net/manual/en/ref.pdo-ibm.php Short Overview]
* Use Db2 driver
** [https://www.ibm.com/support/knowledgecenter/en/SS6NHC/com.ibm.swg.im.dashdb.doc/connecting/connect_driver_package.html Db2 client] & [https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/ direct link]
** [https://github.com/php/pecl-database-ibm_db2 Installation instructions]
** [https://www.php.net/manual/en/function.db2-connect.php Usage] and after client installation: <code>TBD -h</code> might help!
 
==== Source Code using ODBC ====
TBD
 
==== Source Code using PDO ====
TBD
 
==== Source Code using DB2 client ====
TBD
 
=== C ===
tbd
tbd


= Articles to maintain =
== Articles to maintain ==
* [[Basic Software Development]]
* [[:Category:Programming]]
** [[Beginners Project: 99 Bottles Of Beer (using REXX)]]
** [[99 Bottles Of Beer (using REXX)]]
** [[Beginners Project: Hello World (using C)]]
** [[Hello World (using C)]]
** [[Beginners Project: Hello World (using database, display file and RPG)]]
** [[Hello World (using database, display file and RPG)]]
** [[Create a database and query it using ODBC from a linux machine]] <-- NEEDS A LOT OF WORK IN THE PHP DEPARTMENT!
* [[Editing Source Files using Eclipse and FTP]]
* [[Editing Source Files using Eclipse and FTP]]
* [[Compile Sources Without Queuing]]
* [[Compile Sources Without Queuing]]
* [[How to solve Variadic Arguments issue (using C)]]


== Too many F-Keys to memorize ==
I'm using a small apple keyboard on which the F-keys aren't labeled very well. This helps a lot:


[[Image:F-Tasten F13-F24 v2 Photo.jpg|666px]]
You can download it here: [[File:F-Tasten F13-F24 v2.pdf]]


== Sandbox ==
== Sandbox ==
Line 190: Line 83:
</p>
</p>


=== Using (not-working) console-tag ===
== See also ==
<console>
* [[Basic Commands]]
Test
</console>


<console>
== Footnotes ==
 
                                  Anmelden           
                                              System  . . . . . :  SLVRLAKE
                                              Subsystem . . . . :  QINTER
                                              Bildschirm  . . . :  QPADEV0004
                Benutzer  . . . . . . . . . . . .           
                Kennwort  . . . . . . . . . . . .
                Programm/Prozedur . . . . . . . .           
                Men}  . . . . . . . . . . . . . .           
                Aktuelle Bibliothek . . . . . . .           
                                        (C) COPYRIGHT IBM CORP. 1980, 2013.
</console>
 
----
* Links
** [[Basic Commands]]
* References:
<references/>
<references/>
[[Category:Basic Knowledge]]

Latest revision as of 16:41, 14 April 2024

About

This is Heikos personal page, in which he maybe shares some private information or collects bits for new articles.

Personal Information

Heiko has been in IT since the 90s, but never worked with an AS/400…until 2019. He'll document his first steps in the hope they will be useful to others.

Ideas for new articles

tbd

Articles to maintain

Too many F-Keys to memorize

I'm using a small apple keyboard on which the F-keys aren't labeled very well. This helps a lot:

F-Tasten F13-F24 v2 Photo.jpg

You can download it here: File:F-Tasten F13-F24 v2.pdf

Sandbox

Screen mit MW-Bordmitteln

                                  Anmelden            
                                              System  . . . . . :   SLVRLAKE
                                              Subsystem . . . . :   QINTER
                                              Bildschirm  . . . :   QPADEV0004

               Benutzer  . . . . . . . . . . . .             
               Kennwort  . . . . . . . . . . . .
               Programm/Prozedur . . . . . . . .             
               Men}  . . . . . . . . . . . . . .             
               Aktuelle Bibliothek . . . . . . .             













                                       (C) COPYRIGHT IBM CORP. 1980, 2013.

Und nun Screen mit Bordmitteln und etwas HTML-Foo

Anmelden
System . . . . . : SLVRLAKE
Subsystem . . . . : QINTER
Bildschirm . . . : QPADEV0004

Benutzer . . . . . . . . . . . .
Kennwort . . . . . . . . . . . .
Programm/Prozedur . . . . . . . .
Men} . . . . . . . . . . . . . .
Aktuelle Bibliothek . . . . . . .













(C) COPYRIGHT IBM CORP. 1980, 2013.

See also

Footnotes