This topic is locked
[SOLVED]

Sorting During Import

7/19/2021 10:11:24 AM
PHPRunner General questions
I
Ivan van Oosterhout author

Hello,

Can somebody give me a good aproach please.
I want to sort a column during import of the data, Can somebody help me please.

is this the correct way? because it does not work.

Before Insert Record:

$data = $pageObject->getMasterRecord();
$data["comp_sert"] = $data["comp_sert"];

if ($data["comp_sert"] == 1) {
asort($rawvalues["S1Pos1Text"]);
}

This is the column data:
180K1:GND 1
185K1:PE
190K1:-X80:2
190K1:-X80:1
190K1:-X81:2
190K1:-X81:1
X190:7:a
X190:8:c
500K0:6
500K0:14
185K1:NC
185K1:COM
130B1:12
PE22:1

admin 7/21/2021

You are attacking this issue from the wrong angle. Data is the database is not "sorted" but it can be sorted when you retrieve it.

If I understand your question right you just need to modify your SQL query adding the following at the end:
ORDER BY S1Pos1Text

I
Ivan van Oosterhout author 7/22/2021

Hello,
Thank you for your respond, but it is not retrieving data it is inserting data.
At "Before Insert Record" i define all variables which need to be inserted in de database.

But the tricky part is that when i insert into the database I give an numbering to the rows like Batch and batch number.

like this:
Batch - BatchNumber - data
1 1 190K1:-X80:2
1 2 190K1:-X80:1
1 3 190K1:-X81:2
1 4 190K1:-X81:1

So during import when i define all colomns to import,
then the sorting must take place or else my numbering will not be inserted in a proper way in the database.

It should be Inserted in the DB like this,
with the correct numbering:
1 1 190K1:-X80:1
1 2 190K1:-X80:2
1 3 190K1:-X81:1
1 4 190K1:-X81:2

So before it is inserting in the database i need the sorting, the insert in the database with the correct numbering.
admin 7/22/2021

It makes more sense now. The solution would be inserting your data into a temporary table first and then moving it to the permanent table in the correct order.

I
Ivan van Oosterhout author 7/22/2021

Thank you,

It is clear to me,
I was afraid for this aprouch I have to re-program a lot. :-)

Kind regards