Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: retrieving 'intervall Day' dataype from oracle db with php
jouinromain_at_campus.ie (Jouin Romain) wrote in message news:<15723136.0408190819.3622cf61_at_posting.google.com>...
> hi,
>
> I have an oracle column wich is of "INTERVAL DAY (1) TO SECOND (0)"
> type and I would like to retrieve data from it thanks to php.
> I tried something like : "select to_char(column) " but it doesn't give
> me any result :
> These instructions don't give errors, but neither results :
>
> $cursor = ora_open($id_connect);
> if (ora_parse($cursor, $sql))
> if(!ora_exec($cursor))
> echo "problem d'exec sur sql";
>
> $ncols = ora_numcols($cursor);// => give me =1
> $nrows = ora_numrows($cursor);// => give me =0
>
> Does anyone have an idea about what is going on ? And how can I
> retrieve data from an oracle "INTERVAL DAY" column ?
>
> Any help welcome.
> Regards.
> JR.
Using TO_CHAR works fine for me with Oracle 9.2, PHP 4.3.7 and PHP's OCI8 interface.
<?php
/*
Execute these statements in SQL*Plus before running the PL/SQL script:
drop table cjt; create table cjt (c1 INTERVAL DAY TO SECOND); desc cjt insert into cjt values (to_dsinterval ('15 08:30:01')); commit;
define("ORA_CON_UN", "scott"); define("ORA_CON_PW", "tiger"); define("ORA_CON_DB", "ORCL");
$conn = OCILogon(ORA_CON_UN, ORA_CON_PW, ORA_CON_DB);
if (!$conn) {
exit;
}
$query = 'select to_char(c1) c1 from cjt';
$stid = OCIParse($conn, $query);
OCIExecute($stid, OCI_DEFAULT);
while ($succ = OCIFetchInto($stid, $row)) {
foreach ($row as $item) {
echo ($item?htmlentities($item):' ')." ";
}
echo "<br>\n";
}
OCILogoff($conn);
?>
Received on Wed Aug 25 2004 - 01:40:42 CDT