Win32 API 日本語リファレンス
ホームSystem.Search › SQL_INTERVAL_STRUCT

SQL_INTERVAL_STRUCT

構造体
サイズx64: 28 バイト / x86: 28 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
interval_typeSQLINTERVAL4+0+0インターバルの種類を示す SQLINTERVAL 列挙値。年月や日秒等を区別する。
interval_signSHORT2+4+4符号。正は SQL_FALSE、負は SQL_TRUE で表す。
intval_intval_e__Union20+8+8年月または日秒の値を保持する共用体。interval_type で解釈が決まる。

共用体: _intval_e__Union x64 20B / x86 20B

フィールドサイズx64x86
year_monthSQL_YEAR_MONTH_STRUCT8+0+0
day_secondSQL_DAY_SECOND_STRUCT20+0+0

各言語での定義

#include <windows.h>

// SQL_INTERVAL_STRUCT  (x64 28 / x86 28 バイト)
typedef struct SQL_INTERVAL_STRUCT {
    SQLINTERVAL interval_type;
    SHORT interval_sign;
    _intval_e__Union intval;
} SQL_INTERVAL_STRUCT;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SQL_INTERVAL_STRUCT
{
    public int interval_type;
    public short interval_sign;
    public _intval_e__Union intval;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SQL_INTERVAL_STRUCT
    Public interval_type As Integer
    Public interval_sign As Short
    Public intval As _intval_e__Union
End Structure
import ctypes
from ctypes import wintypes

class SQL_INTERVAL_STRUCT(ctypes.Structure):
    _fields_ = [
        ("interval_type", ctypes.c_int),
        ("interval_sign", ctypes.c_short),
        ("intval", _intval_e__Union),
    ]
#[repr(C)]
pub struct SQL_INTERVAL_STRUCT {
    pub interval_type: i32,
    pub interval_sign: i16,
    pub intval: _intval_e__Union,
}
import "golang.org/x/sys/windows"

type SQL_INTERVAL_STRUCT struct {
	interval_type int32
	interval_sign int16
	intval _intval_e__Union
}
type
  SQL_INTERVAL_STRUCT = record
    interval_type: Integer;
    interval_sign: Smallint;
    intval: _intval_e__Union;
  end;
const SQL_INTERVAL_STRUCT = extern struct {
    interval_type: i32,
    interval_sign: i16,
    intval: _intval_e__Union,
};
type
  SQL_INTERVAL_STRUCT {.bycopy.} = object
    interval_type: int32
    interval_sign: int16
    intval: _intval_e__Union
struct SQL_INTERVAL_STRUCT
{
    int interval_type;
    short interval_sign;
    _intval_e__Union intval;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SQL_INTERVAL_STRUCT サイズ: 28 バイト(x64)
dim st, 7    ; 4byte整数×7(構造体サイズ 28 / 4 切り上げ)
; interval_type : SQLINTERVAL (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; interval_sign : SHORT (+4, 2byte)  wpoke st,4,値  /  値 = wpeek(st,4)
; intval : _intval_e__Union (+8, 20byte)  varptr(st)+8 を基点に操作(20byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global SQL_INTERVAL_STRUCT
    #field int interval_type
    #field short interval_sign
    #field byte intval 20
#endstruct

stdim st, SQL_INTERVAL_STRUCT        ; NSTRUCT 変数を確保
st->interval_type = 100
mes "interval_type=" + st->interval_type
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。