'SQL Code' activity example




Can someone please guide me how to use 'SQL Code' activity in Adobe Campaign with an example? A help in this regard will be highly appreciated.





Hi Manish,

The SQL Queries in the Workflow can be directly used in the JavaScript Activity.

The Syntax to do so is given below :

1. var sqlQuery=("Select iworkflowid, ifailed from xtkworkflow where sinternalname='abc''');

    var wfState=sqlSelect("publicUrl,@getWfID:int,@getWfFailedStatus:int",sqlQuery);


    Note # @getWfID -> getWfID is the variable name (anything you may give), and int is datatype of the value which will be returned            by SQL Query.

     Also, if you want to use this variable somewhere in your JS, then you may refer to this variable by below Syntax :


2. Or if you want to use the SQL Code activity to write the SQL Queries in the workflow, then you can use the below syntax:

   INSERT INTO nmsabc VALUES (1, 1, 'first' , 'OK', '2000-01-01 00:00:00+02', '2000-01-01 00:00:00+02', '2000-01-01 00:00:00+02');

3. Third option is that you can directly run the SQL Queries in Using The JavaScript activity by writing the below syntax in JS :

     sqlExec("update sbc set tspreviousruntime = '"+getDate()+"' where iid = '123'");