Re: Extreme problem adding fields to a table.
Dave's right. a5_add_fields_to_table( ) works great.
Without a posted sample, we cannot help much.
Dave's right. a5_add_fields_to_table( ) works great.
Without a posted sample, we cannot help much.
Alpha Software Mobile Development Tools: Alpha Anywhere | Alpha TransForm |
? table.external_field_name_get("awgmd","n,t,W,D") = storenum,C,9,0 startdate,C,17,0 enddate,C,17,0 vendor,C,7,0 upc,C,14,0 dept,N,5,0 descriptio,C,51,0 regretail,N,9,2 activereta,N,11,2 qty,N,4,0 sales,N,9,2 salesatreg,N,19,2 admarkdown,N,12,2
fil = file.create("c:\tbllist.txt",FILE_RW_EXCLUSIVE) grnd_max_len = 0 table_name = :a5.table_enum("") IF table_name <> "" THEN 'While the table_enum method returns nonblank names, get next name WHILE table_name <> "" :Statusbar.Set_Text("Building format specifications.") t = table.open(table_name) flds = t.fields_get() FOR x = 1 TO flds fldlnchk = t.field_get(x) if len(fldlnchk.name_get()) > grnd_max_len grnd_max_len = len(fldlnchk.name_get()) end if next x t.close() table_name = :A5.table_enum(table_name) END WHILE END IF table_name = :a5.table_enum("") IF table_name <> "" THEN 'While the table_enum method returns nonblank names, get next name WHILE table_name <> "" :Statusbar.Set_Text("Building list for: " + table_name) t = table.open(table_name) flds = t.fields_get() FOR a = 1 TO flds fldptr = t.field_get(a) if a = 1 fil.write_line("TABLE: "+F_upper(table_name)) fil.write_line("") fil.write_line(padr("Fieldname",max(grnd_max_len+3,11)," ")+"Type " + "Width "+"Decimals") end if ' fil.write_line(padr(f_upper(lower(fldptr.name_get())),max(fld_max_len+3,11)," ")+" "+f_upper(lower(fldptr.type_get()))+" "+fldptr.width_get()+" "+fldptr.dec_get()) fil.write_line(padr(f_upper(lower(fldptr.name_get())),max(grnd_max_len+3,11)," ")+" "+f_upper(lower(fldptr.type_get()))+" "+padl(alltrim(str(fldptr.width_get())),7," ")+" "+padl(alltrim(str(fldptr.dec_get())),8," ")) NEXT a t.close() fil.write_line("") fil.write_line("") table_name = :A5.table_enum(table_name) END WHILE END IF fil.flush() fil.close() :Statusbar.Set_Text("Done!!")
'Date Created: 04-Sep-2015 09:21:30 AM 'Last Updated: 04-Sep-2015 09:53:25 AM 'Created By : ShopCal 'Updated By : ShopCal copy_db_name = filename_decode("[PathAlias.ADB_Path]\test_header2.dbf") a_tbl = table.open("test_header") ON ERROR GOTO ERROR0409201509105705 DIM a5_operation_order as C a5_operation_order = "" query.order = a5_operation_order DIM a5_operation_filter as C a5_operation_filter = ".T." query.filter = a5_operation_filter query.options = "I" query.description = "Temporary Query" i_indx = a_tbl.query_create() copy.set = "" copy.db = copy_db_name copy.dd = .T. copy.delete_o_dd = .T. copy.records = .T. copy.fields = 3 copy.field1 = "Inv_Id" copy.field2 = "Johnny" copy.field3 = "Billy" a_tbl.copy() GOTO CONTINUE0409201509105705 ERROR0409201509105705: ON ERROR GOTO 0 ui_msg_box("Error","Error running Copy Operation"+crlf()+error_text_get()) END CONTINUE0409201509105705: a_tbl.close() 'Add the table just created by the Copy operation to the Database.. file_add_to_db(copy_db_name) 'You can only run the change table name once in a session as Alpha locks the newname dim filename as c dim newname as c filename ="test_header" 'Must rename it so you can rename the copied table to this name newname ="test_hold" tbl = table.open(filename, FILE_RW_EXCLUSIVE) tbl.rename(newname) tbl.close() filename ="test_header2" 'Now rename the copied table newname ="test_header" tbl = table.open(filename, FILE_RW_EXCLUSIVE) tbl.rename(newname) tbl.close() add_fields() 'Call the function shown below 'FUNCTION add_fields AS L ( ) "this is the code in the function called above" ' 'fld_list = a5_get_fieldnames( "test_header.dbf" ) 'IF "IS_Exported"$fld_list '2013-12-13 ' GOTO Updates_done 'END if 'fld_list = a5_get_fieldnames( "test_header.dbf" ) 'IF .not. ("Is_Exported"$fld_list) ' fields = <<%list% 'Is_Exported,L,1 'event_id,N,16,0 'Details,C,72 'tmstart,T,17 'tmend,T,17 'Alarm,C,20 'How,C,20 'Equip,C,20 'Export_It,L,1 'Add_Date,D,8 'Sch_Notes,C,240 'Priority,N,4,0 'Class_type,C,16 'Rev_Date,D,8 'Sch_datec,C,16 'Sch_Date,D,8 'Cust_email,C,60 '%list% 'a5_add_fields_to_table("test_header.dbf",fields ) ' end if 'Updates_done: ' 'END FUNCTION
Comment