Update or insert in an action

I’ve tried several ways, looking in the topics found in the community and it didn’t work,

I need to check in my action if I’m including or editing, but I’m not getting success.

I thank everyone.

Put a hidden field in your form for the item ID. If a record is being edited then an ID will be present. If it’s a new record there won’t be an ID present.

On the server side, check for the ID in the POST. If an ID is present then update ELSE insert.

1 Like

thanks TMR.

1 Like

We really need an upsert action, already a FR so we can duplicate “insert on duplicate key update” sql statement
https://community.wappler.io/c/feature-requests/12

2 Likes

I don’t need an upset action… I’m already doing my best to keep the ones I have happy…

I didn’t understand :thinking:

Hyperbytes and Antony are discussing something called a upsert action but there was a typo making it upset so just a playful reply from Antony :slight_smile:

If a upsert action existed in Wappler the update and insert would just be done at the same time making it easier but as it doesn’t yet exist in Wappler you normally would do something like TMR mentions where you use a condition step to check if a id is present or not.

Here is the feature request for upsert

Have a look at the following video. The Upsert part starts at 06:25

1 Like

Yes, that’s how most of us are probably doing it now ben but the upsert i refer to would be a single action

SQL allows for a statement such as:

INSERT INTO tab1 (col1, col2, col3) VALUES (10,20,30) ON DUPLICATE KEY UPDATE col3=col3+1;

the insert is first tried but if there is a key violation the update runs in it’s place
It would be nice to be able to do this within a new UPSERT action where the insert and update could be defined within 1 query action

1 Like

Thanks Brian, I saw this as a chance to plug my video.

1 Like

I really need to watch more of these videos. I learn something new each time. Thanks @ben for putting in the time and effort. It does not go un-noticed. :beers:

2 Likes

Plugging is perfectly acceptable even if it sounds like a sex game!

2 Likes

Talking sex, don’t forget the Wappler Meetup this coming Friday.

1 Like

Can actually make it this month, see you there

2 Likes

Looks like this FR has been removed?

For any kind of high-volume apps / actions we really do need upsert as an option. I’ve tried implementing with custom SQL but I just return errors.

@George any chance this is possible at all with Wappler, and is it on the roadmap at all?

The FR is not removed - it is still there, available for voting and you can bump it if you wish

1 Like

Link to the FR is here:

1 Like

Also this FR:

1 Like