这个就是自动生成的模板,对照楼上,是一一对应的。
手动写是非常繁琐的,容易写错。
【 在 Bernstein 的大作中提到: 】
: 每个结构关联两个函数,streamin和streamout,一个负责反序列化另一个负责序列化
: 把对应的函数传递给你的struct_to_json
:
T_PkgType CUT_PI_EXIT_tpl[]={
{CH_INT64,sizeof(INT64),"streaming_session_id",0,-1},//最后这个-1,是offset,第一个元素当然应该是0,-1就是个标志,未计算offset的,任何函数引用这个结构,必须先行计算offset。计算完成,它就是0了。
{CH_INT,sizeof(int),"data_version"},
{CH_INT64,sizeof(INT64),"txn_class"},
{CH_INT64,sizeof(INT64),"txn_revision"},
{CH_INT64,sizeof(INT64),"txn_ssn_a"},
{CH_INT64,sizeof(INT64),"txn_ssn_b"},
{CH_INT64,sizeof(INT64),"ols_txn_type"},
{CH_JUL,sizeof(INT4),"settlement_date","YYYYMMDD"},//结算日期,32bit整数,是一个自1899.12.31以来的天数。序列化时,转换成指定的格式。
{CH_INT,sizeof(int),"application_validation_flags"},
{CH_CHAR,31,"host_name"},
{CH_SHORT,sizeof(short),"multipart_txn_count"},
{CH_SHORT,sizeof(short),"issuer_abort_reason"},
{CH_INT64,sizeof(INT64),"acquirer_id"},
{CH_INT64,sizeof(INT64),"destination_participant_id"},
{CH_SHORT,sizeof(short),"account_type"},
{CH_SHORT,sizeof(short),"portioned_txn_flag"},
{CH_INT64,sizeof(INT64),"format_version"},
{CH_TIME,sizeof(INT64),"txn_date_time","YYYYMMDDHH24:MI:SS"},
{CH_INT64,sizeof(INT64),"source_participant_id"},
{CH_INT64,sizeof(INT64),"device_id"},
{CH_CNUM,22,"sam_id"},
{CH_INT64,sizeof(INT64),"udsn"},
{CH_INT64,sizeof(INT64),"service_participant_id"},
{CH_INT64,sizeof(INT64),"device_location"},
{CH_INT64,sizeof(INT64),"device_ssn"},
{CH_JUL,sizeof(INT4),"business_date","YYYYMMDD"},
{CH_SHORT,sizeof(short),"transaction_status"},
{CH_INT,sizeof(int),"cd_set_version"},
{CH_JUL,sizeof(INT4),"reconciliation_date","YYYYMMDD"},
{CH_SHORT,sizeof(short),"ud_type"},
{CH_SHORT,sizeof(short),"ud_subtype"},
{CH_SHORT,sizeof(short),"device_home_depot"},
{CH_CHAR,8,"mass_installation_id"},
{CH_CHAR,2,"iss_exception_proc_abrtd"},
{CH_CHAR,2,"iss_exception"},
{CH_CHAR,2,"iss_txn_reflection"},
{CH_CHAR,2,"cch_flags_txn_portion"},
{CH_CHAR,2,"cch_flags_txn_summarised"},
{CH_CHAR,2,"cch_flags_txn_forwarded"},
{CH_CHAR,2,"cch_flags_txn_apportioned"},
{CH_CHAR,2,"cch_txn_good_for_summaries"},
{CH_CHAR,2,"cch_no_further_proc"},
{CH_CHAR,2,"cch_exception"},
{CH_CHAR,2,"cch_txn_not_to_issuer"},
{CH_CHAR,2,"cch_txn_approved"},
{CH_CHAR,481,"exception_list"},
{CH_INT64,sizeof(INT64),"card_issuer_id"},
{CH_INT64,sizeof(INT64),"card_serial_number"},
{CH_SHORT,sizeof(short),"card_type"},
{CH_INT,sizeof(int),"card_life_cycle_count"},
{CH_SHORT,sizeof(short),"card_action_sequence_number"},
{CH_SHORT,sizeof(short),"num_rides"},
{CH_SHORT,sizeof(short),"remaining_rides"},
{CH_INT64,sizeof(INT64),"product_issuer_id"},
{CH_INT,sizeof(int),"product_serial_number"},
{CH_INT,sizeof(int),"product_type"},
{CH_SHORT,sizeof(short),"product_action_sequence_number"},
{CH_INT,sizeof(int),"ptsn"},
{CH_SHORT,sizeof(short),"invoice_printed"},
{CH_INT64,sizeof(INT64),"application_provider_id"},
{CH_INT64,sizeof(INT64),"application_serial_number"},
{CH_SHORT,sizeof(short),"application_personalise_cat"},
{CH_SHORT,sizeof(short),"app_action_sequence_number"},
{CH_SHORT,sizeof(short),"application_type"},
{CH_SHORT,sizeof(short),"application_passenger_type"},
{CH_INT64,sizeof(INT64),"key_version"},
{CH_INT,sizeof(int),"route_line_id"},
{CH_SHORT,sizeof(short),"route_direction"},
{CH_SHORT,sizeof(short),"passenger_type"},
{CH_INT,sizeof(int),"journey_type"},
{CH_INT,sizeof(int),"current_location"},
{CH_SHORT,sizeof(short),"number_of_passengers"},
{CH_SHORT,sizeof(short),"number_of_zones"},
{CH_INT64,sizeof(INT64),"previous_operator"},
{CH_INT,sizeof(int),"trip_origin_location"},
{CH_INT64,sizeof(INT64),"trip_previous_location"},
{CH_CNUM,22,"lav_sam_id"},
{CH_INT64,sizeof(INT64),"lav_participant_id"},
{CH_JUL,sizeof(INT4),"lav_date","YYYYMMDD"},
{CH_INT64,sizeof(INT64),"lav_txn_value"},
{CH_SHORT,sizeof(short),"lav_remaining_rides"},
{CH_INT,sizeof(int),"lav_ptsn"},
{CH_SHORT,sizeof(short),"lav_method_of_payment"},
{CH_SHORT,sizeof(short),"data_is_valid"},
{CH_INT,sizeof(int),"number_of_entries"},
{CH_CHAR,88,"portion_to_participant_id"},
{CH_CHAR,88,"portion_value"},
{CH_TIME,sizeof(INT64),"v_start_date_time","YYYYMMDDHH24:MI:SS"},
{CH_TIME,sizeof(INT64),"v_end_date_time","YYYYMMDDHH24:MI:SS"},
{CH_INT,sizeof(int),"v_duration"},
{CH_INT64,sizeof(INT64),"v_distance_origin"},
{CH_INT64,sizeof(INT64),"v_distance_destination"},
{CH_INT,sizeof(int),"v_distance_distance"},
{CH_SHORT,sizeof(short),"v_journey_period_journeys"},
{CH_SHORT,sizeof(short),"v_journey_transfers"},
{CH_CHAR,71,"v_route_routes"},
{CH_CHAR,121,"v_location_locations"},
{CH_INT,sizeof(int),"restrictions_day"},
{CH_SHORT,sizeof(short),"restrictions_time"},
{CH_INT,sizeof(int),"v_period_duration"},
{CH_INT64,sizeof(INT64),"v_origin"},
{CH_INT64,sizeof(INT64),"v_destination"},
{CH_TIME,sizeof(INT64),"lav_pass_expiry_date_time","YYYYMMDDHH24:MI:SS"},
{CH_TIME,sizeof(INT64),"pass_end_date_time","YYYYMMDDHH24:MI:SS"},
{CH_INT64,sizeof(INT64),"transaction_value"},
{CH_INT,sizeof(int),"currency_indicator_fin_details"},
{CH_INT64,sizeof(INT64),"sales_tax"},
{CH_INT64,sizeof(INT64),"discount"},
{CH_INT,sizeof(int),"tax_rate"},
{CH_SHORT,sizeof(short),"tax_code"},
{CH_SHORT,sizeof(short),"number_of_payments"},
{CH_SHORT,sizeof(short),"payment_method"},
{CH_INT64,sizeof(INT64),"payment_value"},
{CH_INT64,sizeof(INT64),"partial_transaction_value"},
{CH_INT64,sizeof(INT64),"partial_sales_tax"},
{CH_INT64,sizeof(INT64),"purse_remaining_value"},
{CH_INT64,sizeof(INT64),"lav_remaining_value"},
{CH_INT64,sizeof(INT64),"lav_amount_paid"},
{CH_SHORT,sizeof(short),"invoice_not_printed"},
{CH_TIME,sizeof(INT64),"entry_time","YYYYMMDDHH24:MI:SS"},
{CH_SHORT,sizeof(short),"end_of_journey"},
{CH_JUL,sizeof(INT4),"delay_date","YYYYMMDD"},
{CH_INT64,sizeof(INT64),"delay_station_location"},
{CH_SHORT,sizeof(short),"delay_operation_mode"},
{CH_INT64,sizeof(INT64),"value_per_ride"},
{CH_SHORT,sizeof(short),"first_use_activation"},
{CH_INT64,sizeof(INT64),"total_journey_amount"},
{CH_SHORT,sizeof(short),"card_captured"},
{CH_CHAR,101,"file_name_and_record"},
{CH_JUL,sizeof(INT4),"cms_settlement_date","YYYYMMDD"},
{CH_TINY,1,"flag"},
{CH_TIME,sizeof(INT64),"use_time",YEAR_TO_SEC},
{CH_TIME,sizeof(INT64),"acc_time",YEAR_TO_SEC},
{CH_SHORT,sizeof(short),"o_acccode"},
{CH_SHORT,sizeof(short),"d_acccode"},
{CH_INT,sizeof(int),"route_line_count"},
{CH_CHAR,2048,"line_desc"},
{CH_CHAR,50,"line_passby_code"},
{CH_SHORT,sizeof(short),"od_walk_time"},
{CH_CHAR,100,"acc_list"},
{CH_CHAR,100,"line_trip_route"},
{CH_CHAR,4001,"sacccode_arr_dep"},
{CH_INT,sizeof(int),"od_route_sn"},
{CH_INT,sizeof(int),"version_sn"},
{CH_TINY,1,"method"},
{CH_TINY,1,"ud_attr"},
{CH_CHAR,16,"changer"},
{-1,0,"CUT_PI_EXIT","file_name_and_record|"}//尾标,name是数据库的表名,format是主键
};
这个模板可以生成SQL语句。
select 列名,,, from 表名 where 主键
insert into 表名 (列名,,,) values (;列名,:列名,,,);
--
修改:ylh0315 FROM 221.218.61.*
FROM 221.218.61.*