我需要有关plsql函数的一些帮助

时间:2019-05-14 12:32:21

标签: sql oracle plsql

我要选择employee_id小于200的薪水总和。这是我的代码。

declare 
  emp_id number;
  x number;
  function sum_max_salary (emp_id in number)    
    return number 
  is 
    v_result number;
  begin 
    select sum(salary) into v_result from employees 
     where employee_id<200;
    return v_result;
  end;
begin
  emp_id:=200;
  x:=sum_max_salary(emp_id);
  dbms_output.put_line(sum_max_salary);
end;

以上过程给我一个错误:

  

ORA-06550:第16行,第22列:PLS-00306:调用“ SUM_MAX_SALARY”时参数的数量或类型错误

     

ORA-06550:第16行,第1列:PL / SQL:忽略了06550语句。00000-“%s行,%s列:\ n%s” *原因:通常是PL / SQL编译错误。 *动作:–

我需要帮助来找到问题。

2 个答案:

答案 0 :(得分:2)

如果您只想执行SQL:

select sum(salary) 
from employees 
where employee_id<200;

如果要使用PL / SQL进行操作

set servoutput on
declare 
emp_id number;
x number;
function sum_max_salary (emp_id in number)


return number 
is 
v_result number;
begin 
select sum(salary) into v_result from employees 
where employee_id<emp_id;
return v_result;
end;
begin
emp_id:=200;
x:=sum_max_salary(emp_id);
dbms_output.put_line(x);
end;

答案 1 :(得分:0)

问题在线了

public static class AzureBlobStorageClient
{
    public static CloudBlobClient GetClient(string AccountName = "foo", string AccountKey = "bar" )
    {
        try
        {

            var connectionString = $"DefaultEndpointsProtocol=https;AccountName={AccountName};AccountKey={AccountKey};EndpointSuffix=core.windows.net";
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
            IRetryPolicy exponentialRetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(2), 10);
            blobClient.DefaultRequestOptions.RetryPolicy = exponentialRetryPolicy;
            return blobClient;
        }
        catch (StorageException ex)
        {
            Console.WriteLine("Error returned from the service: {0}", ex.Message);
            throw;
        }
    }

    public static void DeleteContainer(CloudBlobContainer container)
    {
        var result = container.DeleteIfExistsAsync().Result;
    }

    public static List<CloudBlobContainer> GetContainers()
    {
        var client = GetClient();
        BlobContinuationToken continuationToken = null;
        List<CloudBlobContainer> results = new List<CloudBlobContainer>();
        do
        {
            var response = client.ListContainersSegmentedAsync(continuationToken).Result;
            continuationToken = response.ContinuationToken;
            results.AddRange(response.Results);
        }
        while (continuationToken != null);

        return results;
    }

}

您可能想做

dbms_output.put_line(sum_max_salary);

dbms_output.put_line(x); 和功能的结果