Skip to main content
Nov 6, 2020 6:25 PM UTC
Solved

Adobe Campaign Classic API - Javascript sqlGetString function not working

Hi Adobe Community,

 

I've have been attempting to use the 'sqlGetString' function available within the Adobe Campaign Classic API to test whether a value exists (and return it) within the recipient table. Unfortunately I seem unable to get it to work. Below is the Javascript function as it stands:

 

function checkIfValueExists(str){ try { var val = sqlGetString("SELECT sText2 From NmsRecipient WHERE sText2 = $(sz) LIMIT 1", str); return val.toString(); } catch (e){ return e.toString(); } }

 

  If I change the SQL query to:

 

var val = sqlGetString("SELECT sText2 From NmsRecipient WHERE sText2 = 'ETFX2K' LIMIT 1", str);

 

I seem to the error: 'Error: SCR-160021 Function 'sqlGetString': too many arguments (2 instead of 1).'

 

According to the documentation found here, it should accept two parameters. Maybe i'm going wrong somewhere within my SQL syntax. Would you know what might be causing this? 

Thanks for any help you can offer.

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Jonathon_wodnicki
Jonathon_wodnickiAccepted solution
Community Advisor
Nov 9, 2020 5:51 PM UTC

Hi,

 

If possible, use xtk instead of sql.

The arity of the sqlGet* functions is determined by the number of bind variables in the query, +1 for the query itself.

In the second example there are zero bind vars so it expects 1 arg.

 

Thanks,

-Jon

2 replies

Jonathon_wodnicki
Community Advisor
Jonathon_wodnickiCommunity AdvisorAccepted solution
Community Advisor
Nov 9, 2020 5:51 PM UTC

Hi,

 

If possible, use xtk instead of sql.

The arity of the sqlGet* functions is determined by the number of bind variables in the query, +1 for the query itself.

In the second example there are zero bind vars so it expects 1 arg.

 

Thanks,

-Jon

Translate
Sukrity_Wadhwa
Level 4
Nov 17, 2020 9:55 AM UTC

Hi @aquaticads,

Was the given solution helpful to resolve your query? Do let us know.

Thanks!

Translate
Sukrity Wadhwa