假设我有一个表和一个接受表rowtype的一个参数的过程:
CREATE TABLE t (a NUMBER, b NUMBER);
CREATE PROCEDURE p (x t%ROWTYPE) IS
BEGIN
NULL;
END;
我是否可以使用rowtype文字调用该过程,即没有显式创建rowtype变量(或者至少没有明确列出并分配它的每个字段)?以下两种方法都会产生以下错误:
p(1, 2);
p((1, 2));
PLS-00306:调用'P'
时参数的数量或类型错误
答案 0 :(得分:1)
您还可以从游标循环构建记录:
[.kibana][[.kibana][0]] DocumentAlreadyExistsException[[dashboard][New-Dashboard]: document already exists]
at org.elasticsearch.index.engine.InternalEngine.innerCreateNoLock(InternalEngine.java:411)
at org.elasticsearch.index.engine.InternalEngine.innerCreate(InternalEngine.java:369)
at org.elasticsearch.index.engine.InternalEngine.create(InternalEngine.java:341)
at org.elasticsearch.index.shard.IndexShard.create(IndexShard.java:517)
at org.elasticsearch.index.engine.Engine$Create.execute(Engine.java:789)
at org.elasticsearch.action.support.replication.TransportReplicationAction.executeIndexRequestOnPrimary(TransportReplicationAction.java:1073)
at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:170)
at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryPhase.performOnPrimary(TransportReplicationAction.java:579)
at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryPhase$1.doRun(TransportReplicationAction.java:452)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
不幸的是,PL / SQL记录只是简单的结构,并不像对象类型那样带有构造函数。 (我希望他们这样做。)
答案 1 :(得分:0)
这不是最佳解决方案,因为它(a)需要创建变量而(b)不是很漂亮。但至少它有效:
UPDATE u
SET u.time_code = tcu.time_code
FROM users u INNER JOIN time_code_users tcu
ON u.user_name = tcu.user_name
我仍然对更好的解决方案感兴趣。