Rexx-read-operation

提供:Dev Guides
移動先:案内検索

Rexx-読み取り操作

任意のデータベースでの読み取り操作は、データベースからいくつかの有用な情報を取得することを意味します。 データベース接続が確立されると、このデータベースにクエリを実行する準備が整います。

次の例は、従業員テーブルからすべてのレコードを取得する方法を示しています。

/*Main program*/
Call RxFuncAdd 'SQLLoadFuncs', 'rexxsql', 'SQLLoadFuncs'
Call SQLLoadFuncs

if SQLConnect(c1,'testuser','test123','testdb') == 0 then say 'Connect Succedded'
if SQLCommand(u1,"use testdb") == 0 then say 'Changed database to testdb'
sqlstr = "select first_name,last_name,age,sex,income from employee" say
   SQLCommand(c2,sqlstr)

say c2.first_name.1
say c2.last_name.1
say c2.age.1
say c2.sex.1
say c2.income.1

上記のプログラムの出力は次のようになります。

Connect Succedded
Changed database to testdb
0
Mac
MOhan
20
M
2000