---
title: "SQLCODE"
description: "SQLCODE SQL \uD568\uC218\uB294 \uC2E4\uD589 \uC911\uC5D0 \uBC1C\uC0DD\uD55C \uB9C8\uC9C0\uB9C9 SQL \uC624\uB958\uC758 \uC624\uB958 \uCF54\uB4DC\uB97C \uAC00\uC838\uC635\uB2C8\uB2E4."
language: ko
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/ko/docs/invantive-universalsql/grammar/sql-functions/sqlcode
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/sqlcode
updated: 2026-12-04T14:27:53Z
license: https://documentation.invantive.eu/ko/
---

## 구문

```mermaid
%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart LR
    Start((START)) --> SQLCODE[SQLCODE]:::quoted
    SQLCODE --> End((END))
```

## 목적
`SQLCODE` SQL 함수는 실행 중에 발생한 마지막 SQL 오류의 오류 코드를 가져옵니다. 이 함수는 괄호 없이 사용할 수 있습니다.

[[SQLERRM]] 및 [[SQLROWCOUNT]]도 참조하십시오.

반환값: 마지막 오류의 오류 코드(`varchar2` 타입). 오류가 발생하지 않은 경우 `null`을(를) 반환합니다.

## 예시
다음 예제는 마지막 오류의 오류 코드를 조회합니다. 오류가 발생하지 않았으므로 출력은 비어 있습니다:
```sql
select sqlcode

-------------------

```
다음 예제는 먼저 0으로 나누기 오류를 발생시킨 다음 마지막 오류의 오류 코드를 조회합니다:
```sql
select 1 / 0

itgenttn082: Division of 1 by zero is impossible.
```
```sql
select sqlcode

-------------------
itgenttn082
```
다음 예제는 0으로 나누기 오류를 잡습니다. 예외 처리기 내에서 `SQLCODE`은(는) 오류 코드 `itgenttn082`를 반환합니다:
```sql
declare
  l_dummy    pls_integer;
begin
  select 1/0
  into   l_dummy
  ;
exception
  when others
  then
    dbms_output.put_line(sqlcode);
end;
```

