database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
ㆍPostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
PostgreSQL Q&A 1090 게시물 읽기
No. 1090
왜 에러가 날까요.
작성자
이민우
작성일
2000-05-24 16:52
조회수
12,230

3 #include "/usr/local/pgsql/include/libpq/fe.h"

4 PGconn * p_connection;

5 PGresult * p_result;

6

7 #define MAX_QUERY_LENGTH 600

8

9 char * dbname;

10 char * password;

11 char * host;

12 char * user;

13 char * port;

14

15 int Insert(char *);

16 int Select(char *);

17 void Connect();

18

19 void main()

20 {

21 char *i2;

22

23 i2 = (char *)malloc(MAX_QUERY_LENGTH);

24

25 snprintf(i2, MAX_QUERY_LENGTH,"INSERT INTO tcphdr (sid,cid,th_sport,th_dport,th_flags,th_win,th_urp) VALUES ('%i','%i','%i','%i','%i','%i','%i')",

26 1, 99999, 9999,9999,0,0,99,99);

27

28 Connect();

29

30 Insert(i2); free(i2);

31 }

32

33 int Insert(char * query)

34 {

35 int result = 0;

36

37 p_result = PQexec(p_connection,query);

38 if(!(PQresultStatus(p_result) != PGRES_COMMAND_OK))

39 {

40 result = 1;

41 }

42 if(!result)

43 {

44 ErrorMessage("Postgres insert Error %s\n",PQerrorMessage(p_connection));

45 }

46

47 if (result) { printf("(%s) executed\n", query); }

48 else { printf("(%s) failed\n", query); }

49

50 return result;

51 }

52

53 int Select(char * query)

54 {

55 int result = 0;

56

57 p_result = PQexec(p_connection,query);

58 if((PQresultStatus(p_result) == PGRES_TUPLES_OK))

59 {

60 if(PQntuples(p_result))

61 {

62 if((PQntuples(p_result)) > 1)

63 {

64 ErrorMessage("ERROR (%s) returned more than one result\n", query);

65 result = 0;

66 }

67 else

68 {

69 result = atoi(PQgetvalue(p_result,0,0));

70 }

71 }

72 }

73 if(!result)

74 {

75 ErrorMessage("Error: %s\n",PQerrorMessage(p_connection));

76 }

77

78 return result;

79 }

80

81

82 void Connect()

83 {

84 strncpy(host,"localhost",10);

85 strncpy(port,"5432",5);

86 strncpy(dbname,"snort",6);

87 strncpy(user,"root",5);

88 strncpy(password,"wsp1005",8);

89

90 p_connection = PQsetdbLogin(host,port,NULL,NULL,dbname,user,password);

91 //p_connection = PQsetdbLogin('localhost','5432',NULL,NULL,'snort','root','wsp1005');

92 if (PQstatus(p_connection) == CONNECTION_BAD)

93 {

94 PQfinish(p_connection);

95 FatalError("Connection to database %s failed\n", "snort");

96 }

97 }

 

에러내용...

dbtest.c: In function `main':

dbtest.c:4: warning: return type of `main' is not `int'

/tmp/ccRthada.o: In function `Insert':

/tmp/ccRthada.o(.text+0x80): undefined reference to `PQexec'

/tmp/ccRthada.o(.text+0x95): undefined reference to `PQresultStatus'

/tmp/ccRthada.o(.text+0xb7): undefined reference to `PQerrorMessage'

/tmp/ccRthada.o(.text+0xc7): undefined reference to `ErrorMessage'

/tmp/ccRthada.o: In function `Select':

/tmp/ccRthada.o(.text+0x11c): undefined reference to `PQexec'

/tmp/ccRthada.o(.text+0x131): undefined reference to `PQresultStatus'

[Top]
No.
제목
작성자
작성일
조회
1101이런경우 처음이야?????????
이승현
2000-05-25
12179
1102┕>Re: 이런경우 처음이야?????????
정재익
2000-05-25 11:53:35
13386
1103 ┕>Re: Re: 이런경우 처음이야?????????
이승현
2000-05-25 12:07:43
12599
1104  ┕>Re: Re: Re: 이런경우 처음이야?????????
정재익
2000-05-25 12:33:06
13490
1097TEXT 데이터 타입에 다음의 데이터를 인서트하려 하는데 ERROR가 나서요???
이민우
2000-05-25
13550
1098┕>Re: TEXT 데이터 타입에 다음의 데이터를 인서트하려 하는데 ERROR가 나서요???
정재익
2000-05-25 01:56:01
13766
1114 ┕>Re: Re: TEXT 데이터 타입에 다음의 데이터를 인서트하려 하는데 ERROR가 나서요???
이민우
2000-05-28 22:44:05
15449
1093Postgres 6.5에서 Sort 및 Insert가 안되여~~~
이승현
2000-05-25
13068
1094┕>Re: Postgres 6.5에서 Sort 및 Insert가 안되여~~~
정재익
2000-05-24 22:02:09
13489
1090왜 에러가 날까요.
이민우
2000-05-24
12230
1091┕>Re: 왜 에러가 날까요.
정재익
2000-05-24 18:20:00
12777
1096 ┕>정재익님 감사합니다.
이민우
2000-05-25 01:29:29
13561
1089백업 한글 안 깨어짐 발견.. -_-
김유신
2000-05-24
12666
1092┕>Re: 백업 한글 안 깨어짐 발견.. -_-
정재익
2000-05-24 19:08:21
13358
1088백업시 한글 깨어짐이 똑같이 보여요
김유신
2000-05-24
12604
1086백업에서 이상하게 나오는 한글
김유신
2000-05-24
12136
1087┕>Re: 백업에서 이상하게 나오는 한글
정재익
2000-05-24 14:10:56
12292
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.018초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다