473,395 Members | 1,581 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

use DBI; package problem

Hello,
I have one perl code.
'
Here they are using oracle database. To extract that data from database they are using DBI module.

in this program they have used some queries also.
i have such proram here here
in query they have used

? ? ? but i do not know what is this questions maks.
please can any one exaplain me the usage of this question mark inside the query.

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use DBI qw(:sql_types);
  3.  
  4. my $dbh = DBI->connect( 'dbi:Oracle:orcl',
  5.                         'jeffrey',
  6.                         'jeffspassword',
  7.                         {
  8.                           RaiseError => 1,
  9.                           AutoCommit => 0
  10.                         }
  11.                       ) || die "Database connection not made: $DBI::errstr";
  12.  
  13. my @records = (
  14.                 [ 0, "Larry Wall",      "Perl Author",  "555-0101" ],
  15.                 [ 1, "Tim Bunce",       "DBI Author",   "555-0202" ],
  16.                 [ 2, "Randal Schwartz", "Guy at Large", "555-0303" ],
  17.                 [ 3, "Doug MacEachern", "Apache Man",   "555-0404" ] 
  18.               );
  19.  
  20. my $sql = qq{ INSERT INTO employees VALUES ( ?, ?, ?, ? ) };my $sth = $dbh->prepare( $sql );
  21.  
  22.  
  23. for( @records ) {
  24.   eval {
  25.     $sth->bind_param( 1, @$_->[0], SQL_INTEGER );
  26.     $sth->bind_param( 2, @$_->[1], SQL_VARCHAR );
  27.     $sth->bind_param( 3, @$_->[2], SQL_VARCHAR );
  28.     $sth->bind_param( 4, @$_->[3], SQL_VARCHAR );
  29.     $sth->execute();
  30.     $dbh->commit();
  31.   };
  32.  
  33.   if( $@ ) {
  34.     warn "Database error: $DBI::errstr\n";
  35.     $dbh->rollback(); #just die if rollback is failing
  36.   }
  37. }
  38.  
  39. $sth->finish();
  40. $dbh->disconnect();

shafi
Jan 24 '08 #1
1 1262
eWish
971 Expert 512MB
The ?'s when used with the DBI are called Placeholders. Read the documentation for more.

--Kevin
Jan 24 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Laszlo | last post by:
Hi everybody I am a beginner in Perl DBI. The following dummy code " #!c:\perl\bin\perl.exe # use DBI; "
1
by: ulloa | last post by:
Hi. My name is Randall and I am from Costa Rica. I have a little problem. I did an application using Perl, DBI and DBI::Oracle, and now I have to upload my application in an Unix server. The...
1
by: ssmith | last post by:
When attempting to install DBI, I get the following error message: Error: no suitable installation target found for package DBI. From the command prompt (WinXP), I type 'ppm'. From the ppm...
0
by: Axel Dachtler | last post by:
Hi, I have downloaded both CPAN-moduls DBD-Oracle-1.14.tar and DBI-1.39.tar. But I fail in installing these moduls! The Perl Package Manager (PPM) returns this error message: no valid...
0
by: Jeremy Booker | last post by:
I installed the current stable release of MySQL from RPMs. I used the client and server packages. After installing the server package, the RPM printed a note saying I should run two commands. I...
5
by: dananrg | last post by:
I was messing around with the native ODBC module (I am using Python in a Win32 environment), e.g: import dbi, odbc ....and it seems to meet my needs. I'd rather use a module that comes...
1
by: christianlandry | last post by:
Hi All, I have installed mysql on my powermac G5 (64 bits) and I installed perl DBD-mysql-4.005 and DBI-1.601 that I obtained from CPAN. The installation did not work and I kept getting error...
2
by: jmishra | last post by:
Hi, I am compiling perl 5.8 on i386-linux architecture,every thing went fine and I am able to execute normal perl scripts thorugh this newly built perl. But when I try to execute script which...
2
by: dcruncher4 | last post by:
Our perl DBI is built on DB2 8.2. It runs fine on 8.2 However it does not run on 9.1. After the connect to the database, at the first SQL it gives this error "sql0818n A timestamp conflict...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.