I wanted to insert data to psql from a text file with proc, after inserting data with my proc program ,the order of data in psql was different from the text file sometimes.
there was no any sql error in the process, I found the problem when I select * from table.
Did there have some method could confirm the order which I inserted the same as the order in database(psql) ?
thanks!
for example:
table: testtable
id int
name char(20)txt file:
100 amy
200 john
300 joy
400 ruby
but the data in psql is like:
200 john
300 joy
400 ruby
100 amy
my program:
EXEC SQL BEGIN DECLARE SECTION;
int id;
char name[20];
int id_ind, name_ind;
EXEC SQL ENDDECLARE SECTION;
main ()
{
EXEC CONNECT TO SQL ....
while ( still have data ){
read_data_from_file()
put_data_in_host_varable();
EXEC SQL INSERT INTO testtable( id, name )
VALUES (:id INDICATOR id_ind, :name INDICATOR name_ind)
}
EXEC SQL COMMIT WORK;
EXEC SQL DISCONNECT ALL;
}