0

I'm looking for a solution to browse a complete data extension, row per row without value of reference in a cloud page. Let's say the I have a data extension called "myDE" with only 1 column (email) and I want to retrieve all the values of these email addresses starting with the 1st line, then the 2nd, the third etc etc like this:

Set @nbRow = DataExtensionRowCount("myDE")

for @x = 1 to @nbRow do

    Set @myEmail = Lookup("myDE","email","XX",@x)

next @x

I can't find any way to say instead of "XX", "my line number" and the put the @x variable to specify which row to check.

Thanks in advance!

7
  • @martin do you want retrieve the all emails without using particular value?
    – Ravi.A
    Apr 11, 2018 at 11:59
  • @pkharries Yes exactly. I don't want to compare 2 values to obtain the value of the email column. (in example, I don't have to retrieve the email of the user named "martin", but every email in the data extension)
    – G. Martin
    Apr 11, 2018 at 12:02
  • @martin you can retrieve the emails through ampscript code or other code mean server side javascript
    – Ravi.A
    Apr 11, 2018 at 12:05
  • @pkharrie Ampscript only will be perfect cause I have a lot of other calculations behind.
    – G. Martin
    Apr 11, 2018 at 12:09
  • @martin use any default value in DE based on that value you can retrieve all records of email
    – Ravi.A
    Apr 11, 2018 at 12:34

1 Answer 1

0

You can't do a lookup without specifying a value. I'd recommend adding a lookupKey column to your data extension and giving it a default value of 1.

After you ensure that all rows have the default value, you can utilize it with lookupRows().

Here's an example I did for a client:

%%[
var @rows, @row, @rowCount, @numRowsToReturn, @lookupValue, @i

set @lookupValue = 1
set @numRowsToReturn = 0 /* All */
set @rows = LookupOrderedRows("Master_Summary",@numRowsToReturn,"Action asc","lookupKey", @lookupValue)
set @rowCount = rowcount(@rows)
set @total = 0

if @rowCount > 0 then

  for @i = 1 to @rowCount do

    var @Count, @Created, @Action
    set @row = row(@rows,@i)
    set @Action = field(@row,"Action")
    set @Count = field(@row,"Count")
    set @Created = field(@row,"Created")

    set @total = add(@total,@count)

    if @i == 1 then
        output(concat("<h3>MasterDaily Summary</h3>"))
        output(concat("<b>Run Date:</b> ",@Created,"<br><br>"))
        output(concat("<table border='1' cellpadding='5' cellspacing='0'>"))
        output(concat("<thead>"))
        output(concat("<tr>"))
        output(concat("<td><b>Action</b></td>"))
        output(concat("<td align='right'><b>Count</b></td>"))
        output(concat("</tr>"))
        output(concat("</thead>"))
        output(concat("<tbody>"))
    endif

    output(concat("<tr>"))
    output(concat("<td>",@Action,"</td>"))
    output(concat("<td align='right'>",format(@Count,"n0"),"</td>"))
    output(concat("</tr>"))

    if @i == @rowCount then
      output(concat("<tr>"))
      output(concat("<td><b>Total</b></td>"))
      output(concat("<td align='right'><b>",format(@total,"n0"),"</b></td>"))
      output(concat("</tr>"))
      output(concat("</tbody>"))
      output(concat("</table>"))
    endif

  next @i


else

 raiseError("No counts found")

endif

]%%

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .