--- title: "行の作成" url: https://docs.catalyst.zoho.com/ja/sdk/flutter/v2/cloud-scale/data-store/create-rows/ description: "Data Store内の特定のテーブルに対して新しい行インスタンスを作成し、このクラスで定義されたメソッドがインスタンスオブジェクトにアクセスできるようにすることができます。" last_updated: 2026-03-30T08:10:30Z service: Cloud Scale type: general related_links: - name: "Data Store" url: /ja/cloud-scale/help/data-store/introduction - name: "Records" url: /ja/cloud-scale/help/data-store/records - name: "Insert Row - API" url: /ja/api/code-reference/cloud-scale/data-store/insert-new-row/#InsertNewRow --- # 行の作成 ### 単一行の作成 `newRow()`メソッドを使用して、指定されたインスタンスの[Data Store](https://docs.catalyst.zoho.com/ja/cloud-scale/help/data-store/introduction)テーブルに新しい行を作成できます。カラム名と対応する行の値をキーと値のペアとして指定することで、テーブル内の行の値を設定する必要があります。 以下のコード構文で使用される`<ROW_INSTANCE>`は、[行インスタンスページ](https://docs.catalyst.zoho.com/ja/sdk/flutter/v2/cloud-scale/data-store/create-row-instance)で定義されたインスタンスです。 ```bash Future<(APIResponse, ZCatalystRow)> <ROW_INSTANCE>.create() ``` > **注意:** `is_unique`または`is_mandatory`プロパティが有効な状態でカラムが作成された場合、値がそれぞれ一意であること、または必須で渡されることを確認する必要があります。また、カラムに渡すデータがカラムに設定されたデータ型であることも確認する必要があります。 行インスタンスの作成を含むサンプルコードスニペットを以下に示します: ```bash var row = ZCatalystApp.getInstance() .getDataStoreInstance() .getTableInstance(identifier: 'Products') .newRow(); //テーブルの行インスタンスを定義し、行のキーと値のデータを渡す row.setColumnValue('product_name', 'power_bank'); row.setColumnValue('product_price', 2000); row.setColumnValue('product_quantity', 2); try { var (response, row) = await row.create(); print('New row created successfully : ${row.id}'); } on ZCatalystException catch (ex) { print('Failed to create the row: $exception'); } ``` ### 複数行の作成 Catalyst Flutter SDKでは、指定されたインスタンスのテーブルに複数の行を一度に作成できます。テーブルに挿入する必要がある行を含むリストを渡すことで実行されます。以下のコード構文に示すように、リストは`createRows()`メソッドの引数として渡されます。 以下のコードで使用される`<TABLE_INSTANCE>`は、[テーブルインスタンスページ](https://docs.catalyst.zoho.com/ja/sdk/flutter/v2/cloud-scale/data-store/create-table-instance)で定義されたインスタンスです。 ```bash Future<(APIResponse, List<ZCatalystRow>)> <TABLE_INSTANCE>.createRows(List<ZCatalystRow> rows) ``` **パラメータ**: * `rows`: 作成する行の配列 行インスタンスの作成を含むサンプルコードスニペットを以下に示します: ```bash List<ZCatalystRow> newRows = []; //配列を作成する //作成する行の行インスタンスを定義する ZCatalystRow row1 = dataStore.getTableInstance(identifier: 'Products').newRow(); row1.setColumnValue('product_name', 'a'); row1.setColumnValue('product_price', 25); row1.setColumnValue('product_quantity', 50); ZCatalystRow row2 = dataStore.getTableInstance(identifier: 'Products').newRow(); row2.setColumnValue('product_name', 'b'); row2.setColumnValue('product_price', 30); row2.setColumnValue('product_quantity', 40); ZCatalystRow row3 = dataStore.getTableInstance(identifier: 'Products').newRow(); row3.setColumnValue('product_name', 'c'); row3.setColumnValue('product_price', 25); row3.setColumnValue('product_quantity', 70); //配列に行インスタンスを追加する newRows.add(row1); newRows.add(row2); newRows.add(row3); try{ var (response, rows) = await dataStore.getTableInstance(identifier: 'Products').createRows(rows: newRows); for (var row in rows) { print(row.id); //行の正常な作成時に実行するアクション } } on ZCatalystException catch (ex) { print('The IDs of the rows that were successfully created are listed below:') } ```