# SQL insertions

**URL:** <https://forum.xojo.com/t/sql-insertions/38249>\
**Category:** iOS\
**Created:** [June 15, 2017, 10:25pm UTC](https://forum.xojo.com/t/sql-insertions/38249 "2017-06-15T22:25:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Pitchford](https://forum.xojo.com/user_avatar/forum.xojo.com/james_pitchford/32/4568_2.png) [@James\_Pitchford](https://forum.xojo.com/u/James_Pitchford)\
**Post date:** [June 15, 2017, 10:25pm UTC](https://forum.xojo.com/t/sql-insertions/38249/1 "2017-06-15T22:25:06Z")

</div>

What is wrong with the following:

dim sql as text = "SELECT ?1 FROM ?2 WHERE guid = ?3 AND deleteFlag = 0 "  
dim rs as iossqliterecordset = r.DB.SQLSelect(sql, getfield, TN, r.guid)

Why does it show an exceptionError on running of “near ?2”

getField, TN and r.guid are all Text.

---

<div class="post-metadata">

**Author:** ![Bob\_Keeney](https://forum.xojo.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@Bob\_Keeney](https://forum.xojo.com/u/Bob_Keeney)\
**Post date:** [June 15, 2017, 10:29pm UTC](https://forum.xojo.com/t/sql-insertions/38249/2 "2017-06-15T22:29:29Z")

</div>

Try hard coding the table name. Not sure the table name can be a parameter like that. Might be wrong, but let’s start by eliminating variables.

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [June 15, 2017, 10:45pm UTC](https://forum.xojo.com/t/sql-insertions/38249/3 "2017-06-15T22:45:10Z")

</div>

you cant use ?1 style parameters as either the select list (the columns) or the table names  
Its for parameter values for the where clause only

---

<div class="post-metadata">

**Author:** ![James\_Pitchford](https://forum.xojo.com/user_avatar/forum.xojo.com/james_pitchford/32/4568_2.png) [@James\_Pitchford](https://forum.xojo.com/u/James_Pitchford)\
**Post date:** [June 16, 2017, 1:29am UTC](https://forum.xojo.com/t/sql-insertions/38249/4 "2017-06-16T01:29:44Z")

</div>

Makes sense - thanks both.

---

<div class="post-metadata">

**Author:** ![Richard\_Duke](https://forum.xojo.com/user_avatar/forum.xojo.com/richard_duke/32/246_2.png) [@Richard\_Duke](https://forum.xojo.com/u/Richard_Duke)\
**Post date:** [June 16, 2017, 9:16am UTC](https://forum.xojo.com/t/sql-insertions/38249/5 "2017-06-16T09:16:21Z")

</div>

[quote=336428:@James Pitchford]What is wrong with the following:

dim sql as text = "SELECT ?1 FROM ?2 WHERE guid = ?3 AND deleteFlag = 0 "  
dim rs as iossqliterecordset = r.DB.SQLSelect(sql, getfield, TN, r.guid)

Why does it show an exceptionError on running of “near ?2”

getField, TN and r.guid are all Text.[/quote]

what about using REPLACE for ?1 and ?2  
and then do the dim rs as iossqliterecordset = r.DB.SQLSelect(sql, r.guid)

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 6:48pm UTC](https://forum.xojo.com/t/sql-insertions/38249/6 "2020-10-29T18:48:57Z")

</div>


