MCPcopy Create free account
hub / github.com/bytebase/bytebase / addLimitFor12cAndLater

Function addLimitFor12cAndLater

backend/plugin/db/oracle/query.go:209–221  ·  view source on GitHub ↗

addLimitFor12cAndLater adds a FETCH NEXT clause for Oracle 12c and later versions. Uses the modern SQL standard approach, falling back to 11g approach on error.

(statement string, limit int)

Source from the content-addressed store, hash-verified

207// addLimitFor12cAndLater adds a FETCH NEXT clause for Oracle 12c and later versions.
208// Uses the modern SQL standard approach, falling back to 11g approach on error.
209func addLimitFor12cAndLater(statement string, limit int) string {
210 if !isSelectOrWithStatement(statement) {
211 return statement
212 }
213
214 stmt, err := addFetchNextClause(statement, limit)
215 if err != nil {
216 slog.Error("failed to add FETCH NEXT clause, falling back to ROWNUM",
217 slog.String("statement", statement), log.BBError(err))
218 return addLimitFor11g(statement, limit)
219 }
220 return stmt
221}
222
223// addFetchNextClause adds a FETCH NEXT clause to a SELECT statement using AST parsing.
224// This provides more precise placement of the limit clause compared to simple string wrapping.

Calls 6

BBErrorFunction · 0.92
isSelectOrWithStatementFunction · 0.85
addFetchNextClauseFunction · 0.85
addLimitFor11gFunction · 0.85
StringMethod · 0.65
ErrorMethod · 0.45