Sponsored Content
Top Forums Shell Programming and Scripting Access to database/eval command Post 302203515 by era on Monday 9th of June 2008 04:05:25 AM
Old 06-09-2008
You are declaring a "my" variable $sth inside the eval scope. Those variables cannot be accessed outside of the scope (basically, curly braces, or in the absence of those, the file) they are declared in. If you take out the eval, the fetchvalue is in the same scope as the my declaration.

If you add use strict; use warnings; to the beginning of your script, you get more and better diagnostics for mistakes like this (but the strict pragma also forces you to write more disciplined code, for worse or, mostly, better).

Last edited by era; 06-09-2008 at 05:07 AM.. Reason: Remark on use strict; use warnings;
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

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... (2 Replies)
Discussion started by: mercuryshipzz
2 Replies

2. 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

3. 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

4. Shell Programming and Scripting

Eval command help

I have file called myfile which has the text "myserver" in it. I need to have a command to ping "myserver". How would I do that? I tried when I type at the terminal I get the output as . How do I do something like a ? thanks, Nick (5 Replies)
Discussion started by: nikhilfake
5 Replies

5. 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

6. Shell Programming and Scripting

Strange result of eval, how does eval really work with ssh?

Hi all, some small script with eval turned me to crazy. my OS is linux Linux s10-1310 2.6.16.53-0.8.PTF.434477.3.TDC.0-smp #1 SMP Fri Aug 31 06:07:27 PDT 2007 x86_64 x86_64 x86_64 GNU/Linux below script works well #!/bin/bash eval ssh remotehost date eval ssh remotehost ls below... (1 Reply)
Discussion started by: summer_cherry
1 Replies

7. Shell Programming and Scripting

Help with perl eval command .....

Hi All, I read the above written code (perl code) in another perl script and evaluates this code for each line of text file,but using exit statement in code make this not to work and i could not get the desired results. However if i use return it works fine. I just need to know why it doesn't... (1 Reply)
Discussion started by: sarbjit
1 Replies

8. Shell Programming and Scripting

Error in eval eval command to print html tags

anyone has any info on why this is complaining??? vivek@vivek-c5e55ef2e ~/TAC $ zoneCounter=1 vivek@vivek-c5e55ef2e ~/TAC $ optUsage1=23% vivek@vivek-c5e55ef2e ~/TAC $ eval eval echo "<th>Zone $zoneCounter </th><th align=\"left\"> \$optUsage$zoneCounter </th>" -bash: syntax error... (1 Reply)
Discussion started by: vivek d r
1 Replies

9. Shell Programming and Scripting

Error in eval eval command to print html tags

anyone has any info on why this is complaining??? vivek@vivek-c5e55ef2e ~/TAC $ zoneCounter=1 vivek@vivek-c5e55ef2e ~/TAC $ optUsage1=23% vivek@vivek-c5e55ef2e ~/TAC $ eval eval echo "<th>Zone $zoneCounter </th><th align=\"left\"> \$optUsage$zoneCounter </th>" -bash: syntax error... (13 Replies)
Discussion started by: vivek d r
13 Replies

10. Shell Programming and Scripting

Usage of '-' in eval command.

Hi, I am trying to use eval command to evaluate a variable(HAPROXY_LISTENER_rabbitmq_project-test-BRHM_PORT) which consists of '-' but unfortunately the eval command is unable to interpret the value of variable and trims the variable name after '-' and produces the string output rather than the... (10 Replies)
Discussion started by: Kuldip
10 Replies
DataSource::Driver(3)					User Contributed Perl Documentation				     DataSource::Driver(3)

NAME
DBIx::DataSource::Driver - Driver Writer's Guide and base class SYNOPSIS
perldoc DBIx::DataSource::Driver; or package DBIx::DataSource::FooBase; use DBIx::DataSource::Driver; @ISA = qw( DBIx::DataSource::Driver ); DESCRIPTION
To implement a driver for your database: 1) If you can create a database with an SQL command through DBI/DBD, simply provide a parse_dsn class method which returns a list consisting of the *actual* data source to use in DBI->connect and the SQL. package DBIx::DataSource::NewDatabase; use DBIx::DataSource::Driver; @ISA = qw( DBIx::DataSource::Driver ); sub parse_dsn { my( $class, $action, $dsn ) = @_; # $action is `create' or `drop' # for example, if you parse parse $dsn for $database, # $sql = "$action $database"; # you can die on errors - it'll be caught ( $new_dsn, $sql ); } 2) Otherwise, you'll need to write create_database and drop_database class methods. package DBIx::DataSource::NewDatabase; sub create_database { my( $class, $dsn, $user, $pass ) = @_; # for success, return true # for failure, die (it'll be caught) } sub drop_database { my( $class, $dsn, $user, $pass ) = @_; # for success, return true # for failure, die (it'll be caught) } AUTHOR
Ivan Kohler <ivan-dbix-datasource@420.am> COPYRIGHT
Copyright (c) 2000 Ivan Kohler Copyright (c) 2000 Mail Abuse Prevention System LLC All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. BUGS
SEE ALSO
DBIx::DataSource, DBIx::DataSource::mysql, DBIx::DataSource::Pg, DBI perl v5.8.0 2000-09-25 DataSource::Driver(3)
All times are GMT -4. The time now is 03:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy