The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: sql query-passing variable error
Replies: 4   Last Post: Aug 25, 2015 4:54 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
kainat ali

Posts: 18
Registered: 12/26/12
sql query-passing variable error
Posted: Feb 20, 2013 2:55 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I'm taking input from user on Command Window and storing that input in a variable (UserInput). After this I'm trying to pass this information to the sql query to select the data from database:

query2 = strcat(strcat('select Column1 from Table where Column2=''', UserInput), '''')
curs1 = exec(conn,query2)
final = fetch(curs1)
final1 = fetch(conn,query2)

The following error comes:

Error using database/fetch (line 37)
Second argument must be either a query string or object of type sqlOutput

Error in recipe (line 23)
final1 = fetch(conn,query2)

What I understand is that the query2 that its taking, it is taking as a string instead of sql query. What should I do to make it recognize as an sql query instead of a string.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.