I am unsure why the MySQL query below, whilst works and insert into DB without any errors, doesn’t output the two values when testing in Server Action? the vrfyCode_code and vrfyCode_key insert in DB, but don’t show their values in the Server Action so I can use then in the App connect side.
The output for a custom query doesn’t return the same as native insert/update (identity/affected). You would have to add a query afterwards to select the relevant information for use on other steps or on client-side.
I’ve never tried but you might be able to add a semi colon to the end of your insert statement and then a select statement in the custom query. Not sure if it can handle 2 statements in one query.
Hi @bpj, I tried adding another query afterwards to select the info. still not working.
Any other ideas.
Whats the way around using output from custom queries as parameters?
hi @Teodor,
I added another step, a single query, to get the output from the previous customer query step.
Everything inserts properly in the DB without problems, its just that I can’t use the customer values as a parameter.
INSERT INTO users_codes
(vrfyCode_usr_id, vrfyCode_code, vrfyCode_key, vrfyCode_created)
VALUES (:P1, LPAD(FLOOR(RAND() * 999999.99), 4, '0'), (SELECT UUID()), :P3);
SELECT vrfyCode_usr_id, vrfyCode_code, vrfyCode_key, vrfyCode_created FROM users_codes
WHERE vrfyCode_usr_id = :P1
ORDER BY vfyCode_id DESC
The little play button at the top allows you to run the query to test it and it automatically generates the schema from the output. Use the parameters tab to set test values for the user id and create date
Good point @bpj - but with other queries, I can get out what was inserted. For example, I can get the IDENTITY or I can then create another single query to get out what was inserted in the Custom query.
I tried the INSERT and SELECT query you kindly provided, and received an error.
I just want to be able to use the data that was inserted by the custom query. I have set the Schema in the custom query so they can appear for the data bind.
As I said an INSERT does not return data so setting the schema does nothing - it just tells the UI that there should be fields to pick from. You usually don’t need to add the schema manually, just use the play button to run a test query and it will produce it for you. When you said you used the lightning bolt, did you point it to the same value as the parameter :P1.
(I presume this was the Set Value usrID step in your API file) - in the data picker, you can switch to code view and type usrID to assign it f it still puts 0 in
Ok I will try to remove the ‘0’ manually.
Can I ask, a normal INSERT does give us an ‘Identity’ we can use in other queries. Can we also do the same for a custom query and at least get an ‘Identity’?
The trouble with custom queries is they can be any type of statement not all of which generate an identity. Some complex statements could involve a mix of SELECT/INSERT/UPDATE etc… so I suspect it’s just not possible
Understood @bpj. So I took off some unnecessary queries for simplicity.
So what do I do after the custom query?
I just want to be able to extract what it inserted and be able to use it later as a data bind in the App connect.
How do I link what of inserted and use that with another query.