Comments (6)
Hey guys!
Just to keep you posted, I've just pushed an update that is related to procedure and cursor on v2.3.0. Example usage can be found at https://github.com/yajra/laravel-oci8/wiki/Oracle-Cursor.
Regards!
from laravel-oci8.
Hi,
there's an other way for using the returned cursor:
use Yajra\Pdo\Oci8;
use Yajra\Pdo\Oci8\Statement;
$conn = new Oci8(
'oci:dbname=localhost:1521/xe;charset=UTF8',
'user',
'pass'
);
$stmt = $conn->prepare("BEGIN TEST_PKG.GET_RECORDS(:cursor); END;");
$stmt->bindParam(':cursor', $cursor, PDO::PARAM_STMT);
$stmt->execute();
$cursor_stmt = new Statement($cursor, $conn, [
PDO::ATTR_CASE => PDO::CASE_LOWER
]);
$cursor_stmt->execute();
foreach ($cursor_stmt->fetchAll(PDO::FETCH_ASSOC) as $item) {
print_r($item);
}
$conn->closeCursor($cursor);
Thanks for your effort creating and maintaining this package!
Peter
from laravel-oci8.
Honestly haven't tried this on procedure yet but you can try using DB::select()
.
On the other hand, you can also use DB::transaction
. Have used it for an oracle function.
DB::transaction(function($conn)
{
$filename = Input::get('filename');
$pdo = $conn->getPdo();
$sql = "begin :ret := check_if_file_exists(:filename); end;";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':ret',$exists);
$stmt->bindParam(':filename',$filename);
$stmt->execute();
if ($exists)
{
....
}
});
from laravel-oci8.
BTW, if the suggestions above did not work, please provide feedback for any error you may encounter. Will also try to use procedure on my free time. Thanks!
from laravel-oci8.
I made a solution that i'm pretty sure is not the best, but was able to use a stored procedure that returns a cursor by using (the cursor result will be in $array):
$sql = "begin sgc.pintegracaomodoffline.ListaCidade(:pTabResultado, :pCodRetorno, :pMsgRetorno); end;"
return DB::transaction(function($conn) use ($sql){
$pdo = $conn->getPdo();
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':pTabResultado', $lista, PDO::PARAM_STMT);
$stmt->bindParam(':pCodRetorno', $cod, PDO::PARAM_INT);
$stmt->bindParam(':pMsgRetorno', $text, PDO::PARAM_STR, 100);
$stmt->execute();
oci_execute($lista, OCI_DEFAULT);
oci_fetch_all($lista, $array, 0, -1, OCI_FETCHSTATEMENT_BY_ROW + OCI_ASSOC );
oci_free_cursor($lista);
return $array;
});
from laravel-oci8.
@TiagoGoddard thanks for sharing your solution! This is a good reference when the time comes for me to use stored procedures too. 🍻
from laravel-oci8.
Related Issues (20)
- Materialized view HOT 2
- Case Sensitivity Issue with Alias Names HOT 2
- Improve pagination for newer oracle
- "sessionVars" config are ignored HOT 1
- Binding driver options are ignored when calling addBindingsToStatement method HOT 4
- OCI_DEFAULT Undefined HOT 2
- lock/lockForUpdate locks up all rows even combined with limit (Job Queue becomes unusable on large table) HOT 3
- Updating model with multiple blob columns fails
- DRCP Connection Pooling HOT 4
- Undefined type 'Yajra\Oci8\Oci8ServiceProvider'. HOT 5
- Method Yajra\Oci8\Schema\Grammars\OracleGrammar::compileColumns does not exist. HOT 2
- v10.4.3 introduced SQL error in SELECT FOR UPDATE HOT 4
- OracleProcessor.php function processColumns donot return key "auto_increment" HOT 2
- OCI_SUCCESS_WITH_INFO: ORA-28002: the password will expire within 13 days HOT 2
- Laravel 11 support is on the road? HOT 5
- [11.x] This database engine does not support inserting while ignoring errors.
- [11.x] Error Code : 942 Error Message : ORA-00942, Sessions table HOT 1
- Support PHP 8.3 With Laravel 10.x HOT 1
- Error LogicException This database driver does not support modifying columns HOT 1
- `Schema::dropIfExists()` not working in 11.2.2+ HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-oci8.