WANTED: Best way to assign Variables from Database

Label printing integration (NiceWatch middleware and ActiveX programming interface)

Moderators: Georges, milos, NiceLabel Support Team

Post Reply
Posts: 6
Joined: Fri Mar 20, 2015 8:20 pm

WANTED: Best way to assign Variables from Database

Post by JMASEK » Fri Mar 20, 2015 8:56 pm

HI, All

I created the following generic Printjob interface in msSQL Server:

Table Printjob with fields: JobID (PK), Status, Lable, Printer, Quantity
Table Variables with: JobID (FK), VarName, VarValue

Using Automation Enterprise that Triggers to Printjob Entries with Status ='NEW'
I want to assign all the Variables as found by the Query: SELECT Varname, VarValue FROM Variables WHERE JobID=...

Is there an easy way to do that, without creating some temporary File that needs to be parsed in a second step.

Any ideas, samples?

Thank and best regards


p.S: We suggest the Varnames returned from the Query also exist in the Lable

User avatar
Posts: 2984
Joined: Mon Sep 04, 2006 8:09 am

Re: WANTED: Best way to assign Variables from Database

Post by Saso » Tue May 12, 2015 8:54 pm

Hi Jiri,

You would do the following:
  • Use action Execute SQL Statement to run your SELECT statement.
  • You would store the returned dataset in the variable.
    pic-dataset variable.png
    pic-dataset variable.png (13.48 KiB) Viewed 2269 times
    The returned dataset is provided with the CSV structure (including field names in the first row), so you can easily parse it with filter.
  • You would define the Structured Text filter with enabled Dynamic structure option.
    pic-filter.png (18.45 KiB) Viewed 2269 times
  • You would define the action Use Data Filter, which would run the Structured Text filter upon the value of the variable containing dataset returned from SQL query.
    pic-run data filter.png
    pic-run data filter.png (21.64 KiB) Viewed 2269 times
  • Enabled 'Dynamic structure' will extract all field name:value pairs and automatically map them to the variables of the same name on the label.
  • Just make sure that the variables on the label have the same names as database fields, so the automatic mapping will work and you are done.
Saso Fleiser
Senior Technical Product Specialist

Post Reply