 | | Wide Studio Object Reference
| |
クラスの型
WSCdbRecord
メソッド関数仕様
WSCdbRecord 関数の説明
- 書式
- WSCdbRecord(WSCdbDatabase* pDatabase)
- 機能
- WSCdbRecordクラスのコンストラクタです。
- 処理
-
- 引数
-
(in)WSCdbDatabase* db | WSCdbDatabaseインスタンス |
- 返値
- WS_NO_ERR:成功、WS_ERR:失敗
- 注意
- なし。
- サンプル
-
WSCdbDatabase db;
db.setDatabase("PGSQL");
if(db.open("server", "user", "pass", "db", NULL) == WS_ERR) {
WSCdbRecode rs(&db);
long ret = rs.open("select * from shinamono order by code");
if (ret == WS_NO_ERR){
//接続。
}else{
//接続失敗、エラーメッセージを取得。
char buffer[1024];
rs.getErrorMsg(buffer,1024);
}
}
WSCdbRecord 関数の説明
- 書式
- WSCdbRecord(WSCvdb* inst)
- 機能
- WSCdbRecordクラスのコンストラクタです。
- 処理
-
- 引数
-
(in)WSCvdb* inst | WSCvdbクラスのインスタンス |
- 返値
- WS_NO_ERR:成功、WS_ERR:失敗
- 注意
- なし。
- サンプル
-
WSCdbRecode rs(newvdb__000);
long ret = rs.open("select * from shinamono order by code");
if (ret == WS_NO_ERR){
//接続。
}else{
//接続失敗、エラーメッセージを取得。
char buffer[1024];
rs.getErrorMsg(buffer,1024);
}
open 関数の説明
- 書式
- long open(char* stmt)
- 機能
- SQL文によりデータベースサーバへの問い合わせを行います。
- 処理
- ODBC、PostgreSQL、MySQLの各APIを通じて SQL文を実行し
FETCHカーソルをOPENします。
- 引数
-
- 返値
- WS_NO_ERR:成功、WS_ERR:失敗
- 注意
- なし。
- サンプル
-
WSCdbRecode rs(newvdb__000);
long ret = rs.open("select * from shinamono order by code");
if (ret == WS_NO_ERR){
//接続。
}else{
//接続失敗、エラーメッセージを取得。
char buffer[1024];
rs.getErrorMsg(buffer,1024);
}
open 関数の説明
- 書式
- long open(char* stmt, short eCousor, short eAccess)
- 機能
- SQL文によりデータベースサーバへの問い合わせを行います。
- 処理
- ODBC、PostgreSQL、MySQLの各APIを通じて SQL文を実行し
FETCHカーソルをOPENします。
- 引数
-
(in)char* stmt | 実行するSQL文を指定 |
(in)short eCursor | カーソルの種類を指定 |
(in)short eAccess | アクセスの種類を指定 |
カーソルの種類に指定できる値には、 次のようなものがあります。
WSCDB_SQL_CURSOR_FORWARD_ONLY | 前方スクロール カーソル |
WSCDB_SQL_CURSOR_KEYSET_DRIVEN | キーセット カーソル |
WSCDB_SQL_CURSOR_DYNAMIC | 動的カーソルです。 |
WSCDB_SQL_CURSOR_STATIC | 静的カーソル |
WSCDB_SQL_CURSOR_TYPE_DEFAULT | 前方スクロール カーソル |
アクセスの種類に指定できる値には、 次のようなものがあります。
WSCDB_SQL_CONCUR_READ_ONLY | カーソルは読み取り専用 |
WSCDB_SQL_CONCUR_LOCK | カーソルは、確実に行を更新できるように、十分な最低ロックを使用 |
WSCDB_SQL_CONCUR_ROWVER | カーソルは、行バージョンによる楽観的な競合制御 |
WSCDB_SQL_CONCUR_VALUES | カーソルは、行の値による楽観的な競合制御 |
WSCDB_SQL_CONCUR_DEFAULT | カーソルは読み取り専用です。更新は出来ません。 |
- 返値
- WS_NO_ERR:成功、WS_ERR:失敗
- 注意
- なし。
- サンプル
-
WSCdbRecode rs(newvdb__000);
long ret = rs.open("select * from shinamono order by code",
WSCDB_SQL_CURSOR_KEYSET_DRIVEN,
WSCDB_SQL_CONCUR_READ_ONLY);
if (ret == WS_NO_ERR){
//接続。
}else{
//接続失敗、エラーメッセージを取得。
char buffer[1024];
rs.getErrorMsg(buffer,1024);
}
close 関数の説明
- 書式
- long close()
- 機能
- データベースサーバへの問い合わせを切断します。
- 処理
- ODBC、PostgreSQL、MySQLの各APIを通じて SQL文を実行しFETCH
カーソルをCLOSEします。
- 引数
- なし。
- 返値
- WS_NO_ERR:成功、WS_ERR:失敗
- 注意
- なし。
- サンプル
-
long ret = rs.close();
if (ret == WS_NO_ERR){
//切断成功。
}else{
//切断失敗、エラーメッセージを取得。
char buffer[1024];
db.getErrorMsg(buffer,1024);
}
isEOF 関数の説明
- 書式
- WSCbool isEOF()
- 機能
- 問い合わせ結果の現在のレコード位置を取得します。
- 処理
- 問い合わせ結果のレコード位置が先頭レコード、
最終レコードの範囲かどうかの状態を取得します。
- 引数
- なし。
- 返値
- True:先頭レコード、最終レコードの範囲外状態、
False:先頭レコード、最終レコードの範囲内状態
- 注意
- なし。
- サンプル
-
WSCbool ret = rs.isEOF();
if (ret == False){
//先頭レコード、最終レコードの範囲内状態。
}else{
//先頭レコード、最終レコードの範囲外状態。
}
isOpen 関数の説明
- 書式
- WSCbool isOpen()
- 機能
- データベースサーバへの問い合わせ状態を取得します。
- 処理
-
- 引数
- なし。
- 返値
- True:問合せ状態、False:非問合せ状態
- 注意
- なし。
- サンプル
-
WSCbool ret = rs.isOpen();
if (ret == False){
//非問合せ状態。
}else{
//問合せ状態。
}
getColValue 関数の説明
- 書式
- long getColValue(long index, WSCvariant* var)
- 機能
- 項目のデータを取得します。
- 処理
- 指定した番号の項目のデータを取得します。
- 引数
-
(in)long index | 項目の番号を指定します。0 からの連番です。 |
(in)WSCvariant* var | 項目のデータを格納するWSCvariantクラスのポインタを指定します。 |
- 返値
- WS_NO_ERR:成功、WS_ERR:失敗
- 注意
- なし。
- サンプル
-
//テーブルの作成とデータの格納
char buf1[1024];
strcpy(buf1, "drop table shinamono");
long ret = newvdb__000->sqlExecute(buf1);
strcpy(buf1,"create table shinamono(code int, hinmei char(20), nedan float)");
newvdb__000->sqlExecute(buf1);
newvdb__000->beginTran();
strcpy(buf1,"insert into shinamono values(1, 'みかん', 100)");
newvdb__000->sqlExecute(buf1);
strcpy(buf1,"insert into shinamono values(2, 'りんご', 200)");
newvdb__000->sqlExecute(buf1);
strcpy(buf1,"insert into shinamono values(3, 'バナナ', 300)");
newvdb__000->sqlExecute(buf1);
strcpy(buf1,"insert into shinamono values(4, 'メロン', 0)");
newvdb__000->sqlExecute(buf1);
newvdb__000->commitTran();
//データの参照
WSCdbRecord rs(newvdb__000);
char var[256];
WSCstring result;
newvdb__000->beginTran();
if(rs.open("select * from shinamono order by code") == WS_NO_ERR) {
while (!rs.isEOF()) {
rs.getColValue("code", &var);
int code = (int)var;
result << "code:" << (int)var << " ";
rs.getColValue(0, &var);
result << "hinmei:" << (char*)var << " ";
rs.getColValue(1, &var);
char buf[80];
double nedan = (float)var + 10;
sprintf(buf, "%f", (float)var);
result << "nedan:" << buf << "\n";
rs.movenext();
}
printf("result:\n%s",(char*)result);
}
getColValue 関数の説明
- 書式
- long getColValue(const char* name, WSCvariant* var)
- 機能
- 項目のデータを取得します。
- 処理
- 指定した名前の項目のデータを取得します。
- 引数
-
(in)const char* name | 項目の名前を指定します。 |
(in)WSCvariant* var | 項目のデータを格納する WSCvariant型のポインタを指定します。 |
- 返値
- WS_NO_ERR:成功、WS_ERR:失敗
- 注意
- なし。
- サンプル
-
//テーブルの作成とデータの格納
char buf1[1024];
strcpy(buf1, "drop table shinamono");
long ret = newvdb__000->sqlExecute(buf1);
strcpy(buf1,"create table shinamono(code int, hinmei char(20), nedan float)");
newvdb__000->sqlExecute(buf1);
newvdb__000->beginTran();
strcpy(buf1,"insert into shinamono values(1, 'みかん', 100)");
newvdb__000->sqlExecute(buf1);
strcpy(buf1,"insert into shinamono values(2, 'りんご', 200)");
newvdb__000->sqlExecute(buf1);
strcpy(buf1,"insert into shinamono values(3, 'バナナ', 300)");
newvdb__000->sqlExecute(buf1);
strcpy(buf1,"insert into shinamono values(4, 'メロン', 0)");
newvdb__000->sqlExecute(buf1);
newvdb__000->commitTran();
//データの参照
WSCdbRecord rs(newvdb__000);
WSCvariant var;
WSCstring result;
newvdb__000->beginTran();
if(rs.open("select * from shinamono order by code") == WS_NO_ERR) {
while (!rs.isEOF()) {
rs.getColValue("code", &var);
int code = (int)var;
result << "code:" << (int)var << " ";
rs.getColValue("hinmei", &var);
result << "hinmei:" << (char*)var << " ";
rs.getColValue("nedan", &var);
char buf[80];
double nedan = (float)var + 10;
sprintf(buf, "%f", (float)var);
result << "nedan:" << buf << "\n";
rs.movenext();
}
printf("result:\n%s",(char*)result);
}
getColStringValue 関数の説明
- 書式
- long getColStringValue(long index, char* var)
- 機能
- 項目のデータを取得します。
- 処理
- 指定した番号の項目のデータを文字列で取得します。
- 引数
-
(in)long index | 項目の番号を指定します。0 からの連番です。 |
(out)char* var | 項目のデータを格納するchar型のポインタを指定します。 |
- 返値
- WS_NO_ERR:成功、WS_ERR:失敗
- 注意
- バッファのオーバーフローに気を付けて使用して下さい。
- サンプル
-
//テーブルの作成とデータの格納
char buf1[1024];
strcpy(buf1, "drop table shinamono");
long ret = newvdb__000->sqlExecute(buf1);
strcpy(buf1,"create table shinamono(code int, hinmei char(20), nedan float)");
newvdb__000->sqlExecute(buf1);
newvdb__000->beginTran();
strcpy(buf1,"insert into shinamono values(1, 'みかん', 100)");
newvdb__000->sqlExecute(buf1);
strcpy(buf1,"insert into shinamono values(2, 'りんご', 200)");
newvdb__000->sqlExecute(buf1);
strcpy(buf1,"insert into shinamono values(3, 'バナナ', 300)");
newvdb__000->sqlExecute(buf1);
strcpy(buf1,"insert into shinamono values(4, 'メロン', 0)");
newvdb__000->sqlExecute(buf1);
newvdb__000->commitTran();
//データの参照
WSCdbRecord rs(newvdb__000);
char var[256];
WSCvariant var1;
WSCstring result;
newvdb__000->beginTran();
if(rs.open("select * from shinamono order by code") == WS_NO_ERR) {
while (!rs.isEOF()) {
rs.getColValue("code", &var);
int code = (int)var;
result << "code:" << (int)var << " ";
rs.getColStringValue(0, &var);
result << "hinmei:" << (char*)var << " ";
rs.getColValue("nedan", &var1);
char buf[80];
double nedan = (float)var1 + 10;
sprintf(buf, "%f", (float)var1);
result << "nedan:" << buf << "\n";
rs.movenext();
}
printf("result:\n%s",(char*)result);
}
getColStringValue 関数の説明
- 書式
- long getColStringValue(const char* name, char* var)
- 機能
- 項目のデータを取得します。
- 処理
- 指定した名前の項目のデータを文字列で取得します。
- 引数
-
(in)const char* name | 項目の名前を指定します。 |
(out)char* var | 項目のデータを格納する char型のポインタを指定します。 |
- 返値
- WS_NO_ERR:成功、WS_ERR:失敗
- 注意
- バッファのオーバーフローに気を付けて使用して下さい。
- サンプル
-
//テーブルの作成とデータの格納
char buf1[1024];
strcpy(buf1, "drop table shinamono");
long ret = newvdb__000->sqlExecute(buf1);
strcpy(buf1,"create table shinamono(code int, hinmei char(20), nedan float)");
newvdb__000->sqlExecute(buf1);
newvdb__000->beginTran();
strcpy(buf1,"insert into shinamono values(1, 'みかん', 100)");
newvdb__000->sqlExecute(buf1);
strcpy(buf1,"insert into shinamono values(2, 'りんご', 200)");
newvdb__000->sqlExecute(buf1);
strcpy(buf1,"insert into shinamono values(3, 'バナナ', 300)");
newvdb__000->sqlExecute(buf1);
strcpy(buf1,"insert into shinamono values(4, 'メロン', 0)");
newvdb__000->sqlExecute(buf1);
newvdb__000->commitTran();
//データの参照
WSCdbRecord rs(newvdb__000);
char var[256];
WSCstring result;
newvdb__000->beginTran();
if(rs.open("select * from shinamono order by code") == WS_NO_ERR) {
while (!rs.isEOF()) {
rs.getColValue("code", &var);
int code = (int)var;
result << "code:" << (int)var << " ";
rs.getColStringValue("hinmei", &var);
result << "hinmei:" << (char*)var << " ";
rs.getColValue("nedan", &var);
char buf[80];
double nedan = (float)var + 10;
sprintf(buf, "%f", (float)var);
result << "nedan:" << buf << "\n";
rs.movenext();
}
printf("result:\n%s",(char*)result);
}
setColValue 関数の説明
- 書式
- long setColValue(long index, WSCvariant var)
- 機能
- 項目のデータを取得します。
- 処理
- 指定した番号の項目のデータ文字列で取得します。
- 引数
-
(in)long index | 項目の番号を指定します。 |
(in)WSCvariant var | 設定するデータを指定します。 |
- 返値
- WS_NO_ERR:成功、WS_ERR:失敗
- 注意
- プライマリキーの設定とキーの not null オプションが
必要になります。
ODBCの場合はODBCドライバによってサポートされない場合が
あります。
PostgreSQLでは oid を使用して実現しております。
MySQLでは _rowid を使用して実現しております。
- サンプル
-
//テーブルの作成とデータの格納
char buf1[1024];
strcpy(buf1, "drop table shinamono");
long ret = newvdb__000->sqlExecute(buf1);
strcpy(buf1,"create table shinamono(code int not null, hinmei char(20), nedan float, primary key(code))");
newvdb__000->sqlExecute(buf1);
newvdb__000->beginTran();
strcpy(buf1,"insert into shinamono values(1, 'みかん', 100)");
newvdb__000->sqlExecute(buf1);
strcpy(buf1,"insert into shinamono values(2, 'りんご', 200)");
newvdb__000->sqlExecute(buf1);
strcpy(buf1,"insert into shinamono values(3, 'バナナ', 300)");
newvdb__000->sqlExecute(buf1);
strcpy(buf1,"insert into shinamono values(4, 'メロン', 0)");
newvdb__000->sqlExecute(buf1);
newvdb__000->commitTran();
//データの参照
WSCdbRecord rs(newvdb__000);
WSCvariant var;
WSCstring result;
newvdb__000->beginTran();
if(rs.open("select * from shinamono order by code", SQL_CURSOR_KEYSET_DRIVEN) == WS_NO_ERR) {
while (!rs.isEOF()) {
rs.getColValue("code", &var);
int code = (int)var;
result << "code:" << (int)var << " ";
rs.getColStringValue("hinmei", &var);
result << "hinmei:" << (char*)var << " ";
rs.getColValue("nedan", &var);
char buf[80];
double nedan = (float)var + 10;
sprintf(buf, "%f", (float)var);
result << "nedan:" << buf << "\n";
if(code != 5) {
rs.edit();
rs.setColValue(0, nedan);
rs.update();
} else {
rs.deleterow();
}
rs.movenext();
}
printf("result:\n%s",(char*)result);
}
setColValue 関数の説明
- 書式
- long setColValue(const char* name, WSCvariant var)
- 機能
- 項目のデータを取得します。
- 処理
- 指定した番号の項目のデータ文字列で取得します。
- 引数
-
(in)const char* name | 項目の名前を指定します。 |
(in)WSCvariant var | 設定するデータを指定します。 |
- 返値
- WS_NO_ERR:成功、WS_ERR:失敗
- 注意
- プライマリキーの設定とキーの not null オプションが
必要になります。
ODBCの場合はODBCドライバによってサポートされない場合が
あります。
PostgreSQLでは oid を使用して実現しております。
MySQLでは _rowid を使用して実現しております。
- サンプル
-
//テーブルの作成とデータの格納
char buf1[1024];
strcpy(buf1, "drop table shinamono");
long ret = newvdb__000->sqlExecute(buf1);
strcpy(buf1,"create table shinamono(code int not null, hinmei char(20), nedan float, primary key(code))");
newvdb__000->sqlExecute(buf1);
newvdb__000->beginTran();
strcpy(buf1,"insert into shinamono values(1, 'みかん', 100)");
newvdb__000->sqlExecute(buf1);
strcpy(buf1,"insert into shinamono values(2, 'りんご', 200)");
newvdb__000->sqlExecute(buf1);
strcpy(buf1,"insert into shinamono values(3, 'バナナ', 300)");
newvdb__000->sqlExecute(buf1);
strcpy(buf1,"insert into shinamono values(4, 'メロン', 0)");
newvdb__000->sqlExecute(buf1);
newvdb__000->commitTran();
newvdb__000->beginTran();
//データの参照
WSCdbRecord rs(newvdb__000);
WSCvariant var;
WSCstring result;
newvdb__000->beginTran();
if(rs.open("select * from shinamono order by code", SQL_CURSOR_KEYSET_DRIVEN) == WS_NO_ERR) {
while (!rs.isEOF()) {
rs.getColValue("code", &var);
int code = (int)var;
result << "code:" << (int)var << " ";
rs.getColStringValue("hinmei", &var);
result << "hinmei:" << (char*)var << " ";
rs.getColValue("nedan", &var);
char buf[80];
double nedan = (float)var + 10;
sprintf(buf, "%f", (float)var);
result << "nedan:" << buf << "\n";
if(code != 5) {
rs.edit();
rs.setColValue("nedan", nedan);
rs.update();
} else {
rs.deleterow();
}
rs.movenext();
}
printf("result:\n%s",(char*)result);
}
newvdb__000->commitTran();
edit 関数の説明
- 書式
- long edit()
- 機能
- 項目の編集を可能とします。
- 処理
-
- 引数
- なし。
- 返値
- WS_NO_ERR:成功、WS_ERR:失敗
- 注意
- カーソルの種類が SQL_CURSOR_KEYSET_DRIVEN に
設定されていなければいけません。
プライマリキーの設定とキーの not null オプションが
必要になります。
ODBCの場合はODBCドライバによってサポートされない場合が
あります。
PostgreSQLでは oid を使用して実現しております。
MySQLでは _rowid を使用して実現しております。
- サンプル
- setColValue のサンプルを参照ください。
update 関数の説明
- 書式
- long update()
- 機能
- 現在のレコードを更新します。
- 処理
- 現在のレコードを UPDATE 又は INSERTします。
- 引数
- なし。
- 返値
- WS_NO_ERR:成功、WS_ERR:失敗
- 注意
- edit、addnew 関数が先に実行されている必要があります。
プライマリキーの設定とキーの not null オプションが
必要になります。
ODBCの場合はODBCドライバによってサポートされない場合が
あります。
PostgreSQLでは oid を使用して実現しております。
MySQLでは _rowid を使用して実現しております。
- サンプル
- setColValue のサンプルを参照ください。
addnew 関数の説明
- 書式
- long addnew()
- 機能
- レコードの追加を行います。
- 処理
- レコードの追加を行う準備を行います。
- 引数
- なし。
- 返値
- WS_NO_ERR:成功、WS_ERR:失敗
- 注意
- プライマリキーの設定とキーの not null オプションが
必要になります。
ODBCの場合はODBCドライバによってサポートされない場合が
あります。
PostgreSQLでは oid を使用して実現しております。
MySQLでは _rowid を使用して実現しております。
- サンプル
-
//テーブルの作成とデータの格納
char buf1[1024];
strcpy(buf1, "drop table shinamono");
long ret = newvdb__000->sqlExecute(buf1);
strcpy(buf1,"create table shinamono(code int not null, hinmei char(20), nedan float, primary key(code))");
newvdb__000->beginTran();
//データの参照
WSCdbRecord rs(newvdb__000);
WSCvariant var;
WSCstring result;
newvdb__000->beginTran();
if(rs.open("select * from shinamono order by code", SQL_CURSOR_KEYSET_DRIVEN) == WS_NO_ERR) {
if (rs.isEOF()) {
rs.addnew();
rs.setColValue("code", 1);
rs.setColValue("hinmei", 'みかん');
rs.setColValue("nedan", 100);
rs.update();
}
}
newvdb__000->commitTran();
deleterow 関数の説明
- 書式
- long deleterow()
- 機能
- 現在のレコードを削除します。
- 処理
-
- 引数
- なし。
- 返値
- WS_NO_ERR:成功、WS_ERR:失敗
- 注意
- なし。
- サンプル
- setColValue のサンプルを参照ください。
moveNext 関数の説明
- 書式
- long moveNext()
- 機能
- 現在のレコードを次のレコードに移動します。
- 処理
-
- 引数
- なし。
- 返値
- WS_NO_ERR:成功、WS_ERR:失敗
- 注意
- なし。
- サンプル
- setColValue のサンプルを参照ください。
movePrevious 関数の説明
- 書式
- long movePrevious()
- 機能
- 現在のレコードを前のレコードに移動します。
- 処理
-
- 引数
- なし。
- 返値
- WS_NO_ERR:成功、WS_ERR:失敗
- 注意
- なし。
- サンプル
-
//データの参照
WSCdbRecord rs(newvdb__000);
WSCvariant var;
WSCstring result;
newvdb__000->beginTran();
if(rs.open("select * from shinamono order by code", SQL_CURSOR_KEYSET_DRIVEN) == WS_NO_ERR) {
if (!rs.isEOF()) {
rs.moveLast();
rs.movePrevious();
}
}
moveFirst 関数の説明
- 書式
- long moveFirst()
- 機能
- 現在のレコードを先頭のレコードに移動します。
- 処理
-
- 引数
- なし。
- 返値
- WS_NO_ERR:成功、WS_ERR:失敗
- 注意
- ODBCの場合はODBCドライバによって動作が正しく行われない場合が
あります。
- サンプル
-
//データの参照
WSCdbRecord rs(newvdb__000);
WSCvariant var;
WSCstring result;
newvdb__000->beginTran();
if(rs.open("select * from shinamono order by code", SQL_CURSOR_KEYSET_DRIVEN) == WS_NO_ERR) {
if (!rs.isEOF()) {
rs.moveLast();
rs.moveFirst();
}
}
moveLast 関数の説明
- 書式
- long moveLast()
- 機能
- 現在のレコードを最終のレコードに移動します。
- 処理
-
- 引数
- なし。
- 返値
- WS_NO_ERR:成功、WS_ERR:失敗
- 注意
- ODBCの場合はODBCドライバによって動作が正しく行われない場合が
あります。
- サンプル
- moveFirst のサンプルを参照ください。
getColName 関数の説明
- 書式
- long getColName(long index, char* name)
- 機能
- 指定した番号の項目名を取得します。
- 処理
-
- 引数
-
(in)long index | 項目の番号を指定します。0 からの連番です。 |
(in)char* name | カラム名を格納するchar型のポインタを指定します。 |
- 返値
- WS_NO_ERR:成功、WS_ERR:失敗
- 注意
- なし。
- サンプル
-
//データの参照
WSCdbRecord rs(newvdb__000);
WSCvariant var;
WSCstring result;
if(rs.open("select * from shinamono order by code", SQL_CURSOR_KEYSET_DRIVEN) == WS_NO_ERR) {
if (!rs.isEOF()) {
char name[31];
long ret = getColName(0, name);
printf("name : %s\n", name);
}
}
getColIndex 関数の説明
- 書式
- long getColIndex(const char* name)
- 機能
- 指定した名前の項目番号を取得します。
取得される値は0からの連番です。
- 処理
-
- 引数
-
(in)const char* name | 項目の名前を指定します。 |
- 返値
- 0以上:成功、WS_ERR:失敗
- 注意
- なし。
- サンプル
-
//データの参照
WSCdbRecord rs(newvdb__000);
WSCvariant var;
WSCstring result;
if(rs.open("select * from shinamono order by code", SQL_CURSOR_KEYSET_DRIVEN) == WS_NO_ERR) {
if (!rs.isEOF()) {
char name[31];
long index = getColName("code");
printf("index : %d\n", index);
}
}
getColType 関数の説明
- 書式
- long getColType(long index)
- 機能
- 指定した番号の項目種別を取得します。
- 処理
-
- 引数
-
(in)long index | 項目の番号を指定します。 |
- 返値
- 0以上:成功、WS_ERR:失敗
WSCDB_FIELD_TYPE_CHAR | 文字列です。 |
WSCDB_FIELD_TYPE_NUMERIC | 文字列の数値型です。 |
WSCDB_FIELD_TYPE_DECIMAL | 文字列の数値型です。 |
WSCDB_FIELD_TYPE_INTEGER | 数値の long型です。 |
WSCDB_FIELD_TYPE_SMALLINT | 数値の short型です。 |
WSCDB_FIELD_TYPE_FLOAT | 数値の float型です。 |
WSCDB_FIELD_TYPE_REAL | 数値の float型です。 |
WSCDB_FIELD_TYPE_DOUBLE | 数値の double型です。 |
WSCDB_FIELD_TYPE_DATE | 文字列の日付型です。 |
WSCDB_FIELD_TYPE_TIME | 文字列の時間型です。 |
WSCDB_FIELD_TYPE_TIMESTAMP | 文字列のタイムスタンプ型です。 |
WSCDB_FIELD_TYPE_NONE | 文字列のその他型です。 |
- 注意
- なし。
- サンプル
-
//データの参照
WSCdbRecord rs(newvdb__000);
WSCvariant var;
WSCstring result;
if(rs.open("select * from shinamono order by code", SQL_CURSOR_KEYSET_DRIVEN) == WS_NO_ERR) {
if (!rs.isEOF()) {
char name[31];
long type = getColType(0);
printf("type : %d\n", type);
}
}
getColLength 関数の説明
- 書式
- long getColLength(long index)
- 機能
- 指定した番号の項目の長さを取得します。
- 処理
-
- 引数
-
(in)long index | 項目の番号を指定します。 |
- 返値
- 項目の長さ
- 注意
- なし。
- サンプル
-
//データの参照
WSCdbRecord rs(newvdb__000);
WSCvariant var;
WSCstring result;
if(rs.open("select * from shinamono order by code", SQL_CURSOR_KEYSET_DRIVEN) == WS_NO_ERR) {
long count = rs.getRowCount();
for (long i = 0; i < count; i++) {
char* name = new char(rs.getColLength(0));
rs.getColValue("name", name);
delete name;
rs.moveNext();
}
}
getColLength 関数の説明
- 書式
- long getColLength(const char* name)
- 機能
- 項目名で指定した番号の項目の長さで取得します。
- 処理
-
- 引数
-
(in)const char* name | 項目の名前を指定します。 |
- 返値
- 項目の長さ
- 注意
- なし。
- サンプル
-
//データの参照
WSCdbRecord rs(newvdb__000);
WSCvariant var;
WSCstring result;
if(rs.open("select * from shinamono order by code", SQL_CURSOR_KEYSET_DRIVEN) == WS_NO_ERR) {
long count = rs.getRowCount();
for (long i = 0; i < count; i++) {
char* name = new char(rs.getColLength(0));
rs.getColValue("name", name);
delete name;
rs.moveNext();
}
}
getRowCount 関数の説明
- 書式
- long getRowCount()
- 機能
- 問合せした結果のレコード件数を取得します。
- 処理
-
- 引数
- なし。
- 返値
- レコード件数
- 注意
- なし。
- サンプル
-
//データの参照
WSCdbRecord rs(newvdb__000);
WSCvariant var;
WSCstring result;
if(rs.open("select * from shinamono order by code", SQL_CURSOR_KEYSET_DRIVEN) == WS_NO_ERR) {
long count = rs.getRowCount();
for (long i = 0; i < count; i++) {
rs.getColValue(0, &var);
rs.moveNext();
}
}
getColCount 関数の説明
- 書式
- long getColCount()
- 機能
- 問合せした結果の項目数を取得します。
- 処理
-
- 引数
- なし。
- 返値
- 項目数
- 注意
- なし。
- サンプル
-
//データの参照
WSCdbRecord rs(newvdb__000);
WSCvariant var;
WSCstring result;
if(rs.open("select * from shinamono order by code", SQL_CURSOR_KEYSET_DRIVEN) == WS_NO_ERR) {
long count = rs.getRowCount();
for (long i = 0; i < count; i++) {
for(long cols = 0; cols < rs.getColCount; cols++) {
rs.getColValue(cols, &var);
}
rs.moveNext();
}
}
getErrorMsg 関数の説明
- 書式
- void getErrorMsg(char* szState, char* szMsg)
- 機能
- エラーメッセージを取得します。
- 処理
-
- 引数
-
(in)char* szState | エラー番号を格納する変数を指定します。 |
(in)char* szMsg | エラーメッセージを格納する変数を指定します。 |
- 返値
- なし。
- 注意
- なし。
- サンプル
-
//データの参照
WSCdbRecord rs(newvdb__000);
WSCvariant var;
WSCstring result;
if(rs.open("select * from shinamono order by code", SQL_CURSOR_KEYSET_DRIVEN) != WS_NO_ERR) {
char szStatus[10];
char szMessage[256];
getErrorMsg(szStatus, szMessage);
printf("db error %s:%s", szStatus, szMessage);
}
Document Release 3.70 For Use with Wide Studio Release 3.70, Spring 2004 WideStudio Home | Up to Copyright(C) WideStudio Development Team, 1999-2004 | | Last modified: May. 25, 2004 | |