将Oracle Sequence Nextval返回到C#变量

时间:2017-04-25 14:10:25

标签: c# oracle

我正在尝试从oracle序列返回nextval并将值保存到变量中,我不是使用Oracle和C#的专家,直到现在我已完成连接并且我已经使用了一些带有c#的Oracle包。

我知道我可以将[sequence_name] .nextval用于插入查询但是对于业务逻辑我需要为许多记录使用相同的序列号,并且想法是将nextval存储到变量中并将其像参数一样传递给另一个c#将负责将“n”记录插入表中的函数。

任何提示或代码示例都会有所帮助,非常感谢您的帮助。

1 个答案:

答案 0 :(得分:5)

您可以使用final_data <- NULL for (ptcp in unique(data$Participant)) { # subset to chose each participant new_data <- data[which(data$Participant==ptcp), ] # Check if Non-cognate and Cognate are equal if ( length(which(new_data$Cognate=="Non-cognate")) == length(which(new_data$Cognate=="Cognate")) ) break # Check if have more Non-cognate than Cognate if ( length(which(new_data$Cognate=="Non-cognate")) > length(which(new_data$Cognate=="Cognate")) ) { # Loop while they are not equal while (length(which(new_data$Cognate=="Non-cognate")) > length(which(new_data$Cognate=="Cognate"))) { # Removes the first row of "non-cognate id <- which(new_data$Cognate=="Non-cognate") new_data <- new_data[-id[1],] } # Check if have more Cognate than Non-cognate } else if ( length(which(new_data$Cognate=="Cognate")) > length(which(new_data$Cognate=="Non-cognate")) ) { # Loop while they are not equal while (length(which(new_data$Cognate=="Cognate")) > length(which(new_data$Cognate=="Non-cognate"))) { # Removes the first row of "non-cognate id <- which(new_data$Cognate=="Cognate") new_data <- new_data[-id[1],] } } # Combine each user to final_data final_data <- rbind(final_data, new_data) }

获取nextval
OracleCommand