Hi,
I'm on ADS 10 and I'm wondering whether an AquaScript can handle a parameterized query. I saved such a query as an AquaScript but it saved it with the value I put in for the parameter when I ran it. Is it possible to create or save an AquaScript in such a way that the parameter is again asked for when the script runs?
Thanks
The following code will always prompt the user for input:
var something = aqua.console.readLine("Enter something: "); aqua.console.println("You've entered: " + something); var secret = aqua.console.readPassword("Enter a secret: "); aqua.console.println("You've entered: " + secret);
Interesting but I'm not sure whether that would be very good for filling out a few parameters in a sql statement of several hundred lines. I guess I'd have to 'build' the query, getting the parameters with the 'readLine' function. Doable but it would be cool to have the parameterized query capabilities within the AquaScript! :)
Interesting but I'm not sure whether that would be very good for filling out a few parameters in a sql statement of several hundred lines. I guess I'd have to 'build' the query, getting the parameters with the 'readLine' function. Doable but it would be cool to have the parameterized query capabilities within the AquaScript! :)
Hi John,
AquaScript currently doesn't support parameterization.
Can you please clarify what you meant by "I saved such a query as an AquaScript but it saved it with the value I put in for the parameter when I ran it." ? So this query is embedded as a string in your AquaScript?
Regards.
--Nhi
Hi John,
AquaScript currently doesn't support parameterization.
Can you please clarify what you meant by "I saved such a query as an AquaScript but it saved it with the value I put in for the parameter when I ran it." ? So this query is embedded as a string in your AquaScript?
Regards.
--Nhi
Sure. I ran a parameterized query as per usual that asks the users enter some IDs and other variables like this: &StudyID. After running the query I then hit the Save Results menu item where you get the buttons below of 'Cancel', 'Save to File', 'Save to Clipboard' and 'Generate AquaScript'. On hitting the last button the AquaScript is generated but when it is run - instead of the user being prompted for the parameter(s) - the query runs using the parameters that were entered when the query was last run (before hitting the 'Save Results' menu item).
Using the AquaScript functions that you suggested I can see where it would be possible to 'imitate' the parameterized query within AquaScript. That's just a bit more work, especially if the query is lengthy with a number of parameters and thus you have to break the query up into 'chunks', get the user's input for the parameters and then insert those chosen parameters between those chunks and put the query back together before running it.
Sure. I ran a parameterized query as per usual that asks the users enter some IDs and other variables like this: &StudyID. After running the query I then hit the Save Results menu item where you get the buttons below of 'Cancel', 'Save to File', 'Save to Clipboard' and 'Generate AquaScript'. On hitting the last button the AquaScript is generated but when it is run - instead of the user being prompted for the parameter(s) - the query runs using the parameters that were entered when the query was last run (before hitting the 'Save Results' menu item).
Using the AquaScript functions that you suggested I can see where it would be possible to 'imitate' the parameterized query within AquaScript. That's just a bit more work, especially if the query is lengthy with a number of parameters and thus you have to break the query up into 'chunks', get the user's input for the parameters and then insert those chosen parameters between those chunks and put the query back together before running it.
Hi John,
I've changed this issue into an enhancement request to be considered for a future release.
Basically when generating AquaScripts from query results, and when the original query is parameterized, we can generate the SQL string composing of fixed parts and parameters. For example:
select * from test where column1 = &column1
will appear in the generated AquaScripts as
var column1 = aqua.console.readLine("Enter value for column1: "); var query = "select * from test where column1=\'" + column1 + "\'";
Hi John,
I've changed this issue into an enhancement request to be considered for a future release.
Basically when generating AquaScripts from query results, and when the original query is parameterized, we can generate the SQL string composing of fixed parts and parameters. For example:
select * from test where column1 = &column1
will appear in the generated AquaScripts as
var column1 = aqua.console.readLine("Enter value for column1: "); var query = "select * from test where column1=\'" + column1 + "\'";
Issue #8236 |
Closed |
Completion |
No due date |
No fixed build |
No time estimate |
The following code will always prompt the user for input: