Sponsored Content
Full Discussion: Perl Database access
Top Forums Shell Programming and Scripting Perl Database access Post 302158530 by mercuryshipzz on Tuesday 15th of January 2008 04:53:00 PM
Old 01-15-2008
Perl Database access

Hi,

I tried to run this code but it isnt giving me any output or errors.

My aim is to retrieve the row based on the flag name(this is the primary key).

flag_test is my table

This is how i ran it:

perl read_db.pl flag1

flag1 is the criteria in where clause

--------

this is my code:


#!/usr/bin/perl
use DBI;

sub read_db
{


$dbh = DBI -> connect('DBI:Oracle:mercury','student','learn') || die "unable to connect:$DBI::errstr";




my $dbh = DBI->connect();


my $sql = qq/select flag_name, f_name, l_name from flag_test where flag_name =?/;


my $sth = $dbh->prepare($sql);
$sth->execute();
my ($col1, $col2, $col3);


$sth->bind_col(1, \$col1);
$sth->bind_col(2, \$col2);
$sth->bind_col(3, \$col3);
while ($sth->fetch) {
print "$col1, $col2, $col3\n";
}

}


could somebody help me with this?

thanks,

mercury
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

microsoft access database on Unix

Hello, I am a newborn baby to Unix and I was told that it was possible to have Microsoft Access databases on a Unix web server. I am using Perl to interface and query the Access database, which puts the information into the appropriate fields of a web page. Then updated information is submitted... (1 Reply)
Discussion started by: spiderling
1 Replies

2. Programming

C program with Oracle database access

Hey, I want to access oracle database through Unix C programming.. Can you through me some light on that... (5 Replies)
Discussion started by: kavi
5 Replies

3. UNIX for Advanced & Expert Users

Help with ms access database and firebird

Hi! I need to access two diferent databases allocated in a linux server through PHP. I know in the php.ini file I can't configure some parameters as odbc.default_db... but I can't configure it. I've already installed unixodbc drivers Can Anybody point me to a tutorial web o teach me how... (0 Replies)
Discussion started by: ncatdesigner
0 Replies

4. Shell Programming and Scripting

Access to database/eval command

Hi i have the following code: if(($line!=1) and (@field!='\$')){ print ( "\nTRY TO CONNECT TO DATABASE................\n"); my $dbh = DBI->connect($dsn, $user, $pass); print ("CONNECTED TO DATABASE\n"); eval ... (1 Reply)
Discussion started by: chriss_58
1 Replies

5. Shell Programming and Scripting

problem trying to access a database

hi guys, I am using the following code in order to access a database. #!/usr/bin/perl print "READ DATA FROM DATABASE\n"; use DBI; use strict; #use DBD::Oracle; my $user='reassure'; my $pass='R3Assur3'; #my $dsn="dbi:Oracle:orcl"; my $dsn='dbi:Oracle:cobscs.world'; my $dbh =... (1 Reply)
Discussion started by: chriss_58
1 Replies

6. Shell Programming and Scripting

Database access

Hell all, I have the following snippet of code: $sql=qq{select * from ( select to_char(t.start_time_timestamp,'yyyy/mm/dd hh24:mi:ss') start_time,t.s_p_number_address, null cos_icsa_code, null cos_icsa_subcode from cc_unrated_msc_flow t union select... (2 Replies)
Discussion started by: chriss_58
2 Replies

7. IP Networking

Access database over internet, help

Hi! :D I'm new here, and I will appreciate all the help you can give. This is the problem we are trying to solve at my office. At office 1 we have SCO UNIX 5.0.can't remember last number. On it runs database software on which we input/read/modify data throughout terminal software, on remote... (1 Reply)
Discussion started by: PNemesis
1 Replies

8. Shell Programming and Scripting

using unix scripts database access

i want to access database (sql script) within a unix script. help me (2 Replies)
Discussion started by: chamaraa
2 Replies

9. UNIX for Dummies Questions & Answers

Access to a database

Hello all, is it possible to write a script in order to connect to a database, load data in a specific domain and execute the corresponding command? (3 Replies)
Discussion started by: FelipeAd
3 Replies

10. AIX

No Suitable Driver for MS Access database

Hi, I am running a JDBC:ODBC code to access .mdb file in my windows system successfully but, not able to access MS Access mdb file in AIX Unix box. when I am trying to run the same piece of code in AIX Unix box it is saying "No Suitable Driver". I need some immediate help. (0 Replies)
Discussion started by: thirunp
0 Replies
MySQL::Diff::Table(3pm) 				User Contributed Perl Documentation				   MySQL::Diff::Table(3pm)

NAME
MySQL::Diff::Table - Table Definition Class SYNOPSIS
use MySQL::Diff::Table my $db = MySQL::Diff::Database->new(%options); my $def = $db->def(); my $name = $db->name(); my $field = $db->field(); my $fields = $db->fields(); # %$fields my $primary_key = $db->primary_key(); my $indices = $db->indices(); # %$indices my $options = $db->options(); my $isfield = $db->isa_field($field); my $isprimary = $db->isa_primary($field); my $isindex = $db->isa_index($field); my $isunique = $db->is_unique($field); my $isfulltext = $db->is_fulltext($field); DESCRIPTION
Parses a table definition into component parts. METHODS
Constructor new( %options ) Instantiate the objects, providing the command line options for database access and process requirements. Public Methods Fuller documentation will appear here in time :) o def Returns the table definition as a string. o name Returns the name of the current table. o field Returns the current field definition of the given field. o fields Returns an array reference to a list of fields. o primary_key Returns a hash reference to fields used as primary key fields. o indices Returns a hash reference to fields used as index fields. o options Returns the additional options added to the table definition. o isa_field Returns 1 if given field is used in the current table definition, otherwise returns 0. o isa_primary Returns 1 if given field is defined as a primary key, otherwise returns 0. o isa_index Returns 1 if given field is used as an index field, otherwise returns 0. o is_unique Returns 1 if given field is used as unique index field, otherwise returns 0. o is_fulltext Returns 1 if given field is used as fulltext index field, otherwise returns 0. COPYRIGHT AND LICENSE
Copyright (c) 2000-2011 Adam Spiers. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
mysqldiff, MySQL::Diff, MySQL::Diff::Database, MySQL::Diff::Utils AUTHOR
Adam Spiers <mysqldiff@adamspiers.org> perl v5.14.2 2012-04-06 MySQL::Diff::Table(3pm)
All times are GMT -4. The time now is 10:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy