You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by Trevor Holman <tr...@mchsi.com> on 2016/12/26 19:58:33 UTC

Using a variable in a sqlite query

Hello, 

 

I have been struggling with this for some time. Everything I've tried and
googled has not helped. 

 

var query:String = "CREATE TABLE IF NOT EXISTS " + name + "(recid INTEGER
PRIMARY KEY AUTOINCREMENT, object_name TEXT)";

The variable "name" is used to create tables by the user. In the main Flex
file I use an input field to pass the name into the query string. The
problem is that I can't seem to separate the query command to create the
table from the actual table name unless I add the space in the input field
itself. 

 

Error #2044: Unhandled SQLErrorEvent:. errorID=3115, operation=execute ,
message=Error #3115: SQL Error. , details=near 'EXISTSKnives': syntax error

 

I've tried concatenating a space everywhere I can think of without any luck.


 

Trevor


Re: Using a variable in a sqlite query

Posted by Ghazi Triki <gh...@gmail.com>.
Hello,

Did you try using this library I developed?
https://github.com/riadvice/ActiveAIRCord/tree/master/ActiveAIRCord

It uses the Active Record (anti-pattern) and work pretty well. Some
features are not implemented yet, I would be happy to improve it.

Cordialement,
Ghazi Triki

Le 12/26/2016 � 21:05, Mark Kessler a �crit :
> Might it be needed a little string separation using single quotes?
>
> So the part here....
>
> "CREATE TABLE IF NOT EXISTS " + name + "
>
> might be this.
>
> "CREATE TABLE IF NOT EXISTS '" + name + "'
>
> which has single quotes added... translating to roughly
>
> CREATE TABLE IF NOT EXISTS 'Knives'
>
>
> -Mark
>
>
> On Mon, Dec 26, 2016 at 2:58 PM, Trevor Holman <tr...@mchsi.com> wrote:
>> Hello,
>>
>>
>>
>> I have been struggling with this for some time. Everything I've tried and
>> googled has not helped.
>>
>>
>>
>> var query:String = "CREATE TABLE IF NOT EXISTS " + name + "(recid INTEGER
>> PRIMARY KEY AUTOINCREMENT, object_name TEXT)";
>>
>> The variable "name" is used to create tables by the user. In the main Flex
>> file I use an input field to pass the name into the query string. The
>> problem is that I can't seem to separate the query command to create the
>> table from the actual table name unless I add the space in the input field
>> itself.
>>
>>
>>
>> Error #2044: Unhandled SQLErrorEvent:. errorID=3115, operation=execute ,
>> message=Error #3115: SQL Error. , details=near 'EXISTSKnives': syntax error
>>
>>
>>
>> I've tried concatenating a space everywhere I can think of without any luck.
>>
>>
>>
>>
>> Trevor
>>


RE: Using a variable in a sqlite query

Posted by Trevor Holman <tr...@mchsi.com>.
Thanks Ghazi, I'll take a look at that.

Trevor

-----Original Message-----
From: Ghazi Triki [mailto:ghazi.nocturne@gmail.com] 
Sent: Monday, December 26, 2016 2:14 PM
To: users@flex.apache.org
Subject: Re: Using a variable in a sqlite query

Hello,

Did you try using this library I developed?
https://github.com/riadvice/ActiveAIRCord/tree/master/ActiveAIRCord

It uses the Active Record (anti-pattern) and work pretty well. Some features are not implemented yet, I would be happy to improve it.

Cordialement,
Ghazi Triki

Le 12/26/2016 à 21:05, Mark Kessler a écrit :
> Might it be needed a little string separation using single quotes?
>
> So the part here....
>
> "CREATE TABLE IF NOT EXISTS " + name + "
>
> might be this.
>
> "CREATE TABLE IF NOT EXISTS '" + name + "'
>
> which has single quotes added... translating to roughly
>
> CREATE TABLE IF NOT EXISTS 'Knives'
>
>
> -Mark
>
>
> On Mon, Dec 26, 2016 at 2:58 PM, Trevor Holman <tr...@mchsi.com> wrote:
>> Hello,
>>
>>
>>
>> I have been struggling with this for some time. Everything I've tried 
>> and googled has not helped.
>>
>>
>>
>> var query:String = "CREATE TABLE IF NOT EXISTS " + name + "(recid 
>> INTEGER PRIMARY KEY AUTOINCREMENT, object_name TEXT)";
>>
>> The variable "name" is used to create tables by the user. In the main 
>> Flex file I use an input field to pass the name into the query 
>> string. The problem is that I can't seem to separate the query 
>> command to create the table from the actual table name unless I add 
>> the space in the input field itself.
>>
>>
>>
>> Error #2044: Unhandled SQLErrorEvent:. errorID=3115, 
>> operation=execute , message=Error #3115: SQL Error. , details=near 
>> 'EXISTSKnives': syntax error
>>
>>
>>
>> I've tried concatenating a space everywhere I can think of without any luck.
>>
>>
>>
>>
>> Trevor
>>


Re: Using a variable in a sqlite query

Posted by Mark Kessler <ke...@gmail.com>.
Might it be needed a little string separation using single quotes?

So the part here....

"CREATE TABLE IF NOT EXISTS " + name + "

might be this.

"CREATE TABLE IF NOT EXISTS '" + name + "'

which has single quotes added... translating to roughly

CREATE TABLE IF NOT EXISTS 'Knives'


-Mark


On Mon, Dec 26, 2016 at 2:58 PM, Trevor Holman <tr...@mchsi.com> wrote:
> Hello,
>
>
>
> I have been struggling with this for some time. Everything I've tried and
> googled has not helped.
>
>
>
> var query:String = "CREATE TABLE IF NOT EXISTS " + name + "(recid INTEGER
> PRIMARY KEY AUTOINCREMENT, object_name TEXT)";
>
> The variable "name" is used to create tables by the user. In the main Flex
> file I use an input field to pass the name into the query string. The
> problem is that I can't seem to separate the query command to create the
> table from the actual table name unless I add the space in the input field
> itself.
>
>
>
> Error #2044: Unhandled SQLErrorEvent:. errorID=3115, operation=execute ,
> message=Error #3115: SQL Error. , details=near 'EXISTSKnives': syntax error
>
>
>
> I've tried concatenating a space everywhere I can think of without any luck.
>
>
>
>
> Trevor
>

Re: Using a variable in a sqlite query

Posted by Greg Dove <gr...@gmail.com>.
Trevor did you also make sure you had a space after the name, before the
opening parethesis?

NOT EXISTS " + name + "(r
NOT EXISTS " + name + " (r




On Tue, Dec 27, 2016 at 8:58 AM, Trevor Holman <tr...@mchsi.com> wrote:

> Hello,
>
>
>
> I have been struggling with this for some time. Everything I've tried and
> googled has not helped.
>
>
>
> var query:String = "CREATE TABLE IF NOT EXISTS " + name + "(recid INTEGER
> PRIMARY KEY AUTOINCREMENT, object_name TEXT)";
>
> The variable "name" is used to create tables by the user. In the main Flex
> file I use an input field to pass the name into the query string. The
> problem is that I can't seem to separate the query command to create the
> table from the actual table name unless I add the space in the input field
> itself.
>
>
>
> Error #2044: Unhandled SQLErrorEvent:. errorID=3115, operation=execute ,
> message=Error #3115: SQL Error. , details=near 'EXISTSKnives': syntax error
>
>
>
> I've tried concatenating a space everywhere I can think of without any
> luck.
>
>
>
>
> Trevor
>
>

RE: Using a variable in a sqlite query

Posted by Trevor Holman <tr...@mchsi.com>.
Thanks Mark, I have tried that. It still runs the "EXISTSKnives" as one word.  I've tried adding a space in the functions that grab the input text as well.

Trevor

-----Original Message-----
From: Mark Kessler [mailto:kesslerconsulting@gmail.com] 
Sent: Monday, December 26, 2016 2:06 PM
To: users@flex.apache.org
Subject: Re: Using a variable in a sqlite query

Might it be needed a little string separation using single quotes?

So the part here....

"CREATE TABLE IF NOT EXISTS " + name + "

might be this.

"CREATE TABLE IF NOT EXISTS '" + name + "'

which has single quotes added... translating to roughly

CREATE TABLE IF NOT EXISTS 'Knives'


-Mark


On Mon, Dec 26, 2016 at 2:58 PM, Trevor Holman <tr...@mchsi.com> wrote:
> Hello,
>
>
>
> I have been struggling with this for some time. Everything I've tried 
> and googled has not helped.
>
>
>
> var query:String = "CREATE TABLE IF NOT EXISTS " + name + "(recid 
> INTEGER PRIMARY KEY AUTOINCREMENT, object_name TEXT)";
>
> The variable "name" is used to create tables by the user. In the main 
> Flex file I use an input field to pass the name into the query string. 
> The problem is that I can't seem to separate the query command to 
> create the table from the actual table name unless I add the space in 
> the input field itself.
>
>
>
> Error #2044: Unhandled SQLErrorEvent:. errorID=3115, operation=execute 
> , message=Error #3115: SQL Error. , details=near 'EXISTSKnives': 
> syntax error
>
>
>
> I've tried concatenating a space everywhere I can think of without any luck.
>
>
>
>
> Trevor
>


RE: Using a variable in a sqlite query

Posted by Trevor Holman <tr...@mchsi.com>.
I did. I also had it with no space and the open parenthesis was enough to separate the character.  I've tried using the concat() function with the input field.text but it seems to strip out the space. The only thing that has worked is adding the space in the input field before I type the name... 

I've tried breaking down the query as well in separate lines but again it wants to close that gap after the "EXISTS" command. 

-----Original Message-----
From: Greg Dove [mailto:greg.dove@gmail.com] 
Sent: Monday, December 26, 2016 2:40 PM
To: users@flex.apache.org
Subject: Re: Using a variable in a sqlite query

Trevor did you also make sure you had a space after the name, before the opening parethesis?

NOT EXISTS " + name + "(r
NOT EXISTS " + name + " (r




On Tue, Dec 27, 2016 at 8:58 AM, Trevor Holman <tr...@mchsi.com> wrote:

> Hello,
>
>
>
> I have been struggling with this for some time. Everything I've tried 
> and googled has not helped.
>
>
>
> var query:String = "CREATE TABLE IF NOT EXISTS " + name + "(recid 
> INTEGER PRIMARY KEY AUTOINCREMENT, object_name TEXT)";
>
> The variable "name" is used to create tables by the user. In the main 
> Flex file I use an input field to pass the name into the query string. 
> The problem is that I can't seem to separate the query command to 
> create the table from the actual table name unless I add the space in 
> the input field itself.
>
>
>
> Error #2044: Unhandled SQLErrorEvent:. errorID=3115, operation=execute 
> , message=Error #3115: SQL Error. , details=near 'EXISTSKnives': 
> syntax error
>
>
>
> I've tried concatenating a space everywhere I can think of without any 
> luck.
>
>
>
>
> Trevor
>
>


RE: Using a variable in a sqlite query

Posted by Trevor Holman <tr...@mchsi.com>.
I did get this to finally work. I found another error messing the whole shebang up.

Thanks.

-----Original Message-----
From: Trevor Holman [mailto:trevorh@mchsi.com] 
Sent: Monday, December 26, 2016 3:09 PM
To: users@flex.apache.org
Subject: RE: Using a variable in a sqlite query

I did. I also had it with no space and the open parenthesis was enough to separate the character.  I've tried using the concat() function with the input field.text but it seems to strip out the space. The only thing that has worked is adding the space in the input field before I type the name... 

I've tried breaking down the query as well in separate lines but again it wants to close that gap after the "EXISTS" command. 

-----Original Message-----
From: Greg Dove [mailto:greg.dove@gmail.com]
Sent: Monday, December 26, 2016 2:40 PM
To: users@flex.apache.org
Subject: Re: Using a variable in a sqlite query

Trevor did you also make sure you had a space after the name, before the opening parethesis?

NOT EXISTS " + name + "(r
NOT EXISTS " + name + " (r




On Tue, Dec 27, 2016 at 8:58 AM, Trevor Holman <tr...@mchsi.com> wrote:

> Hello,
>
>
>
> I have been struggling with this for some time. Everything I've tried 
> and googled has not helped.
>
>
>
> var query:String = "CREATE TABLE IF NOT EXISTS " + name + "(recid 
> INTEGER PRIMARY KEY AUTOINCREMENT, object_name TEXT)";
>
> The variable "name" is used to create tables by the user. In the main 
> Flex file I use an input field to pass the name into the query string.
> The problem is that I can't seem to separate the query command to 
> create the table from the actual table name unless I add the space in 
> the input field itself.
>
>
>
> Error #2044: Unhandled SQLErrorEvent:. errorID=3115, operation=execute 
> , message=Error #3115: SQL Error. , details=near 'EXISTSKnives':
> syntax error
>
>
>
> I've tried concatenating a space everywhere I can think of without any 
> luck.
>
>
>
>
> Trevor
>
>