Forum Discussion

IP's avatar
IP
Occasional Contributor
15 years ago

[RESOLVEDD]Using variables for insertion values via DataSink

Newbie

Hi,

I have made a testcase which works fine. However I'm trying to store the results from the webrequest in a mysql-database which gives me some trouble. The Data-connection works fine for retrieving data from the mysql-database. However (and here is the problem) I cannot seem to store the results from the webrequest into the database. Storing fixed results in the database works fine, but I don't know how to store the (variable) webresults into the database. I am getting constant sql-error. The sql-statement with a fixed surname (for instance "McCloud") works fine  and looks like:



I am stock with regard to the proper syntax for storing a variable from the datasource into the table "test"
I have tried to find example sql-statements but haven't found any. The variable I am trying tot store is ${DataSource#surname}
Can anyone please help?

Kind regards

4 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    You are specifying variable in a right way.
    Can you send the sql query?What is the exact error that you get?

    Regards,
    /Dragica
    eviware.com
  • IP's avatar
    IP
    Occasional Contributor
    Hi,

    Sorry for the missing sql-query.

    The working sql-query (fixed value) is:                            insert into test(naam) values ('1')
    The not-working sql-query (variable)                                insert into test(naam) values (${DataSource#surname})
    The error I get with the last query is: "java.lang.Exception: SQL problem occured"
    Kind regards
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    It looks like you need to enclose the value in quotes in the second statement. Try something like:
    insert into test(naam) values (${'DataSource#surname'})
  • IP's avatar
    IP
    Occasional Contributor
    Hi,

    Thanks for the reply. Indeed it helped by using the statement:

    insert into test(naam) values ("${DataSource#surname}")

    (so, using the double marks '.."..' instead of the single mark '..'..' ). No error occurs anymore and the value of the recent surname-value is inserted. Thanks very much. I'll continue exploring your program ;-)

    kind regards