Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Adobe Campaign Classic API - Javascript sqlGetString function not working

Avatar

Avatar
Validate 1
Level 1
AquaticAds
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
AquaticAds
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
AquaticAds
Level 1

06-11-2020

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.

 

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
MVP
wodnicki
MVP

Likes

969 likes

Total Posts

1,091 posts

Correct Reply

513 solutions
Top badges earned
Establish
Affirm 500
Contributor
Shape 1
Give Back 100
View profile

Avatar
Establish
MVP
wodnicki
MVP

Likes

969 likes

Total Posts

1,091 posts

Correct Reply

513 solutions
Top badges earned
Establish
Affirm 500
Contributor
Shape 1
Give Back 100
View profile
wodnicki
MVP

09-11-2020

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

Answers (1)

Answers (1)

Avatar

Avatar
Validate 1000
Employee
Sukrity_Wadhwa
Employee

Likes

146 likes

Total Posts

884 posts

Correct Reply

35 solutions
Top badges earned
Validate 1000
Validate 500
Validate 250
Validate 100
Validate 25
View profile

Avatar
Validate 1000
Employee
Sukrity_Wadhwa
Employee

Likes

146 likes

Total Posts

884 posts

Correct Reply

35 solutions
Top badges earned
Validate 1000
Validate 500
Validate 250
Validate 100
Validate 25
View profile
Sukrity_Wadhwa
Employee

17-11-2020

Hi @AquaticAds,

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

Thanks!