Solved

Perl in oracle query

Posted on 2007-11-20
3
254 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

740 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