Sponsored Content
Top Forums Shell Programming and Scripting Perl + Oracle + bind_param_inout() Post 302182076 by mirage4d on Saturday 5th of April 2008 10:15:15 AM
Old 04-05-2008
Perl + Oracle + bind_param_inout()

Hi. I'm attempting to assign a variable via a field that is using an autoincrement sequence. I'm trying to use the Oracle bind_param_inout() procedure to pass the value by reference. The code goes a bit like this:

*************

my $sql=q(INSERT INTO MESSAGES (message_id, message_text, message_category, start_date, stop_date, admin_comments, time_submitted) VALUES (?,?,?,?,?,?,?) RETURNING message_id INTO ?);
my $sth=$dbh->prepare($sql);
die "Could not prepare query. Check SQL syntax."
unless defined $sql;
my $newMessageID;
$sth->bind_param_inout(8,\$newMessageID, 38);
$sth->execute('messages_id_pkseq.nextval', $messageText, $messageCategory, $startDate, $stopDate, $adminComments, $timeStamp);


****************

By example, bind_param_inout seems to by far the best way to retrieve the value, but the examples I have seen so far all assume no arguments to sth->execute(). In this case I have arguments in my execute statement, and that seems to be where my issues lie. Apache returns:

***
DBD::Oracle::st execute failed: called with 7 bind variables when 8 are needed [for Statement "INSERT INTO MESSAGES (message_id, message_text, message_category, start_date, stop_date, admin_comments, time_submitted) VALUES (?,?,?,?,?,?,?) RETURNING message_id INTO ?" with ParamValues: Smilie5=undef, Smilie6=undef, Smilie3=undef, Smilie7=undef, Smilie1=undef, Smilie8=undef, Smilie4=undef, Smilie2=undef]
***

Wondering if anyone could shed some light as to why the DB is expecting the eight value (the ? after the RETURNING clause); it should be assigned via the bind_param_inout() function by my understanding. Could very well be something I am missng here though. There may be a way to pass it in the execute() statement as well. but just passing $newMessageID as the eight parameter returns an error. Thanks in advance for assistance.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

perl-DBD-Oracle

I am trying to install perl-DBD-Oracle-1.16-1.2.rpm on Suse (SLE 9), like rpm -Uvh perl-DBD-Oracle-1.16-1.2.rpm but I keep getting the following error message error: Failed dependencies: libclntsh.so.10.1 is needed by perl-DBD-Oracle-1.16-1.2.el4 libnnz10.so is needed by... (1 Reply)
Discussion started by: hassan1
1 Replies

2. UNIX for Dummies Questions & Answers

PERL - Oracle

Hi friends, I am new to Perl programming. I have a requirement, using perl I need to connect to Oracle DB and get some records ( on unix environment). I googled and found that we need to use DBD (Database Drivers), DBI (DataBase Interface) to connect to oracle. I tried using " sqlplus... (1 Reply)
Discussion started by: satguyz
1 Replies

3. Programming

perl dbi to oracle getting disconnect_all for oracle dbi help

hi i am trying to connect to an oracle database using dbi and i get this :: Driver has not implemented the disconnect_all method. at /opt/perl/lib/site_perl/5.8.0/sun4-solaris/DBI.pm line 575 END failed--call queue aborted. for all i know, the script was working earlier, but has... (1 Reply)
Discussion started by: poggendroff
1 Replies

4. Shell Programming and Scripting

How to connect ORACLE using PERL

Hi Friends, I am having Perl 5 and Oracle 9i. I just wanna to connect Oracle DB & to perform some select query statement. Could anyone pls let me know. I've tried below command which i found in some website, But it throws some error.:confused: Executed: perl -e 'use DBI; print... (1 Reply)
Discussion started by: Vijayakumarpc
1 Replies

5. Shell Programming and Scripting

Oracle using perl

Hello All, I need to now how can I establish connection with oracle database then shutdown abort and then startup, In other words need to implement the following lines to perl script: export ORACLE_SID=<some user> ${ORACLE_HOME}/bin/sqlplus /nolog SQL> connect / as sysdba SQL> shutdown... (2 Replies)
Discussion started by: Alalush
2 Replies

6. Shell Programming and Scripting

Perl connect to remote oracle db without local oracle installation

I want to use Perl to connect to a remote Oracle DB I have no oracle installation on my server (and dont plan on installing one) I am using solaris 9 on x86 server. Is this possible? I basically want to run some basic sql queries on the remote oracle db which I have access to using perl on my... (0 Replies)
Discussion started by: frustrated1
0 Replies

7. Shell Programming and Scripting

Need help in perl script for oracle

Hi, #!/usr/bin/perl my @sid=`cat /etc/oratab|grep -v "^#"|grep -v "*"|grep -v "#"|cut -d: -f1 -s`; my $log; my $body=""; my $oraclesid=""; chomp($hostname); foreach my $oraclesid (@SID){ $body=""; chomp($oraclesid); $dbname=print ($oraclesid); print... (2 Replies)
Discussion started by: rocky1954
2 Replies

8. Shell Programming and Scripting

PERL and Oracle 11.2 question

Hi, we have PERL 64-bit build with Oracle 10g DBD . PERL database connection are working fine. Database upgraded to 11.2 and in PERL documents it says still use 10g DBD to connect to 11.2. when I try some test connections, I am getting this error . Did anyone see this error before . I set the... (2 Replies)
Discussion started by: talashil
2 Replies

9. Shell Programming and Scripting

perl- oracle sql query

Hi, I am new to perl.How to query oracle database with perl??? Thanks (1 Reply)
Discussion started by: tdev457
1 Replies

10. Shell Programming and Scripting

Perl Oracle connection error

I've a Centralized Server which can connect to all Oracle Databases. When I was trying the below code it doesn't work, But tnsping was working fine. #!D:/perl5/bin/perl.exe use DBI; my $dbh = DBI->connect('dbi:Oracle:QBDIWCE', 'IDUSER', 'SECRET123#' ) || die( $DBI::errstr . "\n" ) ; ... (1 Reply)
Discussion started by: ilugopal
1 Replies
DBI::DBD::SqlEngine(3)					User Contributed Perl Documentation				    DBI::DBD::SqlEngine(3)

NAME
DBI::DBD::SqlEngine - Base class for DBI drivers without their own SQL engine SYNOPSIS
package DBD::myDriver; use base qw(DBI::DBD::SqlEngine); sub driver { ... my $drh = $proto->SUPER::driver($attr); ... return $drh->{class}; } package DBD::myDriver::dr; @ISA = qw(DBI::DBD::SqlEngine::dr); sub data_sources { ... } ... package DBD::myDriver::db; @ISA = qw(DBI::DBD::SqlEngine::db); sub init_valid_attributes { ... } sub init_default_attributes { ... } sub set_versions { ... } sub validate_STORE_attr { my ($dbh, $attrib, $value) = @_; ... } sub validate_FETCH_attr { my ($dbh, $attrib) = @_; ... } sub get_myd_versions { ... } sub get_avail_tables { ... } package DBD::myDriver::st; @ISA = qw(DBI::DBD::SqlEngine::st); sub FETCH { ... } sub STORE { ... } package DBD::myDriver::Statement; @ISA = qw(DBI::DBD::SqlEngine::Statement); sub open_table { ... } package DBD::myDriver::Table; @ISA = qw(DBI::DBD::SqlEngine::Table); sub new { ... } DESCRIPTION
DBI::DBD::SqlEngine abstracts the usage of SQL engines from the DBD. DBD authors can concentrate on the data retrieval they want to provide. It is strongly recommended that you read DBD::File::Developers and DBD::File::Roadmap, because many of the DBD::File API is provided by DBI::DBD::SqlEngine. Currently the API of DBI::DBD::SqlEngine is experimental and will likely change in the near future to provide the table meta data basics like DBD::File. Metadata The following attributes are handled by DBI itself and not by DBI::DBD::SqlEngine, thus they all work as expected: Active ActiveKids CachedKids CompatMode (Not used) InactiveDestroy AutoInactiveDestroy Kids PrintError RaiseError Warn (Not used) The following DBI attributes are handled by DBI::DBD::SqlEngine: AutoCommit Always on. ChopBlanks Works. NUM_OF_FIELDS Valid after "$sth->execute". NUM_OF_PARAMS Valid after "$sth->prepare". NAME Valid after "$sth->execute"; probably undef for Non-Select statements. NULLABLE Not really working, always returns an array ref of ones, as DBD::CSV does not verify input data. Valid after "$sth->execute"; undef for non-select statements. The following DBI attributes and methods are not supported: bind_param_inout CursorName LongReadLen LongTruncOk DBI::DBD::SqlEngine specific attributes In addition to the DBI attributes, you can use the following dbh attributes: sql_engine_version Contains the module version of this driver (readonly) sql_nano_version Contains the module version of DBI::SQL::Nano (readonly) sql_statement_version Contains the module version of SQL::Statement, if available (readonly) sql_handler Contains the SQL Statement engine, either DBI::SQL::Nano or SQL::Statement (readonly). sql_parser_object Contains an instantiated instance of SQL::Parser (readonly). This is filled when used first time (only when used with SQL::Statement). sql_sponge_driver Contains an internally used DBD::Sponge handle (readonly). sql_valid_attrs Contains the list of valid attributes for each DBI::DBD::SqlEngine based driver (readonly). sql_readonly_attrs Contains the list of those attributes which are readonly (readonly). sql_identifier_case Contains how DBI::DBD::SqlEngine deals with non-quoted SQL identifiers: * SQL_IC_UPPER (1) means all identifiers are internally converted into upper-cased pendants * SQL_IC_LOWER (2) means all identifiers are internally converted into lower-cased pendants * SQL_IC_MIXED (4) means all identifiers are taken as they are These conversions happen if (and only if) no existing identifier matches. Once existing identifier is used as known. The SQL statement execution classes doesn't have to care, so don't expect "sql_identifier_case" affects column names in statements like SELECT * FROM foo sql_quoted_identifier_case Contains how DBI::DBD::SqlEngine deals with quoted SQL identifiers (readonly). It's fixated to SQL_IC_SENSITIVE (3), which is interpreted as SQL_IC_MIXED. sql_flags Contains additional flags to instantiate an SQL::Parser. Because an SQL::Parser is instantiated only once, it's recommended to set this flag before any statement is executed. sql_dialect Controls the dialect understood by SQL::Parser. Possible values (delivery state of SQL::Statement): * ANSI * CSV * AnyData Defaults to "CSV". Because an SQL::Parser is instantiated only once and SQL::Parser doesn't allow to modify the dialect once instantiated, it's strongly recommended to set this flag before any statement is executed (best place is connect attribute hash). SUPPORT
You can find documentation for this module with the perldoc command. perldoc DBI::DBD::SqlEngine You can also look for information at: o RT: CPAN's request tracker <http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBI> http://rt.cpan.org/NoAuth/Bugs.html?Dist=SQL-Statement <http://rt.cpan.org/NoAuth/Bugs.html?Dist=SQL-Statement> o AnnoCPAN: Annotated CPAN documentation <http://annocpan.org/dist/DBI> http://annocpan.org/dist/SQL-Statement <http://annocpan.org/dist/SQL-Statement> o CPAN Ratings <http://cpanratings.perl.org/d/DBI> o Search CPAN <http://search.cpan.org/dist/DBI/> Where can I go for more help? For questions about installation or usage, please ask on the dbi-dev@perl.org mailing list. If you have a bug report, patch or suggestion, please open a new report ticket on CPAN, if there is not already one for the issue you want to report. Of course, you can mail any of the module maintainers, but it is less likely to be missed if it is reported on RT. Report tickets should contain a detailed description of the bug or enhancement request you want to report and at least an easy way to verify/reproduce the issue and any supplied fix. Patches are always welcome, too. ACKNOWLEDGEMENTS
Thanks to Tim Bunce, Martin Evans and H.Merijn Brand for their continued support while developing DBD::File, DBD::DBM and DBD::AnyData. Their support, hints and feedback helped to design and implement this module. AUTHOR
This module is currently maintained by H.Merijn Brand < h.m.brand at xs4all.nl > and Jens Rehsack < rehsack at googlemail.com > The original authors are Jochen Wiedmann and Jeff Zucker. COPYRIGHT AND LICENSE
Copyright (C) 2009-2010 by H.Merijn Brand & Jens Rehsack Copyright (C) 2004-2009 by Jeff Zucker Copyright (C) 1998-2004 by Jochen Wiedmann All rights reserved. You may freely distribute and/or modify this module under the terms of either the GNU General Public License (GPL) or the Artistic License, as specified in the Perl README file. SEE ALSO
DBI, DBD::File, DBD::AnyData and DBD::Sys. perl v5.16.2 2012-04-20 DBI::DBD::SqlEngine(3)
All times are GMT -4. The time now is 03:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy