-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDebit_Credit_Of_A_Branch.pgc
executable file
·80 lines (58 loc) · 1.91 KB
/
Debit_Credit_Of_A_Branch.pgc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*GET TOTAL DEBIT AND CREDIT OF A PARTICULAR BRANCH IN A BANK
#include <stdio.h>
#include <string.h>
#include <libpq-fe.h>
int main()
{
EXEC SQL BEGIN DECLARE SECTION;
char ifc[11] ,ifsc[15] , date[50];
int i;
long int cr , de ;
char query[500] ,buf[200],query1[200];
EXEC SQL END DECLARE SECTION;
printf("Enter ifsc code");
scanf("%s",&ifsc);
printf("Enter date");
scanf("%s",&date);
printf("Total credit:");
strcpy(query," select ifsc_code, sum(amount) from transactions where narration='CREDIT' AND ifsc_code =");
sprintf(buf,"%s",ifsc);
strcat(query,buf);
strcat(query," AND date(Time_stamp) =");
sprintf(buf,"%s",date);
strcat(query,buf);
strcat(query," group by ifsc_code");
printf("%s\n",query);
EXEC SQL CONNECT TO "201551094@10.100.1.62" USER "201551094" IDENTIFIED BY "**";
EXEC SQL set search_path to bank;
EXEC SQL PREPARE query_prep FROM :query;
EXEC SQL DECLARE emp_cursor CURSOR FOR query_prep;
EXEC SQL OPEN emp_cursor;
while(sqlca.sqlcode==0)
{
EXEC SQL FETCH FROM emp_cursor INTO :ifc, :cr;
//printf("%s",ifc);
printf("IFSC: %10s,%10d \n ",ifc,cr);
}
printf("Total debit:");
strcpy(query1," select ifsc_code, sum(amount) from transactions where narration='DEBIT' AND ifsc_code =");
sprintf(buf,"%s",ifsc);
strcat(query1,buf);
strcat(query1," AND date(Time_stamp) =");
sprintf(buf,"%s",date);
strcat(query1,buf);
strcat(query1," group by ifsc_code");
printf("%s\n",query);
EXEC SQL set search_path to bank;
EXEC SQL PREPARE query_prep FROM :query1;
EXEC SQL DECLARE emp_cursor1 CURSOR FOR query_prep;
EXEC SQL OPEN emp_cursor1;
while(sqlca.sqlcode==0)
{
EXEC SQL FETCH FROM emp_cursor INTO :ifc, :cr;
if(ifc[0]!='/0');
//printf("%s",ifc);
printf("IFSC: %10s,%10d \n ",ifc,cr);
}
return 0;
}