PocketQuery Dynamic Parameters with REST
Asked by Ryan Davis:

I've been looking around documentation for PocketQuery to find information on dynamic parameters using REST API queries but I can only seem to find examples for SQL queries. What I would like to do is enable dynamic parameters on my REST query so I can search through a list of names in a contact database without having to load up the entire database and just using a Table Filter macro. I see that in order to add in dynamic parameters you have to add in pq_ before the variable, but I am trying to filter on one of the columns that I am already pulling with my converter.

Can anyone help out?


Answers:
author: Sven Schatter _Lively Apps_
body: Hi [@Ryan Davis](/t5/user/viewprofilepage/user-id/3414591)

dynamic parameters are a macro option and don't have much to do with your query itself. By enabling dynamic parameters you're telling PocketQuery to look for parameters in the URL of your page to use in your query. So for example in this URL:

**<https://your-confluence.com/your-page?pq_year=2019>**

PocketQuery will pick up the **year** parameter and set it to **2019** if one of your queries in that page has a **year** parameter. Also [**see here**](https://help.scandio.de/documentation/display/PQDOC/Using+the+PocketQuery+Macro#UsingthePocketQueryMacro-Macroparameters) for a further explanation.

I think what you are actually looking for are probably [**query parameters**](https://help.scandio.de/documentation/display/PQDOC/Queries#Queries-UsingParametersinQueries). You can define a query parameter in you query by using the colon syntax (e.g.: *:myparam*). This works both for SQL:

```
SELECT *
FROM?customers
WHERE name = :name
```

and REST:

```
/customers/:name
```

By the way: You can also use so called wildcards. For example, if you want the name of the current page filled in automatically you could do:

```
/pages/:@page
```

You can find all available wildcards [**here**](https://help.scandio.de/documentation/display/PQDOC/Queries#Queries-UsingWildcardsforParameters). If you need specific help designing your query you can always raise a ticket at our [**HelpDesk for PocketQuery**](https://help.scandio.de/servicedesk/customer/portal/5) where we can help you with more details.

Hope that helps! :)

Best regards,  
Sven

comments: author: Georg
body: We're just testing your pocket query addon.

Is it possible to pass a parameter directly to a SQL statement without filling the parameter field in the Pocket Query macro.

So far I've only managed to do it this way  
In the query

```

? ? ? ?Select * from Bla where user = :userFullName
? ? ? ?userFullName = String
```

and must then set the parameter

```

? ? ? ?userFullName = @userFullName
```

so that the logged in user can see his data.

In your example above

```

? ? ?/pages/:@page
```

seems as if you could pass the parameters directly through or only refers to the REST call because the SQL statement doesn't work like this

```
Select * from Bla where user = :@userFullName
```

Georg

<br />

<br />


author: Sven Schatter _Lively Apps_
body: Hi [@Georg](/t5/user/viewprofilepage/user-id/10021),

Yes, this is exactly what wildcards in Query statements are for! See them in the documentation: <https://help.scandio.de/documentation/display/PQDOC/Queries#Queries-UsingParametersinQueries>

**:@userFullName** may not work because wildcards might be case sensitive if I remember correctly. Have you also tried **:@userfullname**?

Cheers,  
Sven


author: Georg
body: Hi Sven,

that's it!  
**:@userfullname** then runs as expected

Thanks

Georg


author: Sven Schatter _Lively Apps_
body: Sweet! Should you encounter more questions don't hesitate to [raise a ticket at our ServiceDesk](https://help.scandio.de/servicedesk/customer/portal/5). There you can also send us your concrete Queries, Templates and Converters privately. :)

Cheers,  
Sven


Tags: confluence-server

pocketquery

server