Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Inserting values in DB from the transformed response

sujaldalia
sujaldalia Posts: 27

Hi,
I'm using style sheet to transform my response into something I care about from the fields standpoint.
What I want to do is extract the values from the transformed response and insert that in the DB

My transformed xml is looking like this



2017-10-17T13:45:00.61-04:00
9476102124
HIGH_SPEED_DATA
1
choice
WiFi
Business Wi-Fi Standard
2482984091
0
0
0
true
53
1
1


2017-10-17T13:45:00.61-04:00
9476102124
HIGH_SPEED_DATA
1
choice
WiFi
Wifi PRO 2 Access Point - Commercial
2482983445
34.9
99.9
0
false
200
1
59

Any help is greatly appreciated

Thanks,
Sujal

Comments

  • benken_parasoft
    benken_parasoft Posts: 1,302 ✭✭✭

    You need to determine what SQL statement you want to execute then use a DB Tool to execute that statement. You can reference data bank columns in your SQL statement with ${colName} syntax. For example, you may have a SQL statement like INSERT INTO MyTable VALUES (${dateCol}, ${idCol}, ${nameCol})

  • sujaldalia
    sujaldalia Posts: 27

    Thats exactly what I tried but I was not able to loop through the fields. I'm attaching the transformed xml for an example

  • benken_parasoft
    benken_parasoft Posts: 1,302 ✭✭✭

    Whenever you need to loop over something like that a Writable Data Source is probably want you want. You can configure a Data Bank to write the values across multiple rows of a Writable Data Source. Next, parameterize your DB Tool against the writable data source.

    I don't have an example, offhand. However, I think there are other examples on the forum about how to use a Writable Data Source.

  • sujaldalia
    sujaldalia Posts: 27

    I have worked with Writable Data Source so I can get the data in. Do you have any exampl on how to parameterize DB Tool against the writable data source by any chance?

  • benken_parasoft
    benken_parasoft Posts: 1,302 ✭✭✭

    Parameterizing tools works exactly the same way, regardless of whether it is a data bank column or a writable data source column or a some other data source column. In the DB Tool, make sure the data source you want to use is selected in the upper-right corner of the tool editor. After that, use ${columnName} syntax to reference the columns from the data source you are using.

    As mentioned, I don't have any examples right now. Generally, I am only able to provide quick answers on the forum.