proc 관해 질문 드려요~ㅠㅠ

zealdin의 이미지

이번에 db연동과제가 주어져서

친구도움을 받구 과제를 했습니다

얼마후에 교수님께서 proc가 똑같다고 합니다.

그래서 교수님께서 다시 해오라는데 저는 proc를 수정할려고 합니다.

어떻게하면 proc를 수정할수있을까요? 아님 c언어를 수정해야할까여?

도움 부탁드려요~ㅠㅠ

#include
#include
#include
#include
/*
#include
#include
*/

#define USERNAME "s093910"
#define PASSWORD "jjw0415"

#define TRUE 1
#define FALSE 0

/* Maximum number of select-list items or bind variables. */
#define MAX_ITEMS 40

/* Maximum lengths of the _names_ of the
select-list items or indicator variables. */
#define MAX_VNAME_LEN 30
#define MAX_INAME_LEN 30

#ifndef NULL
#define NULL 0
#endif

/* Function Prototypes */
void sql_error(void);
int oracle_connect(void);
int alloc_descriptors(int, int, int);
int get_dyn_statement(void);
void set_bind_variables(void);
void process_select_list(void);
void help(void);

char *dml_commands[] = {"SELECT", "select", "INSERT", "insert",
"UPDATE", "update", "DELETE", "delete"};

typedef struct STUDENT
{
char name[40];
int numbers;
char ssn[40];
char address[80];
char phone[20];
char parentaddress[80];
char parentphone[20];
char birth[14];
char sex[20];
char class[30];
char degree[20];
char downdegree[20];
char degreeintro[200];
} STUDENT;

typedef struct DEPARTMENT
{
char subjectname[40];
int namecode;
char phone[20];
int numbers;
char college[30];
} DEPARTMENT;

typedef struct LECTURE
{
char lecture[30];
int semester;
int years;
char lesson[20];
int numbers;
} LECTURE;

typedef struct GRADE
{
char student[50];
int studentnumber;
char lecture[40];
int numberpoint;
char characterpoint[4];

} GRADE;

typedef struct LESSON
{
char name[30];
char descript[20];
int numbers;
int output;
int levels;
char openedepartment[50];
} LESSON;

EXEC SQL INCLUDE sqlda;
EXEC SQL INCLUDE sqlca;

EXEC SQL BEGIN DECLARE SECTION;
char dyn_statement[1024];
EXEC SQL VAR dyn_statement IS STRING(1024);
EXEC SQL END DECLARE SECTION;

SQLDA *bind_dp;
SQLDA *select_dp;

/* Define a buffer to hold longjmp state info. */
jmp_buf jmp_continue;

/* A global flag for the error routine. */
int parse_flag = 0;

main()
{
int i;

/* Connect to the database. */
if (oracle_connect() != 0)
exit(1);

/* Allocate memory for the select and bind descriptors. */
if (alloc_descriptors(MAX_ITEMS, MAX_VNAME_LEN, MAX_INAME_LEN) != 0)
exit(1);

/* Process SQL statements. */
for (;;)
{
(void) setjmp(jmp_continue);

/* Get the statement. Break on "exit". */
if (get_dyn_statement() != 0)
break;

/* Prepare the statement and declare a cursor. */
EXEC SQL WHENEVER SQLERROR DO sql_error();

parse_flag = 1; /* Set a flag for sql_error(). */
EXEC SQL PREPARE S FROM :dyn_statement;
parse_flag = 0; /* Unset the flag. */

EXEC SQL DECLARE C CURSOR FOR S;

/* Set the bind variables for any placeholders in the
SQL statement. */
set_bind_variables();

/* Open the cursor and execute the statement.
* If the statement is not a query (SELECT), the
* statement processing is completed after the
* OPEN.
*/

EXEC SQL OPEN C USING DESCRIPTOR bind_dp;

/* Call the function that processes the select-list.
* If the statement is not a query, this function
* just returns, doing nothing.
*/
process_select_list();

/* Tell user how many rows processed. */
for (i = 0; i < 8; i++)
{
if (strncmp(dyn_statement, dml_commands[i], 6) == 0)
{
printf("\n\n%d row%c processed.\n", sqlca.sqlerrd[2],
sqlca.sqlerrd[2] == 1 ? '\0' : 's');
break;
}
}
} /* end of for(;;) statement-processing loop */

/* When done, free the memory allocated for
pointers in the bind and select descriptors. */
for (i = 0; i < MAX_ITEMS; i++)
{
if (bind_dp->V[i] != (char *) 0)
free(bind_dp->V[i]);
free(bind_dp->I[i]); /* MAX_ITEMS were allocated. */
if (select_dp->V[i] != (char *) 0)
free(select_dp->V[i]);
free(select_dp->I[i]); /* MAX_ITEMS were allocated. */
}

/* Free space used by the descriptors themselves. */
sqlclu(bind_dp);
sqlclu(select_dp);

EXEC SQL WHENEVER SQLERROR CONTINUE;
/* Close the cursor. */
EXEC SQL CLOSE C;

EXEC SQL COMMIT WORK RELEASE;
puts("\nHave a good day!\n");

EXEC SQL WHENEVER SQLERROR DO sql_error();
return;
}

int oracle_connect()
{
EXEC SQL BEGIN DECLARE SECTION;
char *dbuserid = USERNAME;
char *dbpassword = PASSWORD;
EXEC SQL END DECLARE SECTION;

EXEC SQL WHENEVER SQLERROR GOTO connect_error;
EXEC SQL CONNECT :dbuserid IDENTIFIED BY :dbpassword;

printf("\nConnected to ORACLE as user %s.\n", dbuserid);

return 0;

connect_error:
fprintf(stderr, "Cannot connect to ORACLE as user %s\n", dbuserid);
return -1;
}

/*
* Allocate the BIND and SELECT descriptors using sqlald().
* Also allocate the pointers to indicator variables
* in each descriptor. The pointers to the actual bind
* variables and the select-list items are realloc'ed in
* the set_bind_variables() or process_select_list()
* routines. This routine allocates 1 byte for select_dp->V[i]
* and bind_dp->V[i], so the realloc will work correctly.
*/

int alloc_descriptors(int size, int max_vname_len, int max_iname_len)
{
int i;

/*
* The first sqlald parameter determines the maximum number of
* array elements in each variable in the descriptor. In
* other words, it determines the maximum number of bind
* variables or select-list items in the SQL statement.
*
* The second parameter determines the maximum length of
* strings used to hold the names of select-list items
* or placeholders. The maximum length of column
* names in ORACLE is 30, but you can allocate more or less
* as needed.
*
* The third parameter determines the maximum length of
* strings used to hold the names of any indicator
* variables. To follow ORACLE standards, the maximum
* length of these should be 30. But, you can allocate
* more or less as needed.
*/

if ((bind_dp =
sqlald(size, max_vname_len, max_iname_len)) == (SQLDA *) 0)
{
fprintf(stderr,
"Cannot allocate memory for bind descriptor.");
return -1; /* Have to exit in this case. */
}

if ((select_dp =
sqlald (size, max_vname_len, max_iname_len)) == (SQLDA *) 0)
{
fprintf(stderr,
"Cannot allocate memory for select descriptor.");
return -1;
}
select_dp->N = MAX_ITEMS;

/* Allocate the pointers to the indicator variables, and the
actual data. */
for (i = 0; i < MAX_ITEMS; i++) {
bind_dp->I[i] = (short *) malloc(sizeof (short));
select_dp->I[i] = (short *) malloc(sizeof(short));
bind_dp->V[i] = (char *) malloc(1);
select_dp->V[i] = (char *) malloc(1);
}

return 0;
}

int selectmenu(char * sqlbuf)
{
int nContinue = TRUE;
int nSel = 0;
char table[20] = {0,};
STUDENT student = {0,};
DEPARTMENT department = {0,};
LECTURE lecture = {0,};
GRADE grade = {0,};
LESSON lesson = {0,};


while(nContinue)
{
printf("테이블 선택하시오: 1.STUDENT 2.DEPARTMENT 3.LESSON 4.LECTURE 5.GRADE :_\b");
scanf("%d",&nSel);

switch(nSel)
{
case 1:
strcpy(table,"student");
nContinue = !nContinue;
break;

case 2:
strcpy(table,"department");
nContinue = !nContinue;
break;

case 3:
strcpy(table,"lesson");
nContinue = !nContinue;
break;

case 4:
strcpy(table,"lecture");
nContinue = !nContinue;
break;

case 5:
strcpy(table,"grade");
nContinue = !nContinue;
break;

default:
printf("다시 입력하세오\n");
break;
}
}

printf("1.테이블 내용보기 2.데이터 삽입 3.데이터 삭제 4.데이터 변경 5.DB 초기화 6.exit :_\b");
scanf("%d",&nSel);

switch(nSel)
{
case 1:
sprintf(sqlbuf, "select * from %s;",table);
break;

case 2:
printf("테이블 데이터를 차례차례입력하세요!!!\n");
if(strcmp(table,"student") == 0)
{
printf("이름을 입력하세요 : ");
scanf("%s", &student.name);
printf("학번을 입력하세요 : ");
scanf("%d", &student.numbers);
printf("주민번호을 입력하세요 : ");
scanf("%s", &student.ssn);
printf("주소를 입력하세요 : ");
scanf("%s", &student.address);
printf("전화번호을 입력하세요 : ");
scanf("%s", &student.phone);
printf("부모님 주소를 입력하세요 : ");
scanf("%s", &student.parentaddress);
printf("부모님 전화번호를 입력하세요 : ");
scanf("%s", &student.parentphone);
printf("생년월일을 입력하세요 : ");
scanf("%s", &student.birth);
printf("성별을 입력하세요 : ");
scanf("%s", &student.sex);
printf("학년을 입력하세요 : ");
scanf("%s", &student.class);
printf("전공을 입력하세요 : ");
scanf("%s", &student.degree);
printf("부전공을 입력하세요 : ");
scanf("%s", &student.downdegree);
printf("전공정보를 입력하세요 : ");
scanf("%s", &student.degreeintro);
sprintf(sqlbuf,"insert into %s values('%s','%d','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s');",
table, student.name, student.numbers, student.ssn, student.address, student.phone, student.parentaddress,
student.parentphone, student.birth, student.sex, student.class, student.degree, student.downdegree,
student.degreeintro);
}
else if(strcmp(table,"department") == 0)
{
printf("학과이름을 입력하세요 : ");
scanf("%s", &department.subjectname);
printf("학과코드을 입력하세요 : ");
scanf("%d", &department.namecode);
printf("학과사무실 전화번호을 입력하세요 : ");
scanf("%s", &department.phone);
printf("학과번호을 입력하세요 : ");
scanf("%d", &department.numbers);
printf("소속단과대학을 입력하세요 : ");
scanf("%s", &department.college);
sprintf(sqlbuf,"insert into %s values('%s','%d','%s','%d','%s');",table, department.subjectname,
department.namecode, department.phone, department.numbers, department.college);
}
else if(strcmp(table,"lecture") == 0)
{
printf("강사을 입력하세요 : ");
scanf("%s", &lecture.lecture);
printf("학기을 입력하세요 : ");
scanf("%d", &lecture.semester);
printf("연도을 입력하세요 : ");
scanf("%d", &lecture.years);
printf("과목을 입력하세요 : ");
scanf("%s", &lecture.lesson);
printf("강좌번호을 입력하세요 : ");
scanf("%d", &lecture.numbers);
sprintf(sqlbuf,"insert into %s values('%s','%d','%d','%s','%d');",table, lecture.lecture,
lecture.semester, lecture.years, lecture.lesson, lecture.numbers );
}
else if(strcmp(table,"grade") == 0)
{
printf("학생을 입력하세요 : ");
scanf("%s", &grade.student);
printf("학번을 입력하세요 : ");
scanf("%d", &grade.studentnumber);
printf("강좌을 입력하세요 : ");
scanf("%s", &grade.lecture);
printf("문자열학점을 입력하세요 : ");
scanf("%d", &grade.numberpoint);
printf("정수형학점을 입력하세요 : ");
scanf("%s", &grade.characterpoint);
sprintf(sqlbuf,"insert into %s values('%s','%d','%s','%d','%s');",table, grade.student,
grade.studentnumber ,grade.lecture , grade.numberpoint , grade.characterpoint);
}
else if(strcmp(table,"lesson") == 0)
{
printf("과목이름을 입력하세요 : ");
scanf("%s", &lesson.name);
printf("과목개요을 입력하세요 : ");
scanf("%s", &lesson.descript);
printf("과목번호을 입력하세요 : ");
scanf("%d", &lesson.numbers);
printf("학점수을 입력하세요 : ");
scanf("%d", &lesson.output);
printf("단계을 입력하세요 : ");
scanf("%d", &lesson.levels);
printf("개설학과을 입력하세요 : ");
scanf("%s", &lesson.openedepartment);
sprintf(sqlbuf,"insert into %s values('%s','%s','%d','%d','%d','%s');",table , lesson.name,
lesson.descript, lesson.numbers, lesson.output, lesson.levels, lesson.openedepartment);
}

break;

// 데이터 삭제. Primary Key로 검색한다.
case 3:
if(strcmp(table,"student") == 0)
{
printf("학번을 입력하세요 : ");
scanf("%d",&student.numbers);
sprintf(sqlbuf, "delete from %s where numbers='%d';",table,student.numbers);
}
else if(strcmp(table,"department") ==0)
{
printf("학과 코드를 입력하세요 : ");
scanf("%d",&department.namecode);
sprintf(sqlbuf, "delete from %s where namecode='%d';",table, department.namecode);
}
else if(strcmp(table,"lesson") ==0)
{
printf("과목번호를 입력하세요 : ");
scanf("%d",&lesson.numbers);
sprintf(sqlbuf, "delete from %s where numbers='%d';",table, lesson.numbers);
}
else if(strcmp(table,"lecture") ==0)
{
printf("강좌번호를 입력하세요 : ");
scanf("%d",&lecture.numbers);
sprintf(sqlbuf, "delete from %s where numbers='%d';",table, lecture.numbers);
}
else if(strcmp(table,"grade") ==0)
{
printf("학번을 입력하세요 : ");
scanf("%d",&grade.studentnumber);
sprintf(sqlbuf, "delete from %s where studentnumber='%d';",table, grade.studentnumber);
}
break;

// 데이터 변경.
case 4:
if(strcmp(table,"student") == 0)
{
printf("학번을 입력하세요 : ");
scanf("%d",&student.numbers);
printf("새로운 주소를 입력하세요 : ");
scanf("%s",&student.address);
sprintf(sqlbuf, "update %s set address='%s' where numbers='%d';",
table, student.address , student.numbers );
}
else if(strcmp(table,"department") == 0)
{
printf("학과 코드 입력 : ");
scanf("%d",&department.namecode);
printf("새로운 학과 사무실 전화번호를 입력하세요 : ");
scanf("%s",&department.phone);
sprintf(sqlbuf, "update %s set phone='%s' where namecode='%d';",
table, department.phone, department.namecode);
}
else if(strcmp(table,"lesson") == 0)
{
printf("과목 번호 입력 : ");
scanf("%d",&lesson.numbers);
printf("새로운 과목이름을 입력하세요 : ");
scanf("%s",&lesson.name);
sprintf(sqlbuf, "update %s set name='%s' where numbers='%d';",
table, lesson.name, lesson.numbers);
}
else if(strcmp(table,"lecture") == 0)
{
printf("강좌 번호 입력 : ");
scanf("%d",&lecture.numbers);
printf("새로운 강사를 입력하세요 : ");
scanf("%s",&lecture.lecture);
sprintf(sqlbuf, "update %s set lecture='%s' where numbers='%d';",
table, lecture.lecture, lecture.numbers);
}
else if(strcmp(table,"grade") == 0)
{
printf("학번 번호 입력 : ");
scanf("%d",&grade.studentnumber);
printf("새로운 학생이름를 입력하세요 : ");
scanf("%s",&grade.student);
sprintf(sqlbuf, "update %s set student='%s' where studentnumber='%d';",
table, grade.student, grade.studentnumber);
}
break;

// 데이터 베이스 초기화
case 5:
if(strcmp(table,"student") == 0)
{
sprintf(sqlbuf, "delete from %s;",table);
}
else if(strcmp(table,"department") == 0)
{
sprintf(sqlbuf, "delete from %s;",table);
}
else if(strcmp(table,"lesson") == 0)
{
sprintf(sqlbuf, "delete from %s;",table);
}
else if(strcmp(table,"lecture") == 0)
{
sprintf(sqlbuf, "delete from %s;",table);
}
else if(strcmp(table,"grade") == 0)
{
sprintf(sqlbuf, "delete from %s;",table);
}
break;

// 끝내기.
case 6:
strcpy(sqlbuf,"exit");
break;

default:
strcpy(sqlbuf,"help");
break;
}
}

int get_dyn_statement()
{
char *cp, linebuf[256];
int iter, plsql;

for (plsql = 0, iter = 1; ;)
{
if (iter == 1)
{
//printf("\n");
dyn_statement[0] = '\0';
}

selectmenu(linebuf);

// fgets(linebuf, sizeof linebuf, stdin);
// fflush(stdin);

cp = strrchr(linebuf, '\n');
if (cp && cp != linebuf)
*cp = ' ';
else if (cp == linebuf)
continue;

if ((strncmp(linebuf, "EXIT", 4) == 0) ||
(strncmp(linebuf, "exit", 4) == 0))
{
return -1;
}

else if (linebuf[0] == '?' ||
(strncmp(linebuf, "HELP", 4) == 0) ||
(strncmp(linebuf, "help", 4) == 0))
{
help();
iter = 1;
continue;
}

if (strstr(linebuf, "BEGIN") ||
(strstr(linebuf, "begin")))
{
plsql = 1;
}

strcat(dyn_statement, linebuf);

if ((plsql && (cp = strrchr(dyn_statement, '/'))) ||
(!plsql && (cp = strrchr(dyn_statement, ';'))))
{
*cp = '\0';
break;
}
else
{
iter++;
printf("%3d ", iter);
}
}
return 0;
}

void set_bind_variables()
{
int i, n;
char bind_var[64];

/* Describe any bind variables (input host variables) */
EXEC SQL WHENEVER SQLERROR DO sql_error();

bind_dp->N = MAX_ITEMS; /* Initialize count of array elements. */
EXEC SQL DESCRIBE BIND VARIABLES FOR S INTO bind_dp;

/* If F is negative, there were more bind variables
than originally allocated by sqlald(). */
if (bind_dp->F < 0)
{
printf ("\nToo many bind variables (%d), maximum is %d\n.",
-bind_dp->F, MAX_ITEMS);
return;
}

/* Set the maximum number of array elements in the
descriptor to the number found. */
bind_dp->N = bind_dp->F;

/* Get the value of each bind variable as a
* character string.
*
* C[i] contains the length of the bind variable
* name used in the SQL statement.
* S[i] contains the actual name of the bind variable
* used in the SQL statement.
*
* L[i] will contain the length of the data value
* entered.
*
* V[i] will contain the address of the data value
* entered.
*
* T[i] is always set to 1 because in this sample program
* data values for all bind variables are entered
* as character strings.
* ORACLE converts to the table value from CHAR.
*
* I[i] will point to the indicator value, which is
* set to -1 when the bind variable value is "null".
*/
for (i = 0; i < bind_dp->F; i++)
{
printf ("\nEnter value for bind variable %.*s: ",
(int)bind_dp->C[i], bind_dp->S[i]);
fgets(bind_var, sizeof bind_var, stdin);

/* Get length and remove the new line character. */
n = strlen(bind_var) - 1;

/* Set it in the descriptor. */
bind_dp->L[i] = n;

/* (re-)allocate the buffer for the value.
sqlald() reserves a pointer location for
V[i] but does not allocate the full space for
the pointer. */

bind_dp->V[i] = (char *) realloc(bind_dp->V[i],
(bind_dp->L[i] + 1));

/* And copy it in. */
strncpy(bind_dp->V[i], bind_var, n);

/* Set the indicator variable's value. */
if ((strncmp(bind_dp->V[i], "NULL", 4) == 0) ||
(strncmp(bind_dp->V[i], "null", 4) == 0))
*bind_dp->I[i] = -1;
else
*bind_dp->I[i] = 0;

/* Set the bind datatype to 1 for CHAR. */
bind_dp->T[i] = 1;
}
return;
}

void process_select_list()
{
int i, null_ok, precision, scale;

if ((strncmp(dyn_statement, "SELECT", 6) != 0) &&
(strncmp(dyn_statement, "select", 6) != 0))
{
select_dp->F = 0;
return;
}

/* If the SQL statement is a SELECT, describe the
select-list items. The DESCRIBE function returns
their names, datatypes, lengths (including precision
and scale), and NULL/NOT NULL statuses. */

select_dp->N = MAX_ITEMS;

EXEC SQL DESCRIBE SELECT LIST FOR S INTO select_dp;

/* If F is negative, there were more select-list
items than originally allocated by sqlald(). */
if (select_dp->F < 0)
{
printf ("\nToo many select-list items (%d), maximum is %d\n",
-(select_dp->F), MAX_ITEMS);
return;
}

/* Set the maximum number of array elements in the
descriptor to the number found. */
select_dp->N = select_dp->F;

/* Allocate storage for each select-list item.

sqlprc() is used to extract precision and scale
from the length (select_dp->L[i]).

sqlnul() is used to reset the high-order bit of
the datatype and to check whether the column
is NOT NULL.

CHAR datatypes have length, but zero precision and
scale. The length is defined at CREATE time.

NUMBER datatypes have precision and scale only if
defined at CREATE time. If the column
definition was just NUMBER, the precision
and scale are zero, and you must allocate
the required maximum length.

DATE datatypes return a length of 7 if the default
format is used. This should be increased to
9 to store the actual date character string.
If you use the TO_CHAR function, the maximum
length could be 75, but will probably be less
(you can see the effects of this in SQL*Plus).

ROWID datatype always returns a fixed length of 18 if
coerced to CHAR.

LONG and
LONG RAW datatypes return a length of 0 (zero),
so you need to set a maximum. In this example,
it is 240 characters.

*/

printf ("\n");
for (i = 0; i < select_dp->F; i++)
{
/* Turn off high-order bit of datatype (in this example,
it does not matter if the column is NOT NULL). */
sqlnul ((unsigned short *)&(select_dp->T[i]), (unsigned short *)&(select_dp->T[i]), &null_ok);

switch (select_dp->T[i])
{
case 1 : /* CHAR datatype: no change in length
needed, except possibly for TO_CHAR
conversions (not handled here). */
break;
case 2 : /* NUMBER datatype: use sqlprc() to
extract precision and scale. */
sqlprc ((unsigned long *)&(select_dp->L[i]), &precision, &scale);
/* Allow for maximum size of NUMBER. */
if (precision == 0) precision = 40;
/* Also allow for decimal point and
possible sign. */
/* convert NUMBER datatype to FLOAT if scale > 0,
INT otherwise. */
if (scale > 0)
select_dp->L[i] = sizeof(float);
else
select_dp->L[i] = sizeof(int);
break;

case 8 : /* LONG datatype */
select_dp->L[i] = 240;
break;

case 11 : /* ROWID datatype */
select_dp->L[i] = 18;
break;

case 12 : /* DATE datatype */
select_dp->L[i] = 9;
break;

case 23 : /* RAW datatype */
break;

case 24 : /* LONG RAW datatype */
select_dp->L[i] = 240;
break;
}
/* Allocate space for the select-list data values.
sqlald() reserves a pointer location for
V[i] but does not allocate the full space for
the pointer. */

if (select_dp->T[i] != 2)
select_dp->V[i] = (char *) realloc(select_dp->V[i],
select_dp->L[i] + 1);
else
select_dp->V[i] = (char *) realloc(select_dp->V[i],
select_dp->L[i]);

/* Print column headings, right-justifying number
column headings. */
if (select_dp->T[i] == 2)
if (scale > 0)
printf ("%.*s ", select_dp->L[i]+3, select_dp->S[i]);
else
printf ("%.*s ", select_dp->L[i], select_dp->S[i]);
else
printf ("%-.*s ", select_dp->L[i], select_dp->S[i]);

/* Coerce ALL datatypes except for LONG RAW and NUMBER to
character. */
if (select_dp->T[i] != 24 && select_dp->T[i] != 2)
select_dp->T[i] = 1;

/* Coerce the datatypes of NUMBERs to float or int depending on
the scale. */
if (select_dp->T[i] == 2)
if (scale > 0)
select_dp->T[i] = 4; /* float */
else
select_dp->T[i] = 3; /* int */
}
printf ("\n\n");

/* FETCH each row selected and print the column values. */
EXEC SQL WHENEVER NOT FOUND GOTO end_select_loop;

for (;;)
{
EXEC SQL FETCH C USING DESCRIPTOR select_dp;

/* Since each variable returned has been coerced to a
character string, int, or float very little processing
is required here. This routine just prints out the
values on the terminal. */
for (i = 0; i < select_dp->F; i++)
{
if (*select_dp->I[i] < 0)
if (select_dp->T[i] == 4)
printf ("%-*c ",(int)select_dp->L[i]+3, ' ');
else
printf ("%-*c ",(int)select_dp->L[i], ' ');
else
if (select_dp->T[i] == 3) /* int datatype */
printf ("%*d ", (int)select_dp->L[i],
*(int *)select_dp->V[i]);
else if (select_dp->T[i] == 4) /* float datatype */
printf ("%*.2f ", (int)select_dp->L[i],
*(float *)select_dp->V[i]);
else /* character string */
printf ("%-*.*s ", (int)select_dp->L[i],
(int)select_dp->L[i], select_dp->V[i]);
}
printf ("\n");
}
end_select_loop:
return;
}

void help()
{
puts("\n\nEnter a SQL statement or a PL/SQL block at the SQL> prompt.");
puts("Statements can be continued over several lines, except");
puts("within string literals.");
puts("Terminate a SQL statement with a semicolon.");
puts("Terminate a PL/SQL block (which can contain embedded semicolons)");
puts("with a slash (/).");
puts("Typing \"exit\" (no semicolon needed) exits the program.");
puts("You typed \"?\" or \"help\" to get this message.\n\n");
}

void sql_error()
{
/* ORACLE error handler */
printf ("\n\n%.70s\n",sqlca.sqlerrm.sqlerrmc);
if (parse_flag)
printf
("Parse error at character offset %d in SQL statement.\n",
sqlca.sqlerrd[4]);

EXEC SQL WHENEVER SQLERROR CONTINUE;
EXEC SQL ROLLBACK WORK;
longjmp(jmp_continue, 1);
}

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.