# プロシージャ

すべてのプロシージャはアプリの `core` スキーマにあり、`VARIANT` を返し、`CALL TOMBA.core.<procedure>(...)` として呼び出します。`VARIANT` 引数には JSON 文字列ではなくオブジェクトを渡します。例：`{'domain': 'WEBSITE'}`。

## テーブルを対象とするツール

| プロシージャ                                                                                                                                                    | 処理内容                                                             | ロール         |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------ |
| `find_emails(input_table STRING, domain_column STRING, first_name_column STRING, last_name_column STRING, output_table STRING, max_rows INT DEFAULT 100000)` | [テーブル全体で Email Finder を実行](/snowflake/tools/email-finder)               | `app_public` |
| `verify_emails(input_table STRING, email_column STRING, output_table STRING, max_rows INT DEFAULT 100000)`                                                   | [テーブル全体で Email Verifier を実行](/snowflake/tools/email-verifier)           | `app_public` |
| `search_domains(input_table STRING, domain_column STRING, output_table STRING, max_rows INT DEFAULT 100000, emails_per_domain INT DEFAULT 10)`               | [テーブル全体で Domain Search を実行](/snowflake/tools/domain-search)             | `app_public` |
| `enrich_emails(input_table STRING, email_column STRING, output_table STRING, max_rows INT DEFAULT 100000)`                                                   | [テーブル全体で Email Enrichment を実行](/snowflake/tools/email-enrichment)       | `app_public` |
| `enrich_people(input_table STRING, email_column STRING, output_table STRING, max_rows INT DEFAULT 100000)`                                                   | [テーブル全体で Person Enrichment を実行](/snowflake/tools/person-enrichment)     | `app_public` |
| `enrich_companies(input_table STRING, domain_column STRING, output_table STRING, max_rows INT DEFAULT 100000)`                                               | [テーブル全体で Company Enrichment を実行](/snowflake/tools/company-enrichment)   | `app_public` |
| `enrich_combined(input_table STRING, email_column STRING, output_table STRING, max_rows INT DEFAULT 100000)`                                                 | [テーブル全体で Combined Enrichment を実行](/snowflake/tools/combined-enrichment) | `app_public` |
| `find_emails_from_linkedin(input_table STRING, url_column STRING, output_table STRING, max_rows INT DEFAULT 100000)`                                         | [テーブル全体で LinkedIn Finder を実行](/snowflake/tools/linkedin-finder)         | `app_public` |
| `find_authors(input_table STRING, url_column STRING, output_table STRING, max_rows INT DEFAULT 100000)`                                                      | [テーブル全体で Author Finder を実行](/snowflake/tools/author-finder)             | `app_public` |
| `find_phones(input_table STRING, email_column STRING, output_table STRING, max_rows INT DEFAULT 100000)`                                                     | [テーブル全体で Phone Finder を実行](/snowflake/tools/phone-finder)               | `app_public` |
| `validate_phones(input_table STRING, phone_column STRING, output_table STRING, max_rows INT DEFAULT 100000, country_code_column STRING DEFAULT '')`          | [テーブル全体で Phone Validator を実行](/snowflake/tools/phone-validator)         | `app_public` |
| `find_similar_domains(input_table STRING, domain_column STRING, output_table STRING, max_rows INT DEFAULT 100000)`                                           | [テーブル全体で Similar Domains を実行](/snowflake/tools/similar-domains)         | `app_public` |

## 1つの値を対象とするツール

| プロシージャ                                                          | 処理内容                                                              | ロール         |
| ------------------------------------------------------------------ | ------------------------------------------------------------------------- | ------------ |
| `email_finder(domain STRING, first_name STRING, last_name STRING)` | [1つの値で Email Finder を実行](/snowflake/tools/email-finder)               | `app_public` |
| `email_verifier(email STRING)`                                     | [1つの値で Email Verifier を実行](/snowflake/tools/email-verifier)           | `app_public` |
| `domain_search(domain STRING, emails_per_domain INT DEFAULT 10)`   | [1つの値で Domain Search を実行](/snowflake/tools/domain-search)             | `app_public` |
| `email_enrichment(email STRING)`                                   | [1つの値で Email Enrichment を実行](/snowflake/tools/email-enrichment)       | `app_public` |
| `person_enrichment(email STRING)`                                  | [1つの値で Person Enrichment を実行](/snowflake/tools/person-enrichment)     | `app_public` |
| `company_enrichment(domain STRING)`                                | [1つの値で Company Enrichment を実行](/snowflake/tools/company-enrichment)   | `app_public` |
| `combined_enrichment(email STRING)`                                | [1つの値で Combined Enrichment を実行](/snowflake/tools/combined-enrichment) | `app_public` |
| `linkedin_finder(url STRING)`                                      | [1つの値で LinkedIn Finder を実行](/snowflake/tools/linkedin-finder)         | `app_public` |
| `author_finder(url STRING)`                                        | [1つの値で Author Finder を実行](/snowflake/tools/author-finder)             | `app_public` |
| `phone_finder(email STRING)`                                       | [1つの値で Phone Finder を実行](/snowflake/tools/phone-finder)               | `app_public` |
| `phone_validator(phone STRING, country_code STRING DEFAULT '')`    | [1つの値で Phone Validator を実行](/snowflake/tools/phone-validator)         | `app_public` |
| `similar_finder(domain STRING)`                                    | [1つの値で Similar Domains を実行](/snowflake/tools/similar-domains)         | `app_public` |

## 任意のツール

| プロシージャ                                                                                                        | 処理内容                                                                                                   | ロール         |
| ---------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | ------------ |
| `run_tool(tool STRING, input_table STRING, columns VARIANT, output_table STRING, max_rows INT, options VARIANT)` | [任意のツールをテーブル全体で実行（列のマッピングとオプションを指定）](/snowflake/enrich-a-table#other-input-combinations) | `app_public` |
| `lookup(tool STRING, params VARIANT)`                                                                            | 任意のツールと入力で 1回の検索を実行                                                                            | `app_public` |
| `search_companies(filters VARIANT, output_table STRING, max_results INT DEFAULT 500)`                            | [フィルターに一致する企業をテーブルに出力](/snowflake/tools/companies-search)                                  | `app_public` |

## バックグラウンド実行と再開

| プロシージャ                                                                                                              | 処理内容                                                                          | ロール         |
| ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------ |
| `run_tool_async(tool STRING, input_table STRING, columns VARIANT, output_table STRING, max_rows INT, options VARIANT)` | [`run_tool` をバックグラウンドで実行し、実行 ID を返す](/snowflake/background-runs)        | `app_public` |
| `search_companies_async(filters VARIANT, output_table STRING, max_results INT DEFAULT 500)`                            | [`search_companies` をバックグラウンドで実行](/snowflake/background-runs)                    | `app_public` |
| `cancel_run(run_id STRING)`                                                                                            | [実行中またはキュー内の実行を停止](/snowflake/background-runs#cancel)                     | `app_public` |
| `resume_run(run_id STRING)`                                                                                            | [停止した実行を続行](/snowflake/resume-and-auto-resume)                           | `app_public` |
| `set_auto_resume(run_id STRING, enabled BOOLEAN)`                                                                      | [実行の自動再開をオンまたはオフにする](/snowflake/resume-and-auto-resume#auto-resume) | `app_public` |
| `resume_pending()`                                                                                                     | 自動再開の対象になっているすべての実行を今すぐ再開（アプリが毎日実行）                   | `app_public` |
| `process_jobs()`                                                                                                       | キュー内のバックグラウンド実行を開始（アプリが自動的に実行）                          | `app_public` |

## スケジュール

| プロシージャ                                                                                                                           | 処理内容                                                     | ロール         |
| ----------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | ------------ |
| `create_schedule(name STRING, tool STRING, input_table STRING, columns VARIANT, output_table STRING, cron STRING, options VARIANT)` | [CRON スケジュールでテーブルをエンリッチし続ける](/snowflake/schedules) | `app_admin`  |
| `list_schedules()`                                                                                                                  | スケジュールと前回の実行                                     | `app_public` |
| `pause_schedule(name STRING)`                                                                                                       | スケジュールを一時停止                                                 | `app_admin`  |
| `resume_schedule(name STRING)`                                                                                                      | 一時停止したスケジュールを再開                                        | `app_admin`  |
| `run_schedule(name STRING)`                                                                                                         | スケジュールを今すぐ実行                                               | `app_public` |
| `drop_schedule(name STRING)`                                                                                                        | スケジュールを削除（テーブルは残ります）                              | `app_admin`  |

## ユーティリティ

| プロシージャ                                | 処理内容                                                                              | ロール         |
| ---------------------------------------- | ----------------------------------------------------------------------------------------- | ------------ |
| `status()`                               | アプリのバージョン、接続の承認、トライアル、1日の上限                                      | `app_public` |
| `list_tools()`                           | すべてのツールとその入力、オプション、クレジット、列                                  | `app_public` |
| `pricing()`                              | [クレジットあたりの価格とツールごとのクレジット](/snowflake/pricing-and-limits)                    | `app_public` |
| `usage_summary(days INT DEFAULT 30)`     | [日別・ツール別の実行、クレジット、料金](/snowflake/results-and-history#usage-by-day) | `app_public` |
| `get_settings()`                         | [現在の設定](/snowflake/reference/settings)                                         | `app_public` |
| `set_setting(name STRING, value STRING)` | [設定を変更](/snowflake/reference/settings)                                         | `app_admin`  |
| `clear_cache(tool STRING DEFAULT '')`    | [ツールのキャッシュ済みの結果を消去（すべての場合は '')](/snowflake/cache-and-budgets)             | `app_admin`  |
| `drop_result(output_table STRING)`       | [結果テーブルを削除](/snowflake/results-and-history)                                     | `app_public` |
| `reset_credentials()`                    | 次回の検索時にアプリを Tomba に再接続させる                                        | `app_admin`  |

ビュー：`TOMBA.core.runs`（すべての実行）と `TOMBA.core.usage_by_day`。[結果と履歴](/snowflake/results-and-history)を参照してください。
