Skip to content
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

Bind Variables in Correlated Sub-Query not working. #20

Closed
demmings opened this issue Jan 19, 2023 · 2 comments
Closed

Bind Variables in Correlated Sub-Query not working. #20

demmings opened this issue Jan 19, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@demmings
Copy link
Owner

  • If a bind variable ('?') is inserted into the correlated sub-query, it will fail. For example:
select * from booksales as b1 where price in (select max(price) from booksales where b1.customer_id = customer_id and book_id <> ?)
  • The way that correlated sub-queries were solved was by inserting a bind variable for every outer table field reference in the inner query. This needs to be resolved.
@demmings demmings added the bug Something isn't working label Jan 19, 2023
@demmings
Copy link
Owner Author

  • The fix will involve changing how SELECT statements will reference the bind variables.
  • Current use has the '?' in the SELECT matching bind data in the order listed in the gsSQL() function.
  • The bind variable will be changed so that the bind ? will use a specific variable in the list. This will be done by also including the position number on the bind variable.
  • The added benefit to this is when one bind data point is needed more than once in the SELECT statement. Currently, you would have to add the bind data as many times as needed in the select.
  • The new format will be like:
=gsSQL("select * from table where fldName = ?1 and amountFld < ?2 and otherAmount > ?2", {{"table", "A1:I20", 60}}, true, "Fred", 100) 
  • You can see in this example, we would only need to list TWO bind data items since we can reference one bind data point more than once, where the current use would require 3 bind data items.
  • The ?1 would reference the first bind data point listed and ?2 would reference the second.

@demmings
Copy link
Owner Author

  • Changed how bind variables are reference in SELECT.
  • Now first bind variable is reference as ?1, the second is referenced as ?2 and so on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant