Google Cloud Bigtable与Google Cloud Datastore(Google Cloud Bigtable vs Google Cloud Datastore)
Google Cloud BigTable和Google Cloud Datastore / App Engine数据存储区有什么区别,主要的实际优点和缺点是什么? AFAIK Cloud Datastore建立在Bigtable之上。
What is the difference between Google Cloud Bigtable and Google Cloud Datastore / App Engine datastore, and what are the main practical advantages/disadvantages? AFAIK Cloud Datastore is build on top of Bigtable.
原文:https://stackoverflow.com/questions/30085326
最满意答案
v_cnt
未初始化,即在第一次调用dbms_output.put_line
IS NULL
,因此您在输出中看到一个空行而不是行号。- 最后一次获取不执行任何操作,因为游标中没有更多行,因此变量
i, a, j
在最后一次获取后不会更改。 您可以根据需要获取,但是在从游标中取出最后一行之后,FETCH INTO
运算符不会生成新数据。为了得到你需要的东西(标准循环行为),抓取循环应该被组织为
LOOP FETCH c1 INTO i, a, j; EXIT WHEN c1%NOTFOUND; v_cnt := c1%ROWCOUNT; dbms_output.put_line(i || ' ' || a || ' SALARY IS ' || j || ' row count is ' || v_cnt); END LOOP;
为了避免与获取光标相关,可以使用“for loop”来完成。 在大多数情况下,这是一个合适的解决方案,绝对是您在问题中提供的示例。
FOR l_rec IN c1 LOOP i := l_rec.first_name; a := l_rec.last_name; j := l_rec.salary; v_cnt := c1%ROWCOUNT; dbms_output.put_line(i || ' ' || a || ' SALARY IS ' || j || ' row count is ' || v_cnt); END LOOP;
v_cnt
is not initialized i.e.IS NULL
on the first call ofdbms_output.put_line
, so you see an empty line instead of row number in the output.- The last fetch makes no action, because there are no more rows in cursor, so variables
i, a, j
doesn't change after last fetch. You may fetch as long as you want, but after the last row has been fetched out of cursor theFETCH INTO
operator produces no new data.To get what you need (standard loop behavior) the fetching loop shall be organized as
LOOP FETCH c1 INTO i, a, j; EXIT WHEN c1%NOTFOUND; v_cnt := c1%ROWCOUNT; dbms_output.put_line(i || ' ' || a || ' SALARY IS ' || j || ' row count is ' || v_cnt); END LOOP;
To avoid compliactions with fetching a cursor you can do it using "for loop". This is an appropriate solution in the most cases, and definitely in the case of example you gave in the question.
FOR l_rec IN c1 LOOP i := l_rec.first_name; a := l_rec.last_name; j := l_rec.salary; v_cnt := c1%ROWCOUNT; dbms_output.put_line(i || ' ' || a || ' SALARY IS ' || j || ' row count is ' || v_cnt); END LOOP;
相关问答
更多-
游标属性%notfound,因为exit语句返回令人困惑的结果(Cursor attribute %notfound as exit statement returns confusing results)[2024-03-04]
v_cnt未初始化,即在第一次调用dbms_output.put_line IS NULL ,因此您在输出中看到一个空行而不是行号。 最后一次获取不执行任何操作,因为游标中没有更多行,因此变量i, a, j在最后一次获取后不会更改。 您可以根据需要获取,但是在从游标中取出最后一行之后, FETCH INTO运算符不会生成新数据。 为了得到你需要的东西(标准循环行为),抓取循环应该被组织为 LOOP FETCH c1 INTO i, a, j; EXIT WHEN c1%NOTFOUND; ... -
您的代码总是围绕循环两次,因此如果光标返回的行少于2行,则会失败。 您可能根本不需要循环: open c_getPrms(in_pnum); fetch c_getPrms into r_prmRecord; if c_getPrms%NOTFOUND then raise X_INVALID_PNUM; end if; close c_getPrms; 我宁愿完全避开光标,而是使用“select into”代替: begin select ... into r_prmReco ...
-
如果在switch case语句中没有使用break ,则代码不会在匹配的case评估中停止,而是继续执行下面的所有其他case语句,直到找到break或switch语句完成。 在这个例子中,第一个匹配的情况是针对x == 3执行的,然后它继续执行以下所有语句,结果导致17 。 您可以在此处详细了解原因 : 为什么switch语句需要休息? When you don't use break in your switch case statement, the code doesn't stop at the ...
-
1 + monthlyRate是1.0583... ,而不是1.00583 。 1 + monthlyRate is 1.0583..., not 1.00583.
-
“是否有可能在下面的FOR循环之后执行未找到的c_emp%” 不,这会抛出ORA-01001: invalid cursor 。 游标属性只有在游标打开时才有作用域,在此语法中,游标属性位于FOR和END LOOP 。 这是PL / SQL的一个丑陋的方面,但是恐怕你被卡住了。 "Is it possible to execute c_emp%notfound after the following FOR loop" No, that's going to hurl ORA-01001: invalid ...
-
令人困惑的SELECT语句(Confusing SELECT statement)[2022-10-15]
对于Oracle 9i +,请使用: SELECT x.fruit_name, x.fruit_id, x.fruit_owner FROM (SELECT mf.fruit_name, mf.fruit_id, mf.fruit_owner, ROW_NUMBER() OVER (PARTITION BY mf.fruit_name ... -
令人困惑的Perl数组行为(Confusing Perl Array behavior)[2023-11-27]
它返回一个数组引用。 尝试解除引用它: foreach ( @{ $specificRecord->ipv4addrs() } ) It's returning an array reference. Try dereferencing it: foreach ( @{ $specificRecord->ipv4addrs() } ) -
游标中需要%NOTFOUND(Need of %NOTFOUND in cursor)[2021-10-20]
有时只有一种方法可以做某件事。 大多数开发人员倾向于使用%NOTFOUND (至少在我的经验中)。 编辑 我不知道为什么PL / SQL语言的设计者给了我们%NOTFOUND 。 我会记得在我下次看到他时问布伦·卢埃林。 但我的猜测是,他们只是认为它会有用。 在编码方面,正如其他形式的写作一样,我们应该总是试图积极表达自己,因为积极性更清楚地表达了我们的意图。 那是, exit when c1%notfound; 那就更清楚了 exit when not c1%found; 但也许这只是一个品味问题。 ... -
我建议检查Google数据库中是否存在邮政编码。 例如,邮政编码H1A0C2似乎丢失了 https://google-developers.appspot.com/maps/documentation/utils/geocoder/#q%3D%26options%3Dtrue%26in_country%3DCA%26in_postal_code%3DH1A0C2 如您所见,地理编码器工具仅返回邮政编码前缀HA1 ,但不返回邮政编码本身。 邮政编码H1C0A9地理编码器返回完整的邮政编码: https://g ...
-
Measure-Command或StopWatch返回令人困惑/不准确的结果(Measure-Command or StopWatch Returning Confusing/Inaccurate Results)[2023-05-19]
Measure-Command将丢弃管道输出,仅测量实际执行命令所需的时间。 秒表计时器测量执行命令所需的时间,然后将所有输出显示到控制台。 要获取Measure-Command以测量写入控制台所需的时间,请在您正在测量的脚本块内向Out-Host添加显式管道。 然后,您应该看到写入控制台的输出,并相应增加完成的测量时间。 Measure-Command will discard the pipeline output, measuring only the time it takes to actuall ...