Solved

Perl in oracle query

Posted on 2007-11-20
3
252 Views
Last Modified: 2013-12-19
i need to write a perl script to substitute the schema name in the from clause of my query and incorporate it in my query,so that it ask me to enter schema name evrytime the query runs.

select

sysdate,
prd_id,
prd_name,
member_id,
member_name,
treatment_date,
Service_id,
Service_Begin_date,
service_end_date,
Service_Desc

from

test.treatment,
test.member,
test.provider,
test.services

where

prd_id = service_prd_id_auth
and
Service_id = treatment_service_id
and
treatment_member_uid = member_id

group by
prd_id,member_id,service_id
0
Comment
Question by:chisun7679
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
Adam314 earned 500 total points
ID: 20320573

print "Enter schema: ";
my $schema = <STDIN>;
chomp;
 
my $sql = "
select
 
sysdate,
prd_id,
prd_name,
member_id,
member_name,
treatment_date,
Service_id,
Service_Begin_date,
service_end_date,
Service_Desc
 
from 
 
$schema.treatment,
$schema.member,
$schema.provider,
$schema.services
 
where
 
prd_id = service_prd_id_auth
and
Service_id = treatment_service_id
and
treatment_member_uid = member_id
 
group by
prd_id,member_id,service_id"

Open in new window

0
 
LVL 39

Expert Comment

by:Adam314
ID: 20320577
Line 3 should have been:
    chomp $schema;
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Convert grep lines to perl 6 37
Oracle DATE Column Space 11 78
Deny Oracle DBAs from Connecting  "/ as sysdba" 5 62
Creation date for a PDB 5 18
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question