ANSImakefiledemo
ORACLEmakefiledemo
ANSI
makefile
dm02_ansi4: @echo ‘dm02_ansi4.pc start…’ proc iname=dm02_ansi4.pc oname=dm02_ansi4.c sqlcheck=full mode=ansi @echo ‘dm02_ansi4.pc ok…’ gcc dm02_ansi4.c -o dm02_ansi4 -I
O
R
A
C
L
E
H
O
M
E
/
p
r
e
c
o
m
p
/
p
u
b
l
i
c
−
L
{ORACLE_HOME}/precomp/public -L
ORACLEHOME/precomp/public−L{ORACLE_HOME}/lib -lclntsh @echo ‘gcc ok…’
demo
#include <stdio.h>
#include <string.h>
#include <sqlca.h>
#define MAX_VAR_LEN 30
#define MAX_NAME_LEN 80
exec sql begin declare section
;
char *serverid
= "c##scott/root";
char input_SqlStatements
[100];
char current_date
[20];
exec sql end declare section
;
void doerr();
int connet();
void process_input();
void process_output();
int main()
{
exec sql whenever sqlerror
do doerr();
connet();
exec sql allocate descriptor
'input_descriptor';
exec sql allocate descriptor
'output_descriptor';
for( ; ; )
{
printf("\n请输入动态SQL语句(EXIT:退出):\n");
gets(input_SqlStatements
);
if(0 == strncmp(input_SqlStatements
, "EXIT" , 4) || 0 == strncmp(input_SqlStatements
, "exit" , 4))
break;
exec sql prepare mydynamicSql from
:input_SqlStatements
;
exec sql declare mycursor cursor
for mydynamicSql
;
process_input();
exec sql open mycursor
using descriptor
'input_descriptor';
if(0 == strncmp(input_SqlStatements
, "SELECT" , 6) , 0 == strncmp(input_SqlStatements
, "select" , 6))
{
process_output();
}
exec sql close mycursor
;
}
exec sql deallocate descriptor
'input_descriptor';
exec sql deallocate descriptor
'output_descriptor';
exec sql commit work release
;
puts("谢谢使用ANSI动态SQL!\n");
return 0;
}
void doerr()
{
char szerrbuf
[120];
size_t outputlen
, inputlen
= 120;
unsigned int ret
= 0;
EXEC SQL WHENEVER SQLERROR CONTINUE
;
ret
= sqlgls(szerrbuf
, &inputlen
, &outputlen
);
printf("SQL:%.*s\n", inputlen
, szerrbuf
);
printf("提示:%.*s\n", sqlca
.sqlerrm
.sqlerrml
, sqlca
.sqlerrm
.sqlerrmc
);
EXEC SQL ROLLBACK WORK RELEASE
;
exit(1);
}
void process_input()
{
int i
;
exec sql begin declare section
;
int input_count
;
int input_type
;
int input_len
;
char input_buffer
[MAX_VAR_LEN
];
char name
[MAX_NAME_LEN
];
int occurs
;
exec sql end declare section
;
exec sql describe input mydynamicSql
using descriptor
'input_descriptor';
exec sql get descriptor
'input_descriptor' :input_count
= count
;
}
void process_output()
{
int i
;
EXEC SQL BEGIN DECLARE SECTION
;
int output_count
;
int output_type
;
int output_len
;
char output_buffer
[MAX_VAR_LEN
];
short output_indicator
;
char name
[MAX_NAME_LEN
];
int occurs
;
EXEC SQL END DECLARE SECTION
;
exec sql describe output mydynamicSql
using descriptor
'output_descriptor';
exec sql get descriptor
'output_descriptor' :output_count
= count
;
output_type
= 12;
for(i
= 0 ; i
!= output_count
; ++i
)
{
occurs
= i
+ 1;
output_len
= MAX_VAR_LEN
;
exec sql set descriptor
'output_descriptor' value
:occurs
type
= :output_type
, length
= :output_len
;
exec sql get descriptor
'output_descriptor' value
:occurs
:name
= name
;
printf("\t%s" , name
);
}
printf("\n");
exec sql whenever
not found
do break;
for( ; ; )
{
exec sql fetch mycursor into descriptor
'output_descriptor';
for(i
= 0 ; i
< output_count
; ++i
)
{
occurs
= i
+1;
exec sql get descriptor
'output_descriptor' VALUE
:occurs
:output_buffer
= DATA
, :output_indicator
= INDICATOR
;
if(-1 == output_indicator
)
printf("\t%s", " ");
else
printf("\t%s" , output_buffer
);
}
printf("\n");
}
}
void connet()
{
int ret
= 0;
EXEC SQL CONNECT
:usrname IDENTIFIED BY
:passwd USING
:serverid
;
if (sqlca
.sqlcode
!= 0)
{
ret
= sqlca
.sqlcode
;
printf("sqlca.sqlcode: err:%d \n", sqlca
.sqlcode
);
return ;
}
else
{
printf("connect ok...\n");
}
}
ORACLE
makefile
dm03
all: dm03_oracle4
dm03_oracle4: @echo ‘dm03_oracle4.pc start…’ proc iname=dm03_oracle4.pc oname=dm03_oracle4.c @echo ‘dm03_oracle4.pc ok…’ gcc dm03_oracle4.c -o dm03_oracle4 -I
O
R
A
C
L
E
H
O
M
E
/
p
r
e
c
o
m
p
/
p
u
b
l
i
c
−
L
{ORACLE_HOME}/precomp/public -L
ORACLEHOME/precomp/public−L{ORACLE_HOME}/lib -lclntsh @echo ‘gcc ok…’
clean: @rm dm03_oracle4 @rm dm03_oracle4.c
dm04 all: dm04_myselforacle4
dm04_myselforacle4: @echo ‘dm04_myselforacle4.pc start…’ proc iname=dm04_myselforacle4.pc oname=dm04_myselforacle4.c @echo ‘dm04_myselforacle4.pc ok…’ gcc dm04_myselforacle4.c -o dm04_myselforacle4 -I
O
R
A
C
L
E
H
O
M
E
/
p
r
e
c
o
m
p
/
p
u
b
l
i
c
−
L
{ORACLE_HOME}/precomp/public -L
ORACLEHOME/precomp/public−L{ORACLE_HOME}/lib -lclntsh @echo ‘gcc ok…’
clean: @rm dm04_myselforacle4 @rm dm04_myselforacle4.c
demo
#include <stdio.h>
#include <string.h>
#include <setjmp.h>
#include <sqlda.h>
#include <stdlib.h>
#include <sqlcpr.h>
#define SQL_SINGLE_RCTX ((void *)0)
#define MAX_ITEMS 40
#define MAX_VNAME_LEN 30
#define MAX_INAME_LEN 30
#ifndef NULL
#define NULL 0
#endif
#if defined(__STDC__)
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);
#else
void sql_error();
int oracle_connect();
int alloc_descriptors();
int get_dyn_statement();
void set_bind_variables();
void process_select_list();
void help();
#endif
char *dml_commands
[] = {"SELECT", "select", "INSERT", "insert",
"UPDATE", "update", "DELETE", "delete"};
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
;
jmp_buf jmp_continue
;
int parse_flag
= 0;
void main()
{
int i
;
if (oracle_connect() != 0)
exit(1);
if (alloc_descriptors(MAX_ITEMS
, MAX_VNAME_LEN
, MAX_INAME_LEN
) != 0)
exit(1);
for (;;)
{
(void) setjmp(jmp_continue
);
if (get_dyn_statement() != 0)
break;
EXEC SQL WHENEVER SQLERROR DO
sql_error();
parse_flag
= 1;
EXEC SQL PREPARE S FROM
:dyn_statement
;
parse_flag
= 0;
EXEC SQL DECLARE C CURSOR FOR S
;
set_bind_variables();
EXEC SQL OPEN C USING DESCRIPTOR bind_dp
;
process_select_list();
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;
}
}
}
for (i
= 0; i
< MAX_ITEMS
; i
++)
{
if (bind_dp
->V
[i
] != (char *) 0)
free(bind_dp
->V
[i
]);
free(bind_dp
->I
[i
]);
if (select_dp
->V
[i
] != (char *) 0)
free(select_dp
->V
[i
]);
free(select_dp
->I
[i
]);
}
SQLSQLDAFree(SQL_SINGLE_RCTX
, bind_dp
);
SQLSQLDAFree(SQL_SINGLE_RCTX
, select_dp
);
EXEC SQL WHENEVER SQLERROR CONTINUE
;
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
;
VARCHAR username
[128];
VARCHAR password
[32];
EXEC SQL END DECLARE SECTION
;
printf("\nusername: ");
fgets((char *) username
.arr
, sizeof username
.arr
, stdin);
username
.arr
[strlen((char *) username
.arr
)-1] = '\0';
username
.len
= (unsigned short)strlen((char *) username
.arr
);
printf("password: ");
fgets((char *) password
.arr
, sizeof password
.arr
, stdin);
password
.arr
[strlen((char *) password
.arr
) - 1] = '\0';
password
.len
= (unsigned short)strlen((char *) password
.arr
);
EXEC SQL WHENEVER SQLERROR GOTO connect_error
;
EXEC SQL CONNECT
:username IDENTIFIED BY
:password
;
printf("\nConnected to ORACLE as user %s.\n", username
.arr
);
return 0;
connect_error
:
fprintf(stderr, "Cannot connect to ORACLE as user %s\n", username
.arr
);
return -1;
}
alloc_descriptors(size
, max_vname_len
, max_iname_len
)
int size
;
int max_vname_len
;
int max_iname_len
;
{
int i
;
if ((bind_dp
=
SQLSQLDAAlloc(SQL_SINGLE_RCTX
, size
, max_vname_len
, max_iname_len
)) ==
(SQLDA
*) 0)
{
fprintf(stderr,
"Cannot allocate memory for bind descriptor.");
return -1;
}
if ((select_dp
=
SQLSQLDAAlloc
(SQL_SINGLE_RCTX
, size
, max_vname_len
, max_iname_len
)) ==
(SQLDA
*) 0)
{
fprintf(stderr,
"Cannot allocate memory for select descriptor.");
return -1;
}
select_dp
->N
= MAX_ITEMS
;
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 get_dyn_statement()
{
char *cp
, linebuf
[256];
int iter
, plsql
;
for (plsql
= 0, iter
= 1; ;)
{
if (iter
== 1)
{
printf("\nSQL> ");
dyn_statement
[0] = '\0';
}
fgets(linebuf
, sizeof linebuf
, 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];
EXEC SQL WHENEVER SQLERROR DO
sql_error();
bind_dp
->N
= MAX_ITEMS
;
EXEC SQL DESCRIBE BIND VARIABLES FOR S INTO bind_dp
;
if (bind_dp
->F
< 0)
{
printf
("\nToo many bind variables (%d), maximum is %d\n.",
-bind_dp
->F
, MAX_ITEMS
);
return;
}
bind_dp
->N
= bind_dp
->F
;
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);
n
= strlen(bind_var
) - 1;
bind_dp
->L
[i
] = n
;
bind_dp
->V
[i
] = (char *) realloc(bind_dp
->V
[i
],
(bind_dp
->L
[i
] + 1));
strncpy(bind_dp
->V
[i
], bind_var
, n
);
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;
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;
}
select_dp
->N
= MAX_ITEMS
;
EXEC SQL DESCRIBE SELECT LIST FOR S INTO select_dp
;
if (select_dp
->F
< 0)
{
printf
("\nToo many select-list items (%d), maximum is %d\n",
-(select_dp
->F
), MAX_ITEMS
);
return;
}
select_dp
->N
= select_dp
->F
;
printf
("\n");
for (i
= 0; i
< select_dp
->F
; i
++)
{
char title
[MAX_VNAME_LEN
];
SQLColumnNullCheck
(0, (unsigned short *)&(select_dp
->T
[i
]),
(unsigned short *)&(select_dp
->T
[i
]), &null_ok
);
switch (select_dp
->T
[i
])
{
case 1 :
break;
case 2 :
SQLNumberPrecV6( SQL_SINGLE_RCTX
,
(unsigned long *)&(select_dp
->L
[i
]), &precision
, &scale
);
if (precision
== 0) precision
= 40;
if (scale
> 0)
select_dp
->L
[i
] = sizeof(float);
else
select_dp
->L
[i
] = sizeof(int);
break;
case 8 :
select_dp
->L
[i
] = 240;
break;
case 11 :
select_dp
->L
[i
] = 18;
break;
case 12 :
select_dp
->L
[i
] = 9;
break;
case 23 :
break;
case 24 :
select_dp
->L
[i
] = 240;
break;
}
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
]);
memset(title
, ' ', MAX_VNAME_LEN
);
strncpy(title
, select_dp
->S
[i
], select_dp
->C
[i
]);
if (select_dp
->T
[i
] == 2)
if (scale
> 0)
printf
("%.*s ", select_dp
->L
[i
]+3, title
);
else
printf
("%.*s ", select_dp
->L
[i
], title
);
else
printf("%-.*s ", select_dp
->L
[i
], title
);
if (select_dp
->T
[i
] != 24 && select_dp
->T
[i
] != 2)
select_dp
->T
[i
] = 1;
if (select_dp
->T
[i
] == 2)
if (scale
> 0)
select_dp
->T
[i
] = 4;
else
select_dp
->T
[i
] = 3;
}
printf
("\n\n");
EXEC SQL WHENEVER NOT FOUND GOTO end_select_loop
;
for (;;)
{
EXEC SQL FETCH C USING DESCRIPTOR select_dp
;
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)
printf
("%*d ", (int)select_dp
->L
[i
],
*(int *)select_dp
->V
[i
]);
else if (select_dp
->T
[i
] == 4)
printf
("%*.2f ", (int)select_dp
->L
[i
],
*(float *)select_dp
->V
[i
]);
else
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()
{
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);
}
dm04
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <setjmp.h>
#include <sqlcpr.h>
#include <sqlda.h>
#include <sqlca.h>
#define MAX_ITEMS 40
#define MAX_VNAME_LEN 30
#define MAX_INAME_LEN 30
void connect();
void sql_error();
void alloc_descriptors(int , int , int);
void dealloc_descriptors();
void set_bind_variables();
void process_select_list();
SQLDA
* bind_dp
;
SQLDA
* select_dp
;
exec sql begin declare section
;
char sql_stat
[100];
char current_date
[20];
exec sql end declare section
;
int main()
{
exec sql whenever sqlerror
do sql_error();
connect2();
alloc_descriptors(MAX_ITEMS
, MAX_VNAME_LEN
, MAX_INAME_LEN
);
for( ; ; )
{
printf("请输入动态SQL语句(exit:退出):");
gets(sql_stat
);
if(0 == strncmp(sql_stat
, "exit" , 4) || 0 == strncmp(sql_stat
, "EXIT" , 4))
break;
exec sql prepare s from
:sql_stat
;
exec sql declare c cursor
for s
;
if(0 != sqlca
.sqlcode
)
continue;
set_bind_variables();
exec sql open c
using descriptor bind_dp
;
if(0 == strncmp(sql_stat
, "select" , 6) || 0 == strncmp(sql_stat
, "SELECT" , 6))
{
process_select_list();
}
exec sql close c
;
}
dealloc_descriptors();
exec sql commit work release
;
puts("谢谢使用Oracle动态SQL方法四!\n");
return 0;
}
void connect2()
{
exec sql begin declare section
;
char username
[20] , password
[20] , server
[20];
exec sql end declare section
;
printf("username:");
gets(username
);
printf("password: ");
gets(password
);
printf("server:");
gets(server
);
EXEC SQL CONNECT
:username identified by
:password
using :server
;
}
void sql_error()
{
printf("%.*s\n" , sqlca
.sqlerrm
.sqlerrml
, sqlca
.sqlerrm
.sqlerrmc
);
}
void alloc_descriptors(int size
, int max_vname_len
, int max_iname_len
)
{
int i
;
bind_dp
= SQLSQLDAAlloc(0 , size
, MAX_VNAME_LEN
, MAX_INAME_LEN
);
select_dp
= SQLSQLDAAlloc(0 , size
, MAX_VNAME_LEN
, MAX_INAME_LEN
);
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);
}
}
void dealloc_descriptors()
{
int i
;
for(i
= 0 ; i
!= MAX_ITEMS
; ++i
)
{
if(bind_dp
->V
[i
] != (char*)0)
free(bind_dp
->V
[i
]);
free(bind_dp
->I
[i
]);
if(select_dp
->V
[i
] != (char*)0)
free(select_dp
->V
[i
]);
free(select_dp
->I
[i
]);
}
SQLSQLDAFree(0 , bind_dp
);
SQLSQLDAFree(0 , select_dp
);
}
void set_bind_variables()
{
int i
;
char bind_var
[64];
bind_dp
->N
= MAX_ITEMS
;
exec sql describe bind variables
for s into bind_dp
;
bind_dp
->N
= bind_dp
->F
;
for(i
= 0 ; i
!= bind_dp
->F
; ++i
)
{
printf("请输入绑定变量%.*s的值:" , (int)bind_dp
->C
[i
] , bind_dp
->S
[i
]);
gets(bind_var
);
bind_dp
->L
[i
] = strlen(bind_var
);
bind_dp
->V
[i
] = (char*)realloc(bind_dp
->V
[i
] , bind_dp
->L
[i
] + 1);
strcpy(bind_dp
->V
[i
] , bind_var
);
if(0 == strncmp(bind_var
, "NULL" , 4) || 0 == strncmp(bind_var
, "null" , 4))
*bind_dp
->I
[i
] = -1;
else
*bind_dp
->I
[i
] = 0;
bind_dp
->T
[i
] = 1;
}
}
void process_select_list()
{
int i
, null_ok
, precision
, scale
;
char title
[MAX_VNAME_LEN
];
select_dp
->N
= MAX_ITEMS
;
exec sql describe select list
for s into select_dp
;
select_dp
->N
= select_dp
->F
;
for(i
= 0 ; i
!= select_dp
->F
; ++i
)
{
SQLColumnNullCheck(0 , (unsigned short*)&select_dp
->T
[i
]
, (unsigned short*)&select_dp
->T
[i
] , &null_ok
);
switch(select_dp
->T
[i
])
{
case 2:
SQLNumberPrecV6(0 , (unsigned long *)&select_dp
->L
[i
] , &precision
, &scale
);
if(scale
> 0)
select_dp
->L
[i
] = sizeof(float);
else
select_dp
->L
[i
] = sizeof(int);
break;
case 12:
select_dp
->L
[i
] = 9;
break;
}
if(2 != select_dp
->T
[i
])
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
]);
memset(title
, ' ' , MAX_VNAME_LEN
);
strncpy(title
, select_dp
->S
[i
] , select_dp
->C
[i
]);
if(2 == select_dp
->T
[i
])
if(scale
> 0)
printf("\t%.*s" , select_dp
->L
[i
] + 3, title
);
else
printf("\t%.*s" , select_dp
->L
[i
] , title
);
else
printf("\t%-.*s" , select_dp
->L
[i
] , title
);
if( 2 == select_dp
->T
[i
])
{
if(scale
> 0)
select_dp
->T
[i
] = 4;
else
select_dp
->T
[i
] = 3;
}
else
select_dp
->T
[i
] = 1;
}
printf("\n");
exec sql whenever
not found
do break;
for( ; ; )
{
exec sql fetch c
using descriptor select_dp
;
for( i
= 0 ; i
!= select_dp
->F
; ++i
)
{
if(*select_dp
->I
[i
] < 0){
printf("\tNULL");
}else{
if(3 == select_dp
->T
[i
]) {
printf("\t%d" , *(int*)select_dp
->V
[i
]);
}else if(4 == select_dp
->T
[i
]){
printf("\t%8.2f" , *(float*)select_dp
->V
[i
]);
}else{
printf("\t%.*s" , select_dp
->L
[i
] , select_dp
->V
[i
]);
}
}
}
printf("\n");
}
}