CALL

CALL is used to invoke a predefined procedure. For the complete listing of availble procedures see Procedures.

Syntax

CALL procedure_name([parameter[,...]]);

The CALL statement is used as follows:

  1. The procedure_name indicates the procedure to invoke. The procedure name must followed by parentheses surrounding all its parameters.
  2. The procedure may take one or more IN parameters.

    Example: to create a simple text file named test.txt in the document library Shared Documents:

    CALL UPLOAD('Shared Documents', 'test.txt', 'This is a small text file..');

  3. Like with other statements, procedures can produce result sets.

    Example: to download the file named test.txt from the document library Shared Documents:

    CALL DOWNLOAD('Shared Documents', 'test.txt');

    In this case, the procedure will produce a scalar binary value.

  4. When the procedure returns, the application can obtain the number of rows affected through the LastRecordsAffected property and the ID of the last inserted item through the LastInsertedId property of the SharePointCommand class if the procedure supports this. The UPLOAD() procedure, to mention one, cannot suppport this because the command does not query the actual list directly.

Code examples

Create folder

using (var connection = new SharePointConnection(connectionString))
{
    connection.Open();
    using (var command = new SharePointCommand(@"CALL CreateFolder('Shared Documents', 'Images')", connection))
    {
        command.ExecuteNonQuery();
        Console.WriteLine("ID = " + command.LastInsertedId);
    }
}

Code result

ID = 4

Upload document

using (var connection = new SharePointConnection(connectionString))
{
    connection.Open();
    using (var command = new SharePointCommand(@"CALL UPLOAD('Shared Documents', 'Images/bendsoft.jpg', @doc)", connection))
    {
        command.Parameters.Add("@doc", System.IO.File.ReadAllBytes(@"C:\bendsoft.jpg"));
        command.ExecuteNonQuery();
    }
}

Download document

using (var connection = new SharePointConnection(connectionString))
{
    connection.Open();
    using (var command = new SharePointCommand(@"CALL DOWNLOAD('Shared Documents', 'Images/bendsoft.jpg')", connection))
    {
        byte[] data = (byte[])command.ExecuteScalar();
        Console.WriteLine("Date length = " + data.Length);
    }
}

Code result

Date length = 20140

Copy document

using (var connection = new SharePointConnection(connectionString))
{
    connection.Open();
    using (var command = new SharePointCommand(@"CALL COPY('Shared Documents', 'Images/bendsoft.jpg', 'Shared Documents', 'Images/bendsoft_backup.jpg')", connection))
    {
        command.ExecuteNonQuery();
    }
}

Delete document

using (var connection = new SharePointConnection(connectionString))
{
    connection.Open();
    using (var command = new SharePointCommand(@"CALL DELETE('Shared Documents', 'Images/bendsoft.jpg')", connection))
    {
        command.ExecuteNonQuery();
    }
}

Rename document

using (var connection = new SharePointConnection(connectionString))
{
    connection.Open();
    using (var command = new SharePointCommand(@"CALL RENAME('Shared Documents', 'Images/bendsoft_backup.jpg', 'Images/bendsoft.jpg')", connection))
    {
        command.ExecuteNonQuery();
    }
}


Skip Navigation Links.

Visa     MasterCard