Unable to use variables in multiline statements (%%sql)
See original GitHub issueVariables can be used normally with the following syntax:
[1] table = 'my_fancy_table'
[2] %sql SELECT * FROM $table
Unfortunately, when I want to create multiline sql statements (like the following) variables are not possible to use:
[1] table = 'my_fancy_table'
[2] %%sql SELECT name, firstname FROM $table
Outputs:
(psycopg2.ProgrammingError) syntax error at or near “$”
LINE 1: SELECT * FROM $table;
Does I have to use a different variables syntax for multiline statements or do multiline statements simply not support variables?
Thanks in advance.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Unable to execute a multiline query read from a file when ...
Scenario: The sql query is stored in file. When I'm just executing the script as a string in powershell the results are displayed...
Read more >How to pass multiline as input to & — oracle-tech
You can't enter multiple lines of text for a SQL*Plus substitution ... To use a bind variable in SQL*Plus, you use the VARIABLE...
Read more >Database Engine events and errors - SQL Server
Consult this MSSQL error code list to find explanations for error messages for SQL Server database engine events.
Read more >MySQL 8.0 Reference Manual :: 5.1.8 Server System Variables
To see the current values used by a running server, use the SHOW VARIABLES statement or the Performance Schema system variable tables. See...
Read more >Work with multi-statement queries | BigQuery - Google Cloud
Use variables in a multi-statement query ... in DDL and DML queries. For example, you can't use a system variable as a project...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Using
:
solves a similar but not quite the same things as$
.:
works for parameters but not for extending the query.IE
works with
$
but not for:
I made a PR for this, and I think it should resolve your issue @mrjoseph84 .
Try: