> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apinizer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# DB-2-API: Stored Procedure Çağırma

> Apinizer Platformu'nda DB-2-API üzerinde stored procedure çağırma işlemlerini sağlar. Oracle veritabanındaki stored procedure'leri REST API endpoint'leri olarak yayınlayabilir, IN ve OUT parametreleri ile çalışabilir.

## Apinizer DB to API Tasarımcısı ile Oracle Veritabanında Procedure Çağrımı

> **Önemli**
>
> Apinizer **OracleTypes.CURSOR** desteklememektedir. Sadece basit procedure çağrımları servis olarak sunabilmektedir.

## 1. DB-2-API Oluşturma

**Yönetim → Geliştirme → API Creator** → **DB-2-API** ile yeni bir API tanımlanır.

<img src="https://mintcdn.com/apinizer/EhzN-eazjyqTurxc/images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/01-db2api-creation.png?fit=max&auto=format&n=EhzN-eazjyqTurxc&q=85&s=dd23eb4678f746a1ee688ecf7d55c4c9" alt="DB-2-API Oluşturma" width="200" data-path="images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/01-db2api-creation.png" />

DB-2-API'nin ad ve açıklama alanları doldurulup **Kaydet ve İlerle (Save and Next)** butonuna tıklanır.

**DB-2-API ayarlarını içeren görsele aşağıda yer verilmiştir:**

<img src="https://mintcdn.com/apinizer/EhzN-eazjyqTurxc/images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/02-db2api-settings.png?fit=max&auto=format&n=EhzN-eazjyqTurxc&q=85&s=ef488ccd8973ad5a14bff1674a767283" alt="DB-2-API Ayarları" width="800" data-path="images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/02-db2api-settings.png" />

## 2. Metot Oluşturma

**Ekle (Add)** butonuna tıklayarak method/endpoint oluşturma paneli açılır.

<img src="https://mintcdn.com/apinizer/EhzN-eazjyqTurxc/images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/03-add-endpoint.png?fit=max&auto=format&n=EhzN-eazjyqTurxc&q=85&s=64142b60ceb62efb376abf9b318d58de" alt="Endpoint Ekleme" width="600" data-path="images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/03-add-endpoint.png" />

### 2.1 Sadece IN Parametresi Kullanan Prosedür Çağrımı

Demo olarak kullanılan Oracle veritabanı prosedürü aşağıdaki örnekte görülmektedir:

```sql theme={null}
create or replace PROCEDURE sampleProcedureWithInParams (
  pId IN NUMBER, 
  pName IN VARCHAR2, 
  pDesc IN VARCHAR2, 
  pCost IN NUMBER, 
  pPrice IN NUMBER, 
  pCat IN NUMBER
) IS 
begin 
  INSERT INTO "TEST"."PRODUCTS" (
    PRODUCT_ID, 
    PRODUCT_NAME, 
    DESCRIPTION, 
    STANDARD_COST, 
    LIST_PRICE, 
    CATEGORY_ID
  ) VALUES (pId, pName, pDesc, pCost, pPrice, pCat); 
  commit; 
end;
```

**Metot oluşturma ayarlarını içeren görsele aşağıda yer verilmiştir:**

<img src="https://mintcdn.com/apinizer/EhzN-eazjyqTurxc/images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/04-method-creation-in-params.png?fit=max&auto=format&n=EhzN-eazjyqTurxc&q=85&s=956b22c497e9abd8d082b012f9d579f4" alt="Metot Oluşturma - IN Parametreleri" width="800" data-path="images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/04-method-creation-in-params.png" />

### 2.2 IN ve OUT Parametresi Alan Prosedür Çağrımı

#### A. Demo olarak kullanılan Oracle veritabanı prosedürü aşağıda görülmektedir:

```sql theme={null}
create or replace PROCEDURE sampleProcedureWithInOutParams (
  pId IN NUMBER, 
  pName OUT VARCHAR2
) IS 
begin 
  select PRODUCT_NAME into pName 
  from PRODUCTS 
  where PRODUCT_ID = pId; 
  commit; 
end;
```

**Metot oluşturma ayarlarını içeren görsele aşağıda yer verilmiştir:**

<img src="https://mintcdn.com/apinizer/EhzN-eazjyqTurxc/images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/05-method-creation-in-out-params.png?fit=max&auto=format&n=EhzN-eazjyqTurxc&q=85&s=4dbc49579bb0ba0d0fee9cf16abc95a8" alt="Metot Oluşturma - IN/OUT Parametreleri" width="800" data-path="images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/05-method-creation-in-out-params.png" />

#### B. Demo olarak kullanılan Oracle veritabanı prosedürü aşağıda görülmektedir:

```sql theme={null}
create or replace PROCEDURE sampleProcedureWithInOutCursorParams (
  cat_id IN NUMBER, 
  total_cost OUT NUMBER, 
  cursoroutparam OUT SYS_REFCURSOR
) IS 
begin 
  SELECT sum (standard_cost) INTO total_cost 
  FROM PRODUCTS 
  where category_id = cat_id; 
  
  OPEN cursoroutparam FOR 
    SELECT * FROM PRODUCTS 
    where category_id = cat_id; 
end;
```

**Metot oluşturma ayarlarını içeren görsele aşağıda yer verilmiştir:**

<img src="https://mintcdn.com/apinizer/EhzN-eazjyqTurxc/images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/06-method-creation-in-out-cursor-params.png?fit=max&auto=format&n=EhzN-eazjyqTurxc&q=85&s=1c11abb39f68540da0484d6cecbd6b16" alt="Metot Oluşturma - IN/OUT Cursor Parametreleri" width="800" data-path="images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/06-method-creation-in-out-cursor-params.png" />

## 3. API Tanım Belgelerini Görüntüleme

**Mesaj İçeriğini Göster (Show Sample Message Body)** linkine tıklayarak mesaj içeriği görüntülenebilir.

<img src="https://mintcdn.com/apinizer/EhzN-eazjyqTurxc/images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/07-show-sample-message-body.png?fit=max&auto=format&n=EhzN-eazjyqTurxc&q=85&s=210bc4e5b273c2aee6fd6e81f076b259" alt="Show Sample Message Body" width="400" data-path="images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/07-show-sample-message-body.png" />

## 4. API Proxy Oluşturma

DB-2-API ekranından **API Proxy Oluştur (Create API Proxy)** butonuna tıklanarak anında API Proxy oluşturulabilir.

<img src="https://mintcdn.com/apinizer/EhzN-eazjyqTurxc/images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/08-create-api-proxy.png?fit=max&auto=format&n=EhzN-eazjyqTurxc&q=85&s=f988f8a3c3815ee1ece9c88c2ba2a1b4" alt="API Proxy Oluştur" width="800" data-path="images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/08-create-api-proxy.png" />

API Proxy'i oluştururken aşağıdaki görselde bulunan alanlar doldurularak **Kaydet (Save)** butonuna tıklanır.

<img src="https://mintcdn.com/apinizer/EhzN-eazjyqTurxc/images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/09-api-proxy-creation-form.png?fit=max&auto=format&n=EhzN-eazjyqTurxc&q=85&s=40194edc7305ff5092c146dc5adeb964" alt="API Proxy Oluşturma Formu" width="800" data-path="images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/09-api-proxy-creation-form.png" />

### 4.1 API Proxy'yi Canlıya Alma

API Proxy, tanımı yapılmış ortam (environment) üzerine hızlı bir şekilde yüklenip , istemcilerin tüketimine açılabilir.

Bu işlemin yönetimi API Proxy ekranındaki **Yükle (Deploy)** butonuyla açılan diyalog üzerinden gerçekleştirilebilir.

<img src="https://mintcdn.com/apinizer/EhzN-eazjyqTurxc/images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/10-deploy-dialog.png?fit=max&auto=format&n=EhzN-eazjyqTurxc&q=85&s=70336ba3b2443e35d6d56b63d1188773" alt="Deploy Dialog" width="800" data-path="images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/10-deploy-dialog.png" />

## 5. Test Etme

### 5.1 IN Procedure'ünün Test Edilmesi

İlgili metodun beklediği parametreler isteğe eklenip çalıştırıldığında aşağıdaki başarılı yanıt dönmektedir.

<img src="https://mintcdn.com/apinizer/EhzN-eazjyqTurxc/images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/11-test-result-in-proc.png?fit=max&auto=format&n=EhzN-eazjyqTurxc&q=85&s=06f2cd0b6c9bd0294fe122d6cbac4623" alt="IN Procedure Test Sonucu" width="800" data-path="images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/11-test-result-in-proc.png" />

### 5.2 OUT Cursor Procedure'ünün Test Edilmesi

İlgili metodun beklediği parametreler isteğe eklenip çalıştırıldığında aşağıdaki başarılı yanıt dönmektedir.

<img src="https://mintcdn.com/apinizer/EhzN-eazjyqTurxc/images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/12-test-result-out-cursor-proc.png?fit=max&auto=format&n=EhzN-eazjyqTurxc&q=85&s=8ec70d752dabda025331d966fce4f231" alt="OUT Cursor Procedure Test Sonucu" width="800" data-path="images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/12-test-result-out-cursor-proc.png" />

### 5.3 OUT Procedure Test Edilmesi

İlgili metodun beklediği parametreler isteğe eklenip çalıştırıldığında aşağıdaki başarılı yanıt dönmektedir.

<img src="https://mintcdn.com/apinizer/EhzN-eazjyqTurxc/images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/13-test-result-out-proc.png?fit=max&auto=format&n=EhzN-eazjyqTurxc&q=85&s=6f52258813aa1d3e49c516dc853116d1" alt="OUT Procedure Test Sonucu" width="800" data-path="images/tutorials/api-olusturucu-senaryolari/db2api-stored-procedure/13-test-result-out-proc.png" />
