我编写了一个代码将数据插入到表all_date_time中,但格式似乎不对总是插入不成功
all_date_time表中的字段情况:
名称 数据类型 长度 可空
VARCHARFIELD VARCHAR 20 是
DATEFIELD DATE 4 是
TIMEFIELD TIME 3 是
TIMESTAMPFIELD TIMESTAMPO 10 是
部分代码
EXEC SQL BEGIN DECLARE SECTION;
char time_stamp[30];
char date_field[20];
char time_field[20];
char varchar_field[20];
char st[80];
EXEC SQL END DECLARE SECTION;
strcpy(time_stamp,"\"no blanks\"";
strcpy(date_field,"1988-12-25";
strcpy(time_field,"17.12.30.000000";
strcpy(varchar_field,"1988-12-25-17.12.30.000000";
EXEC SQL INSERT INTO all_date_time(varcharField,dateField,
timeField,timestampField)VALUES(:time_stamp,
:date_field,:time_field,:varchar_field);
if(sqlca.sqlcode!=0)
{
printf("Error inserting row.SQLCODE=%d.",sqlca.sqlcode);
}
else
{
printf("Successfully inserted new row";
}
运行后显示表中数据:
Error inserting row.SQLCODE=-180. SELECT * FROM all_date_time
varcharField dateField timeField timeStampField
--转自