Sponsored Content
Top Forums Programming How to pass table_name as variable Post 302365941 by Corona688 on Wednesday 28th of October 2009 11:26:27 AM
Old 10-28-2009
What DBMS are you using?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pass variable to sed?

Hi there. If variables are named inside of a ksh script, how is it possible to pass these to sed? The affected portion of my script goes something like this: A=`cut -d. -f1 $FILE` B=`cut -d. -f2 $FILE` C=`cut -d. -f3 $FILE` sed 's/1111/$A/g;s/2222/$B/g;s/3333/$C/g' file > anotherfile ... (2 Replies)
Discussion started by: kristy
2 Replies

2. UNIX for Dummies Questions & Answers

pass variable to awk

i would like to pass a variable to awk wherein the variable comes from external loop. i tried this... let x=0 until test $x -eq 32 do cat file | awk '{ print $1 , "Number" , $($x) }' >> output done thanks, (4 Replies)
Discussion started by: inquirer
4 Replies

3. UNIX for Dummies Questions & Answers

How do I pass a variable to awk?

I have an awk statement where I Need to pass an environment variable but I cannot get it to work: My evironment varible examples below: $FILE1=/dev/fs/file.new $FILE2=/dev/fs/file.old Code below: awk -F"|" ' BEGIN { while( getline < "$FILE1" ) { arr=1 } } arr != 1 { print } '... (12 Replies)
Discussion started by: eja
12 Replies

4. UNIX for Dummies Questions & Answers

How To Pass an Array Variable

Hi, I have a master BASH shell script where I define a bunch of variables: $var1=why $var2=is $var3=(this so hard) I would then like to call another shell script and pass these variables to it: $script2 $var1 $var2 $var3 This works fine for var1 and var2. However, var3 is an array,... (9 Replies)
Discussion started by: msb65
9 Replies

5. Shell Programming and Scripting

Pass variable to sql

Please help. I got these error. I'm try to pass variable extract from data-file.txt to sql file(select.sql). cat: cannot open select cat: cannot open * cat: cannot open from cat: cannot open user cat: cannot open where cat: cannot open name=$list; #!/bin/bash list=`sed q... (3 Replies)
Discussion started by: killboy
3 Replies

6. Shell Programming and Scripting

Problem with * when pass into variable.

Hello expert. I have a little problem here. I write a script and stuck some bug to fix. I found the problem was about * and a sample of script is below. line 1 is print * out but line 3 print all name of files in the script's path. (but I want *) I want to contain * in variable... (3 Replies)
Discussion started by: MaYuMi
3 Replies

7. Shell Programming and Scripting

How to pass a function with a variable parameter into another variable?

Hello again :) Am currently trying to write a function which will delete a record from a file. The code currently looks as such: function deleteRecord() { clear read -p "Please enter the ID of the record you wish to remove: " strID ... (2 Replies)
Discussion started by: U_C_Dispatj
2 Replies

8. Red Hat

How to pass value of pwd as variable in SED to replace variable in a script file

Hi all, Hereby wish to have your advise for below: Main concept is I intend to get current directory of my script file. This script file will be copied to /etc/init.d. A string in this copy will be replaced with current directory value. Below is original script file: ... (6 Replies)
Discussion started by: cielle
6 Replies

9. Shell Programming and Scripting

How to pass variable to a query?

Hi All, How to pass date variable to a query? I have tried the below one , but it's not working. ost.ksh #!/bin/ksh v_date=$1 var=$(sqlplus -s $ORACON <<ENDOFSQL SELECT TO_DATE('$v_date','DD-MON-YYYY'),-1) FROM DUAL; exit; ENDOFSQL ) #End I have executed as below. (7 Replies)
Discussion started by: ROCK_PLSQL
7 Replies

10. UNIX for Beginners Questions & Answers

Need to pass variable in a command and assign value to a variable

Hello All, Hope you're doing well ! I am trying below command to be passed in a shell script, header_date_14 is a variable and $1 is the name of a file I intend to pass as a command line argument, however command line argument is not being accepted. header_date_14=$(m_dump... (8 Replies)
Discussion started by: ektubbe
8 Replies
Easy(3pm)						User Contributed Perl Documentation						 Easy(3pm)

NAME
DBIx::Easy - Easy to Use DBI interface SYNOPSIS
use DBIx::Easy; my $dbi_interface = new DBIx::Easy qw(Pg template1); $dbi_interface -> insert ('transaction', id => serial ('transaction', 'transactionid'), time => $dbi_interface -> now); $dbi_interface -> update ('components', "table='ram'", price => 100); $rows_deleted = $dbi_interface -> delete ('components', 'stock = 0'); $dbi_interface -> makemap ('components', 'id', 'price', 'price > 10'); $components = $dbi_interface -> rows ('components'); $components_needed = $dbi_interface -> rows ('components', 'stock = 0'); DESCRIPTION
DBIx::Easy is an easy to use DBI interface. Currently the Pg, mSQL, mysql, Sybase, ODBC and XBase drivers are supported. CREATING A NEW DBI INTERFACE OBJECT
$dbi_interface = new DBIx::Easy qw(Pg template1); $dbi_interface = new DBIx::Easy qw(Pg template1 racke); $dbi_interface = new DBIx::Easy qw(Pg template1 racke aF3xD4_i); $dbi_interface = new DBIx::Easy qw(Pg template1 racke@linuxia.de aF3xD4_i); $dbi_interface = new DBIx::Easy qw(Pg template1 racke@linuxia.de:3306 aF3xD4_i); The required parameters are the database driver and the database name. Additional parameters are the database user and the password to access the database. To specify the database host use the USER@HOST notation for the user parameter. If you want to specify the port to connect to use USER@HOST:PORT. DESTROYING A DBI INTERFACE OBJECT
It is important that you commit all changes at the end of the interaction with the DBMS. You can either explicitly commit $dbi_interface -> commit (); or do it implicitly: undef $dbi_interface; ERROR HANDLING
sub fatal { my ($statement, $err, $msg) = @_; die ("$0: Statement "$statement" failed (ERRNO: $err, ERRMSG: $msg) "); } $dbi_interface -> install_handler (&fatal); If any of the DBI methods fails, either die will be invoked or an error handler installed with install_handler will be called. CACHING ISSUES
By default, this module caches table structures. This can be disabled by setting $DBIx::Easy::cache_structs to 0. XBASE DRIVER
The DBIx::Easy method rows fails to work with the DBD::XBase driver. METHODS
DATABASE ACCESS process statement $sth = $dbi_interface -> process ("SELECT * FROM foo"); print "Table foo contains ", $sth -> rows, " rows. "; Processes statement by just combining the prepare and execute steps of the DBI. Returns statement handle in case of success. insert table column value [column value] ... $sth = $dbi_interface -> insert ('bar', drink => 'Caipirinha'); Inserts the given column/value pairs into table. Determines from the SQL data type which values has to been quoted. Just pass a refer- ence to the value to protect values with SQL functions from quoting. update table conditions column value [column value] ... $dbi_interface -> update ('components', "table='ram'", price => 100); $dbi_interface -> update ('components', "table='ram'", price => "price + 20"); Updates any row of table which fulfill the conditions by inserting the given column/value pairs. Scalar references can be used to embed strings without further quoting into the resulting SQL statement. Returns the number of rows modified. put table conditions column value [column value] ... delete table conditions $dbi_interface -> delete ('components', "stock=0"); Deletes any row of table which fulfill the conditions. Without conditions all rows are deleted. Returns the number of rows deleted. rows table [conditions] $components = $dbi_interface -> rows ('components'); $components_needed = $dbi_interface -> rows ('components', 'stock = 0'); Returns the number of rows within table satisfying conditions if any. makemap table keycol valcol [condition] $dbi_interface -> makemap ('components', 'idf', 'price'); $dbi_interface -> makemap ('components', 'idf', 'price', 'price > 10'); $dbi_interface -> makemap ('components', 'idf', '*'); $dbi_interface -> makemap ('components', 'idf', '*', 'price > 10'); Produces a mapping between the values within column keycol and column valcol from table. If an condition is given, only rows matching this condition are used for the mapping. In order to get the hash reference to the record as value of the mapping, use the asterisk as the valcol parameter. random_row table conditions [map] Returns random row of the specified table. If map is set, the result is a hash reference of the selected row, otherwise an array refer- ence. If the table doesn't contains rows, undefined is returned. serial table sequence Returns a serial number for table by querying the next value from sequence. Depending on the DBMS one of the parameters is ignored. This is sequence for mSQL resp. table for PostgreSQL. mysql doesn't support sequences, but the AUTO_INCREMENT keyword for fields. In this case this method returns 0 and mysql generates a serial number for this field. fill sth hashref [flag column ...] Fetches the next table row from the result stored into sth and records the value of each field in hashref. If flag is set, only the fields specified by the column arguments are considered, otherwise the fields specified by the column arguments are omitted. view table [name value ...] foreach my $table (sort $dbi_interface -> tables) { print $cgi -> h2 ('Contents of ', $cgi -> code ($table)); print $dbi_interface -> view ($table); } Produces plain text representation of the database table table. This method accepts the following options as name/value pairs: columns: Which columns to display. order: Which column to sort the row after. limit: Maximum number of rows to display. separator: Separator inserted between the columns. where: Display only rows matching this condition. print $dbi_interface -> view ($table, order => $cgi -> param ('order') || '', where => "price > 0"); DATABASE INFORMATION is_table NAME Returns truth value if there exists a table NAME in this database. tables Returns list of all tables in this database. sequences Returns list of all sequences in this database (Postgres only). columns TABLE Returns list of the column names of TABLE. types TABLE Returns list of the column types of TABLE. sizes TABLE Returns list of the column sizes of TABLE. typemap TABLE Returns mapping between column names and column types for table TABLE. sizemap TABLE Returns mapping between column names and column sizes for table TABLE. TIME VALUES now $dbi_interface -> insert ('transaction', id => serial ('transaction', 'transactionid'), time => $dbi_interface -> now); Returns representation for the current time. Uses special values of the DBMS if possible. MONETARY VALUES money2num money Converts the monetary value money to a numeric one. MISCELLANEOUS is_auth_error msg This method decides if the error message msg is caused by an authentification error or not. AUTHORS
Stefan Hornburg (Racke), racke@linuxia.de Dennis Sch[:o]n, ds@1d10t.de Support for Sybase and ODBC provided by David B. Bitton <david@codenoevil.com>. VERSION
0.17 SEE ALSO
perl(1), DBI(3), DBD::Pg(3), DBD::mysql(3), DBD::msql(3), DBD::Sybase(3), DBD::ODBC(3). perl v5.8.8 2007-05-21 Easy(3pm)
All times are GMT -4. The time now is 03:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy