Subject | Re: [firebird-php] Executing an insert sp in fb from php |
---|---|
Author | Umberto Masotti |
Post date | 2009-07-22T18:17:19Z |
Hi Oscar,
Oscar DarĂo Perdiguero ha scritto:
before final END, you can use a ibase_query(), because you transform
your stored procedure in an Selectable Stored Procedure.
// There are 31 parameters, If I counted correctly..., so take it as an
simplified example
$sql = "SELECT NCLIENTE FROM AGREGARCLIENTE (
?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
$parms = array ( $val1, $val2, $val3, ......... $val31);
$resrc = ibase_query ( $sql, $parms );
$row = ibase_fetch_object ( $resrc);
$ncliente = $row->NCLIENTE;
// your selectable stored procedure returns just one row.
Ciao.
Mimmo.
Oscar DarĂo Perdiguero ha scritto:
> Hi.Never tried it in my applications, but if you add SUSPEND statement just
>
> I have a SP that makes insert in a table like this one:
>
> CREATE PROCEDURE AGREGARCLIENTE (
> ...many fields .... OBSERVACIONES Varchar(255) )
> RETURNS (NCLIENTE Integer )
> AS
> BEGIN
> IF ((:IDCLIENTE IS NULL) OR (:IDCLIENTE = 0)) THEN
> NCLIENTE = GEN_ID(GIDCLIENTE, 1);
> ELSE
> NCLIENTE = :IDCLIENTE;
>
> INSERT INTO
> CLIENTES
> ( ... many fields .... )
> VALUES
> ( .... many values .... ); END^
>
>
> and I want to execute it from php and retrieve the resulting value, but
> I dont know how.
>
>
before final END, you can use a ibase_query(), because you transform
your stored procedure in an Selectable Stored Procedure.
// There are 31 parameters, If I counted correctly..., so take it as an
simplified example
$sql = "SELECT NCLIENTE FROM AGREGARCLIENTE (
?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
$parms = array ( $val1, $val2, $val3, ......... $val31);
$resrc = ibase_query ( $sql, $parms );
$row = ibase_fetch_object ( $resrc);
$ncliente = $row->NCLIENTE;
// your selectable stored procedure returns just one row.
Ciao.
Mimmo.