S
S
sflyer2017-04-06 07:15:08
PHP
sflyer, 2017-04-06 07:15:08

Php+Oracle increment by invalid variable name/number, how to write correctly?

$compiled = oci_parse($conn, "alter sequence SQ_TEST increment by :id");
oci_bind_by_name($compiled, ":id", $VAL);
$result =oci_execute($compiled, OCI_DEFAULT);

There is some code that reduces the value of sequence. The request works without PHP. The problem is that (as I understand it) he doesn't like the :id variable. The value of $VAL is not empty.
How to correctly pass the value?
Errors:
Warning: oci_bind_by_name(): ORA-01036: invalid variable name/number in /var/www/html/test/new_year.php on line 11
Warning: oci_execute(): ORA-01722: invalid number in /var/www /html/test/new_year.php on line 12

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2017-04-07
@sflyer

According to the doc , he slips the automatic type SQLT_CHR there, which will automatically be cast to the desired type in the case of SELECT. Because you have DDL here, I think that you need to explicitly specify type=SQLT_INT.

V
Vapaamies, 2017-04-07
@vapaamies

I have a vague suspicion that Oracle doesn't support bind variables for DDL. You can also try specifying "id" without a colon in oci_bind_by_name.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question