Pro * C Oracle 12c

Source: Internet
Author: User

#include <stdio.h>#include <String.h>#include <stdlib.h>#include <sqlca.h>voidMain () {Char username[Ten], password[Ten], server[10];Char name[ALL], title[10];FloatSalary printf"Input name:"); Gets (username); printf "input pass:" ); Gets (password); printf ( "input server: "); Gets (server); EXEC SQL Connect:username identified by:p Assword Using:server; printf (input empoyee Name:  "); Gets (name); EXEC SQL SELECT sal, Job into:salary,: Title from emp WHERE UPPER (ename) = UPPER (: name); PR intf ( "title:%s, salary:%6.2f\n  "             

Compile command: proc iname=demo01.pc parse=full include=/home/oracle/oracle_12c/app/oracle/product/12.1.0/dbhome_1/precomp/ public/include=/usr/local/include/include=/usr/include/

Post-Build: demo01.c

Compile command: Gcc-o Demo01 demo01.c-i/home/oracle/oracle_12c/app/oracle/product/12.1.0/dbhome_1/precomp/public/-l/home/ Oracle/oracle_12c/app/oracle/product/12.1.0/dbhome_1/lib-l Clntsh

Run Intermediate file:./demo01

Input NAME:DINGYINGSI (database user name)

Input PASS:DINGYINGSI (database password)

Input server:127.0.0.1

Input Empolyee:smith

Oracle Scott User table structure and data

--Create tables and delete tables;DROPTABLEDEPT;CREATETABLEDEPT (DEPTNONumber (2)CONSTRAINT pk_deptPRIMARYKEY, dnameVARCHAR2 (14), LOCVARCHAR2 (13) ) ;--Create tables and delete tables;DROPTABLEEMP;CREATETABLEEMP (EMPNONumber (4)CONSTRAINT pk_empPRIMARYKEY, enameVARCHAR2 (10), JOBVARCHAR2 (9), MGRNumber (4), HireDate DATE, SALNumber (7,2), COMMNumber (7,2), DEPTNONumber (2)CONSTRAINT Fk_deptnoREFERENCESDEPT);---Insert DEPT Statement Block;INSERTInto DEPTVALUES(10,‘ACCOUNTING‘,‘NEW YORK‘);INSERTInto DEPTVALUES (20,‘The‘,‘DALLAS‘);INSERTInto DEPTVALUES(30,‘SALES‘,‘CHICAGO‘);INSERTInto DEPTVALUES(40,‘OPERATIONS‘,‘BOSTON‘);---Inserting an EMP statement block;INSERTInto EMPVALUES(7369,‘SMITH‘,‘Clerk‘,7902,to_date (‘17-12-1980‘,‘Dd-mm-yyyy‘),800,Null20);INSERTInto EMPVALUES(7499,‘ALLEN‘,‘Salesman‘,7698,to_date (‘20-2-1981‘,‘Dd-mm-yyyy‘),1600,300,30);INSERTInto EMPVALUES(7521,‘WARD‘,‘Salesman‘,7698,to_date (‘22-2-1981‘,‘Dd-mm-yyyy‘),1250,500,30);INSERTInto EMPVALUES(7566,‘JONES‘,‘MANAGER‘,7839,to_date (‘2-4-1981‘,‘Dd-mm-yyyy‘),2975,Null20);INSERTInto EMPVALUES (7654, ' MARTIN ', ' salesman ', 7698,to_date (' 28-9-1981 ', ' dd-mm-yyyy '), 1250,1400,30); INSERT into EMP VALUES (7698, ' BLAKE ', ' MANAGER ', 7839,to_date (' 1-5-1981 ', ' dd-mm-yyyy '), 2850,null,30); INSERT into EMP VALUES (7782, ' CLARK ', ' MANAGER ', 7839,to_date (' 9-6-1981 ', ' dd-mm-yyyy '), 2450,null,10); INSERT into EMP VALUES (7788, ' SCOTT ', ' ANALYST ', 7566, To_date (' 12-06-1987 ', ' dd-mm-yyyy ') -85,3000,null,20); INSERT into EMP VALUES (7839, ' KING ', ' president ', Null,to_date (' 17-11-1981 ', ' dd-mm-yyyy '), 5000,null,10); INSERT into EMP VALUES (7844, ' TURNER ', ' salesman ', 7698,to_date (' 8-9-1981 ', ' Dd-mm-yyyy '), 1500,0,30); INSERT into EMP VALUES (7876, ' ADAMS ', ' Clerk ', 7788,to_date (' 13-06-1987 ', ' dd-mm-yyyy ')- 51,1100,null,20); INSERT into EMP VALUES (7900, ' JAMES ', ' Clerk ', 7698,to_date (' 3-12-1981 ', ' dd-mm-yyyy '), 950,null,30) INSERT INTO EMP VALUES (7902, ' FORD ', ' ANALYST ', 7566,to_date (' 3-12-1981 ', ' dd-mm-yyyy '), 3000,null,20); INSERT INTO EMP VALUES (7934, ' MILLER ', ' Clerk ', 7782,to_date (' 23-1-1982 ', ' dd-mm-yyyy '), 1300,null,10);D rop TABLE BONUS; CREATE TABLE BONUS (ename VARCHAR2), JOB VARCHAR2 (9), SAL number, COMM number);D rop TABLE Salgrade; CREATE TABLE Salgrade (GRADE number, losal number, hisal number);--insert Salgrade statement block; insert into Salgrade VALUES (1,700,12 INSERT into Salgrade values (2,1201,1400), insert into Salgrade values (3,1401,2000), insert into salgrade values (4,200 1,3000); INSERT into Salgrade VALUES (5,3001,9999); commit;--query part; select * FROM Emp;select * from dept;

Pro * C Oracle 12c

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.