function

Select clausule inside pl/sql function return wrong value

試著忘記壹切 提交于 2020-05-09 17:15:14
问题 When I do this: select sum(m.mot) from rmtq mq join rmo m on mq.id = m.id where mq.another = 138; return value = 2, which is correct. But when I put this code inside a function: create or replace function get(another in number) return number is ret number := 0; begin select sum(m.mot) into ret from rmtq mq join rmo m on mq.id = m.id where mq.another = another return(ret); end; and I call: exec dbms_output.put_line(get(138)); return value = 39, which is incorrect. What is that 39? 回答1: The

bash command grouping for test results in function

瘦欲@ 提交于 2020-05-09 06:49:07
问题 I am accustomed to testing that a variable has a non-null value (or give a message and bail) using a line like this: test $variable || (echo "Value of \$variable cannot be null."; exit 1) I'm quite new to using functions in my scripts, but I've got a case where I need to be sure a non-null value is passed or bail out of the function. However the command grouping for the "or" case is not working the same way inside the function. I wrote this little test script to demonstrate: $ cat -n bubu.sh

How can I create a Perl subroutine that accepts more than one block?

孤者浪人 提交于 2020-05-09 01:16:33
问题 With prototypes, you can create a subroutine that accepts a block of code as its first parameter: sub example (&) { my $code_ref = shift; $code_ref->(); } example { print "Hello\n" }; How can I do the same thing, but with more than one block of code? I want to use blocks of codes, not variables or sub { ... } . This does not work: sub example2 (&&) { my $code_ref = shift; my $code_ref2 = shift; $code_ref->(); $code_ref2->(); } example2 { print "One\n" } { print "Hello\n" }; It gives this

How can I create a Perl subroutine that accepts more than one block?

倖福魔咒の 提交于 2020-05-09 01:15:46
问题 With prototypes, you can create a subroutine that accepts a block of code as its first parameter: sub example (&) { my $code_ref = shift; $code_ref->(); } example { print "Hello\n" }; How can I do the same thing, but with more than one block of code? I want to use blocks of codes, not variables or sub { ... } . This does not work: sub example2 (&&) { my $code_ref = shift; my $code_ref2 = shift; $code_ref->(); $code_ref2->(); } example2 { print "One\n" } { print "Hello\n" }; It gives this

How can I create a Perl subroutine that accepts more than one block?

。_饼干妹妹 提交于 2020-05-09 01:14:19
问题 With prototypes, you can create a subroutine that accepts a block of code as its first parameter: sub example (&) { my $code_ref = shift; $code_ref->(); } example { print "Hello\n" }; How can I do the same thing, but with more than one block of code? I want to use blocks of codes, not variables or sub { ... } . This does not work: sub example2 (&&) { my $code_ref = shift; my $code_ref2 = shift; $code_ref->(); $code_ref2->(); } example2 { print "One\n" } { print "Hello\n" }; It gives this

How can I create a Perl subroutine that accepts more than one block?

大城市里の小女人 提交于 2020-05-09 01:14:09
问题 With prototypes, you can create a subroutine that accepts a block of code as its first parameter: sub example (&) { my $code_ref = shift; $code_ref->(); } example { print "Hello\n" }; How can I do the same thing, but with more than one block of code? I want to use blocks of codes, not variables or sub { ... } . This does not work: sub example2 (&&) { my $code_ref = shift; my $code_ref2 = shift; $code_ref->(); $code_ref2->(); } example2 { print "One\n" } { print "Hello\n" }; It gives this

Why is a local function not always hidden in C#7?

 ̄綄美尐妖づ 提交于 2020-05-07 21:48:05
问题 What I am showing below, is rather a theoretical question. But I am interested in how the new C#7 compiler works and resolves local functions. In C#7 I can use local functions. For example (you can try these examples in LinqPad beta): Example 1: Nested Main() void Main() { void Main() { Console.WriteLine("Hello!"); } Main(); } DotNetFiddle for Example 1 Rather than calling Main() in a recursive way, the local function Main() is being called once, so the output of this is: Hello! The compiler

Why is a local function not always hidden in C#7?

假如想象 提交于 2020-05-07 21:48:04
问题 What I am showing below, is rather a theoretical question. But I am interested in how the new C#7 compiler works and resolves local functions. In C#7 I can use local functions. For example (you can try these examples in LinqPad beta): Example 1: Nested Main() void Main() { void Main() { Console.WriteLine("Hello!"); } Main(); } DotNetFiddle for Example 1 Rather than calling Main() in a recursive way, the local function Main() is being called once, so the output of this is: Hello! The compiler

Why is a local function not always hidden in C#7?

白昼怎懂夜的黑 提交于 2020-05-07 21:42:59
问题 What I am showing below, is rather a theoretical question. But I am interested in how the new C#7 compiler works and resolves local functions. In C#7 I can use local functions. For example (you can try these examples in LinqPad beta): Example 1: Nested Main() void Main() { void Main() { Console.WriteLine("Hello!"); } Main(); } DotNetFiddle for Example 1 Rather than calling Main() in a recursive way, the local function Main() is being called once, so the output of this is: Hello! The compiler

Why is a local function not always hidden in C#7?

て烟熏妆下的殇ゞ 提交于 2020-05-07 21:42:30
问题 What I am showing below, is rather a theoretical question. But I am interested in how the new C#7 compiler works and resolves local functions. In C#7 I can use local functions. For example (you can try these examples in LinqPad beta): Example 1: Nested Main() void Main() { void Main() { Console.WriteLine("Hello!"); } Main(); } DotNetFiddle for Example 1 Rather than calling Main() in a recursive way, the local function Main() is being called once, so the output of this is: Hello! The compiler