How to access psql from perl script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to access psql from perl script?
# 1  
Old 04-28-2008
CPU & Memory How to access psql from perl script?

Hi All,

How to access the postgreSQL from a perl script?
Thanks in advance
JS
# 2  
Old 04-28-2008
Connect Data Base from Shell Script

Quote:
Originally Posted by jisha
Hi All,

How to access the postgreSQL from a perl script?
Thanks in advance
JS
The following method is used to connect plsql from the Bash:

sqlplus -l USERNAME/PASSWORD@DBNAME <<EOF
insert into TABLE_CFS_DUMP(FILE_NAME, REGION_ID, SDP_ID, SEQUENCE_ID, TOTAL_RECORDS) values ('$file','$region_id','$sdp_id','$sequence_id', '$sub_records');
EXIT
EOF
# 3  
Old 04-28-2008
use the DBI module and the respective driver for the type of database. You will probably have to install the DBI module and the driver. You can find them on CPAN.

The CPAN Search Site - search.cpan.org

I can't help with code examples because my SQL knowledge is very limited.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

PSQL multiple queries output to file

Hi, I have a shell script containing multiple PSQL queries for which I want the output to be redirected to a text file. psql -U postgres -d database -o textfile.txt << EOF Query1; Query2; Query ....; EOF When executing the script, queries outputs are directed to textfile.txt, however... (2 Replies)
Discussion started by: nms
2 Replies

2. Shell Programming and Scripting

Psql output into array and read 2 fields into different variables

Hello Just edited the entry to make it easier to understand what i want How can i achieve this: GOAL: read 2 field from a table with PSQL result of this PSQL command is this INSTALLEDLANG=$(su - postgres -c "psql -A -t -q -c -d ${DBNAME} -t -c 'SELECT code, iso_code from res_lang'") ... (0 Replies)
Discussion started by: winston6071
0 Replies

3. Programming

Psql replace blanks with character

Well as the title describes, its a pretty straight forward problem. I have a series of psql tables where there are lots of blanks. However there is at least one column, called name, that will never be blank. I want to write a select statement to get all of the contents of the table and then turn... (3 Replies)
Discussion started by: wxornot
3 Replies

4. Shell Programming and Scripting

Perl Hash access

Suppose I have a hash: my %table1 = ( 'Sam' => { 'Company' => 'XYZ', 'Post' => 'Software Engineer', 'Skills' => 'Perl', ... (0 Replies)
Discussion started by: som.nitk
0 Replies

5. Shell Programming and Scripting

Need to access Oracle DB with shell/perl script in Unix

Hi, We need to access Oracle DB with shell/perl script in Unix. Is Oracle client needed in Unix for this. I have seen threads which tell abt using SQL plus to access Oracle tables. Can we access DB without SQL PLus installation using scripts in UNix like we access DB using jar files in Java .... (1 Reply)
Discussion started by: justinacc
1 Replies

6. Shell Programming and Scripting

How do i access sybase using isql and how do i get result set in perl script?

Hi, How do i get result set in perl script using isql while connecting sybase server. I have a perl script which connected to sybase and get the result set. but i wanted to get the result set. How do i get the result set in perl script not unix shell script.. $server ="ServerName"; open... (1 Reply)
Discussion started by: solo123
1 Replies

7. Shell Programming and Scripting

psql output without return \n

Hi Everyone, When i finish running # echo `psql -t -U root databaseA -c "select a, b from book"`; i get the output 107275 | 14 107301 | 2 107446 | 6 107820 | 77 107929 | 101 Would like to have the result like: 107275 | 14 107301 | 2 107446 | 6 107820 | 77 107929 | 101 (7 Replies)
Discussion started by: jimmy_y
7 Replies

8. UNIX and Linux Applications

strange behavior of PSQL user defined function

Segregated the problematic portion, and showing for your view here., 1. Following is the function definition, create or replace function new_del(id integer) returns void as $$ begin raise info 'dollar :%',$1; delete from testing where id=$1; end ; $$ language 'plpgsql'; ... (1 Reply)
Discussion started by: thegeek
1 Replies

9. Shell Programming and Scripting

Access Sharepoint via perl

Hi All, I like to know if there is any module/package in perl to connect to a sharepoint? Please help!!! Thanks, TC (0 Replies)
Discussion started by: tcomku
0 Replies

10. 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
Login or Register to Ask a Question