Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'ORA-01009: missing mandatory parameter' during select for CLOB columns on 2.8.13 #549

Closed
stle04 opened this issue Apr 25, 2024 · 2 comments
Labels
duplicate This issue or pull request already exists fixed

Comments

@stle04
Copy link
Contributor

stle04 commented Apr 25, 2024

Hi
I faced with issue

I have a table

CREATE TABLE testclob(
    data1 CLOB,
    data2 CLOB,
    n NUMBER
);

and the code for selecting data from that table

package main

import (
	"context"
	"database/sql"
	"fmt"
	_ "github.com/sijms/go-ora/v2"
	ora "github.com/sijms/go-ora/v2"
)

const url = "oracle://user:pass@localhost:1521/XE"

func main() {
	ctx := context.TODO()

	db, err := sql.Open("oracle", url)
	if err != nil {
		fmt.Println("Can't open database: ", err)
		return
	}
	defer func() {
		err = db.Close()
		if err != nil {
			fmt.Println("Can't close database: ", err)
		}
	}()

	conn, err := db.Conn(ctx)
	if err != nil {
		fmt.Println("Can't open connection: ", err)
		return
	}
	defer func() {
		err = conn.Close()
		if err != nil {
			fmt.Println("Can't close connection: ", err)
		}
	}()

	err = selectTestClob(ctx, conn, 1)
	if err != nil {
		fmt.Println("Can't select: ", err)
	}

	fmt.Println("ok")
}

func selectTestClob(
	ctx context.Context,
	conn *sql.Conn,
	n int,
) (err error) {
	var rows *sql.Rows
	rows, err = conn.QueryContext(
		ctx,
		`
SELECT DATA1, DATA2
FROM testclob
WHERE
  n = :1
`,
		n,
	)
	if err != nil {
		return fmt.Errorf("can't select: %w", err)
	}

	for rows.Next() {
		var data1 sql.NullString
		var data2 sql.NullString
		err = rows.Scan(&data1, &data2)
		fmt.Println("[selectTestClob] ", data1, data2)
	}
	return nil
}
@stle04
Copy link
Contributor Author

stle04 commented Apr 25, 2024

The output of that code is

Can't select:  can't select: ORA-01009: missing mandatory parameter

@sijms sijms added duplicate This issue or pull request already exists fixed labels Apr 25, 2024
@sijms
Copy link
Owner

sijms commented Apr 25, 2024

fixed v2.8.14

@sijms sijms closed this as completed Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists fixed
Projects
None yet
Development

No branches or pull requests

2 participants