html5-img
1 / 12

Embedded-SQL

Embedded-SQL. 홍익대학교 데이터베이스 2004 년도 2 학기. ORACLE 사용 준비 단계 (1). Step 1 sol2.ce.hongik.ac.kr 에 접속. ORACLE 사용 준비 단계 (2). Step 2 자신의 계정으로 login 계정이 아직 발급되지 않은 경우는 admin 에게 문의. ORACLE 사용 준비 단계 (3). Step 3 ORACLE 을 사용하기 위해서 ORACLE 이 설치된 220.95.134.97 에 접속.

keitha
Download Presentation

Embedded-SQL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Embedded-SQL 홍익대학교 데이터베이스 2004년도 2학기 Database Laboratory, Hong Ik University

  2. ORACLE 사용 준비 단계 (1) • Step 1 • sol2.ce.hongik.ac.kr 에 접속 Database Laboratory, Hong Ik University

  3. ORACLE 사용 준비 단계 (2) • Step 2 • 자신의 계정으로 login • 계정이 아직 발급되지 않은 경우는 admin에게 문의 Database Laboratory, Hong Ik University

  4. ORACLE 사용 준비 단계 (3) • Step 3 • ORACLE을 사용하기 위해서 ORACLE이 설치된 220.95.134.97에 접속 Database Laboratory, Hong Ik University

  5. ORACLE 사용 준비 단계 (4) • Step 4 • 자신의 DBLAB 계정으로 login • 과제 출제 후 계정 발급 • 계정: ce+자신의 학번 예) a111111인 경우는 cea111111 • 비밀번호: 자신의 학번 예) a111111인 경우는 a111111 Database Laboratory, Hong Ik University

  6. ORACLE 사용 시작 • ORACLE DBMS에 진입 • sqlplus 명령어와 자신의 계정 및 비밀번호 입력 • 계정: ce+자신의 학번 예) a111111인 경우는 cea111111 • 비밀번호 : db • sqlplus cea111111/db 라고 입력함 Database Laboratory, Hong Ik University

  7. ESQL Programming(1) • ESQL(Embedded SQL) • 호스트에서 작성한 프로그램을 통해 DB에 접근 • PL/I, PASCAL, COBOL, C 등의 범용 프로그램밍 언어로 작성된 응용 프로그램속에 SQL 삽입 • 확장자 : pc • 프로그램 시 참고 • 책에 있는 ORACLE에서의 프로그램 예제를 참조하시오. Database Laboratory, Hong Ik University

  8. ESQL Programming(2) • Step 1 • ORACLE의 sqlplus를 통해 자신의 데이터베이스를 구축 • Step 2 • Vi 와 같은 편집기를 이용하여 ESQL 프로그램 작성 Database Laboratory, Hong Ik University

  9. ESQL Programming(3) • Step 3 • 작성된 프로그램을 저장하고 컴파일 • 명령어 : oracle_make examp1 • 단, 프로그램의 확장자는 입력하지 않는다. Database Laboratory, Hong Ik University

  10. ESQL Programming(4) • Step 4 • 디버깅 및 실행 • 실행할 때, 실행 파일 이름 앞에 ./추가 • ./examp1 Database Laboratory, Hong Ik University

  11. ESQL Programming 예(1) static /********************** 제일 간단한 ESQLC 예제(demo1.ec) ********************/ #include<stdio.h> #include<string.h> #include<sqlda.h> EXEC SQL INCLUDE SQLCA; EXEC SQL BEGIN DECLARE SECTION; char name[10]; int number; double sal; char user_name[20]; char pass[10]; EXEC SQL END DECLARE SECTION; int main(){ strcpy(user_name, “hong"); strcpy(pass, “db"); EXEC SQL CONNECT :user_name IDENTIFIED BY :pass; printf("\nConnected to ORACLE as user: %s\n", user_name); EXEC SQL DECLARE sales_info CURSOR FOR select empno, empname, sal from sales; EXEC SQL OPEN sales_info; printf("Person_Number Person_Name Salary\n"); printf("======================================\n"); EXEC SQL FETCH sales_info INTO :number, :name, :sal; printf("%11d%11s%11f\n",number, name, sal); EXEC SQL CLOSE sales_info; EXEC SQL COMMIT WORK; return(0); } Database Laboratory, Hong Ik University

  12. SQLSTATE • 정의 • Error handling을 위한 status variable • SQL 질의문이 올바르게 실행되지 않는 경우 그 원인을 분석하기 위해 사용하는 variable • 형식 • 2-character class code + 3-character subclass code Database Laboratory, Hong Ik University

More Related