# PDF Creation Passing Data In Issues

**URL:** <https://forum.inductiveautomation.com/t/pdf-creation-passing-data-in-issues/70942>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [March 12, 2023, 1:32am UTC](https://forum.inductiveautomation.com/t/pdf-creation-passing-data-in-issues/70942 "2023-03-12T01:32:20Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 12, 2023, 9:23am UTC](https://forum.inductiveautomation.com/t/pdf-creation-passing-data-in-issues/70942/2 "2023-03-12T09:23:32Z")

</div>

> [@Tyler\_Folsom](#):
>
> I have a for loop that builds the WHERE clause for the query.  
> For example: **ticket\_ids = ticket\_ids + " OR t1.id = " + str(73555)**...so on and so forth

Don't do that. If you can script the construction of a where clause, you can construct it with parameter placeholders and pass the parameters without string conversion. You would have code something like this:

```auto
	idList = list(data['idList2'].getColumnAsList(0))
	if idList:
		if len(idList) > 1:
			q_where = "ticket_ids IN (%s)" % (', '.join(['?'] * len(idList)))
		else:
			q_where = "ticket_ids = ?"
	else:
		q_where = "0=1"
	sql_query = "Select ...... From tickets Where %s" % q_where
	pyds = system.db.runPrepQuery(sql_query, idList, 'myDB')
	data['tickets'] = pyds.underlyingDataset

```

If you need subqueries to go with each ticket, it gets more complicated:

> [@Report with Scripted Nested Data](https://forum.inductiveautomation.com/t/report-with-scripted-nested-data/11801):
>
> The report datasource scripting examples explain how to access the nested data in another key for use constructing a custom dataset. What I don’t see is how to construct nested data that would be suitable for use with a child table in a table group. I have a parent dataset that I’m constructing via script due to annoying limitations of an ancient SQL Server 2000 instance. I need a subquery for each row that could be done with a normal query, but there’s no way to add a regular subquery to a s…

---

_[View the full topic](https://forum.inductiveautomation.com/t/pdf-creation-passing-data-in-issues/70942)._
