Solved

Perl in oracle query

Posted on 2007-11-20
3
250 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
Comment Utility

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
Comment Utility
Line 3 should have been:
    chomp $schema;
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now