Hi Everyone,

I'm building an app that inserts data into table A, then I want a trigger to kick off before new data is inserted into table B to confirm that the value exists in column string_Value and then take the data and add it into TABLE C.

Is this possible and what's the best way forward?

Regards

Hi,

please can you explain better the relations between these three tables and the conditions that you want to use to insert the data? Right now I do not understand much.

Hi Cereal,

I have values in my trusted column and values being dumped into an untrusted column. When data is equal to the trusted column then everything is ok but when it's not it should log into another table for further processing.

Hope it makes sense.

Regards

So, you want to compare the string that you want to insert into table B against the values in table A, if they match then the insert should go fine, otherwise you want to insert the value into table C. Correct?

If I'm not wrong, a trigger cannot stop the insert statement, unless you use SIGNAL with MySQL 5.5+, but this will cause an error.

You could use procedure instead of the insert & trigger events, so instead of:

insert into tableB (value) values('oranges');

it will be something like:

call matchAB('oranges');

And from there you decide where to insert the value.

Hi Cereal,

Thanks for the help in the right direction.

SELECT * FROM tbl_data where tblInput=tblOutput

When statement is true ignore query and continue with next insert. My problem now is when my tblInput grows so does the time for each new tblInput. Is there a way of getting rid of the time it takes to input false results into tblOutput.

My current tblInput has 20 000 lines and it takes +-1 minute to complete 1 line so it takes +- 10 minutes to complete 10 line's which is not helpfull at all in the program I'm building.

Any tips for running a query on a table and getting rid of the time constraint?

Regards

Member Avatar for diafol

You're not explaining this very well I fear.
Give your code and table structures.

Hi Diafol,

Manage to get it sorted. Just had too many fields in my query.

Regards

Member Avatar for diafol

Good news :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.