S
S
shedward2013-05-08 16:31:28
JavaScript
shedward, 2013-05-08 16:31:28

Using execute method parameters in stored procedures?

Question to those who worked with VKontakte stored procedures.
There is a stored procedure that looks for groups with audio recordings:

var q;
var groups = API.groups.search({"q": q});
if (groups.length == 0) {
    return {};
}

var i = 1;
var res = [];
while (i < groups.length - 1){
    i = i + 1;
    var grp = groups[i];
    var songs = API.audio.getCount({oid: -grp.gid});
    if ( songs > 1 &&
        (grp.is_closed == 0 || grp.is_member == 1)) 
    {
        res = res + [{"songs" : songs,
                        "gid" : grp.gid,
                        "name" : grp.name,
                        "screen_name" : grp.screen_name,
                        "photo": grp.photo}];
    }
}
return  res;

On the Create Stored Procedures page it says:
You can call the stored procedures created in the interface using the following construction:
api.vk.com/method/execute.PROCEDURE_NAME?PARAMETER_LIST... The passed
parameters will be available inside the procedure code as ordinary variables.

Tell me what does that mean?
If you do not declare var q, then it swears at an unknown literal.
What do I need to do to pass the q value in the request and use it in the code?
To be honest, I have no experience with JavaScript, let alone ECMAScript.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stepan, 2013-05-08
@L3n1n

Does your example even work? :)
To pass parameters to execute use:

var q=Args.q;

The q variable can be sent as a GET or POST request.
PS: When working with VKScript, any experience will not help ... Almost no logic works there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question