![]() SELECT =Ĭoncat('SELECT mac_address,heartbeats->', ' as group_id') You will need to use the function quotestring. That is, the single quotes around group_id needs to be doubled.Ĭomposing nesting dynamic SQL is difficult and in order to save your mind, you should work it out step by step. 'SELECT mac_address,heartbeats->''group_id'' as group_idįROM hubs where location_key = 290 limit 10') So the resulting statement should be: SELECT * FROM OPENQUERY(LOGDB, But OPENQUERY only accepts a single string literal for the second argument. Well, does that look correct to you? You have these tokens. SELECT * FROM OPENQUERY(LOGDB, 'SELECT mac_address,heartbeats->'group_id' as group_id FROM hubs where location_key = 290 limit 10') values, which makes me suspect that the value for VARB that is being passed isn't the exact syntax needed to get a valid result.Īny insights on how to structure the query to return actual values? '')'ĮXEC query does not error and it returns the address, but instead of values for group_id it returns. SELECT = 'SELECT * FROM OPENQUERY(,''SELECT address,heartbeats->''''' + + '''''as group_id FROM. ![]() At present the closest syntax I have been able to come up with is below, where "address" is a text field and "heartbeats" is the json array and group_id is the value I'm trying to select from the JSON array. I have found that I can successfully query the standard data fields, but that the queries don't work for JSON. I have managed to connect to the table but have found that direct queries don't work and that I need to use the open query structure. CSVįormats variables with multiple values as a comma-separated string.I am attempting to query a postgres database that includes a json array as one of its columns. If any invalid formatting option is specified, then glob is the default/fallback option.Īn alternative syntax (that might be deprecated in the future) is ]. Test the formatting options on the Grafana Play site. You can make that happen with advanced variable formatting options listed below. In some cases, you might want to have a comma-separated string without quotes: server01,server02. The formatting of the variable interpolation depends on the data source, but there are some situations where you might want to change the default formatting.įor example, the default for the MySql data source is to join multiple values as comma-separated with quotes: 'server01','server02'. ![]() Read the data source specificĭocumentation topic for details on value escaping during interpolation.įor advanced syntax to override data source default formatting, refer to Advanced variable format options. Interpolation, the variable value might be escaped in order to conform to the syntax of the query language and where it is used.įor example, a variable used in a regex expression in an InfluxDB or Prometheus query will be regex escaped. Deprecated old syntax, will be removed in a future release.īefore queries are sent to your data source the query is interpolated, meaning the variable is replaced with its current value. Refer to Advanced variable format options for more detail on all the formatting types. $ This format gives you more control over how Grafana interpolates values.This syntax is easy to read, but it does not allow you to use a variable in the middle of a word.Įxample: ontend.$ Panel titles and metric queries can refer to variables using two different syntaxes: Grafana Cloud Enterprise Open source Variable syntax
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |