-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion on name-parameters in (sql) queries #69
Comments
regarding, Case 1, please note that |
thoughts on this @varontron ? |
and here is another example. SELECt * from country_inventory where protocol_number = ?v I can: (SELECt * from country_inventory UNION select * from site_inventory)where protocol_number = ?v well, no I can't. SELECT * from ( but I'm not too hopeful on performance. but if I do now, I need to pass 2 protocol_numbers when I call the query. ALSO, now, I have open the possibility to get a merge inventory of country inventory of study-1 with site inventory of study-2 -- well, that's dumb, unless all my developers are smart, attentive and not overloaded. ah! If only I could do: SELECT * from country_inventory where protocol_number = ?v:pcol that'd be nice :) |
What is "pcol"? Is it a column name in the JSONParams spec?
|
well, hello -- I wish this would notify me when you post back - maybe you should @-me. |
Here is a new example: UPDATE site_update SS SET (SAVE_emp521, save_ts) = ( If I allow this query to be called with a bug where the 3 parameters have different values, I kind-of compromised my pseudo-audit-trail. would be much nicer to be able to write: UPDATE site_update SS SET (SAVE_emp521, save_ts) = ( |
ALSO: I'm not saying you should try to do this ASAP. |
Hello,
Here is an example that illustrates why I'm suggesting this.
So, we have a row of data that may be flagged in the app as "missing" to mean, missing data.
The application (aspirin) lets the user confirm whether the row is missing for a good reason or another.
When the row's reason is confirmed, we want to update the row as 'confirmed', however, we don't want to flag it as confirmed if the reason was that the row was corrupt (file truncated etc).
So, you can do that in a few ways:
Case 1- in 2 steps
(1a) UPDATE tbl SET REASON_MISSING_ROW=?v WHERE p_rowid=?v
(1b) UPDATE tbl SET IS_CONFIRMED = (CASE WHEN REASON_MISSING_ROW = 'corrupt' OR REASON_MISSING_ROW IS NULL THEN 0 ELSE 1 END) WHERE p_rowid=?v
Case 2- in 1 step
(2) UPDATE tbl SET REASON_MISSING_ROW=?v, IS_CONFIRMED=?n WHERE p_rowid=?v
Another case is to use "named parameters" in Yada queries:
Case X - in 1 step:
(X) UPDATE tbl SET REASON_MISSING_ROW=?v:reason, IS_CONFIRMED=(CASE when ?v:reason = 'corrupt' OR ?v:reason IS NULL THEN 0 ELSE 1 END) WHERE p_rowid = ?v
The suggestion is to allow tags on the parameters, so that in jsonParams you could run the query with [{qname:"QQ",DATA:[{"reason":"ok",p_rowid:"23132132"},{"reason":"corrupt","P_ROWID":2342363}]]
instead of
[{qname:"QQ",DATA:[{"REASON_MISSING_ROW":"ok",P_ROWID:"23132132"},{"REASON_MISSING_ROW":"corrupt","P_ROWID":2342363}]]
This enables case X.
Maybe it is a personal slant of mine, but:
Case 2 is not very desirable because the Yada query does not enforce an important business rule. The onus is on the application or the yada developer cow-boys. Not cool.
Case 1 also puts the onus on the app developer to remember to call both queries and call them in the right order - however, perhaps (1a) can be configured to force a follow-up query, (1b) -- as a default parameter with post-process [can this be done in Yada 8?]
But anyway, it gets complicated to configure these cascading 1a ==> 1b queries, and "named parameters" could be a neat addition to Yada, also allowing an application developer to rely on a "field name" (e.g here 'reason') that may be different than the internal table (REASON_MISSING_ROW).
That is much better for data integration, as important as the harmonizer ...
thanks for the consideration, if you agree, I could try to make it happen...
The text was updated successfully, but these errors were encountered: