Sponsored Content
Top Forums Shell Programming and Scripting Creating IN list in PLSQL script dynamically by using shell script Post 302910770 by LoneRanger on Monday 28th of July 2014 05:25:38 AM
Old 07-28-2014
Creating IN list in PLSQL script dynamically by using shell script

Hi all,

I have a PLSQL script which has a IN list where it takes some ids as input. For example

SELECT * FROM EMPLOYEE WHERE EMPLOYEE_ID IN (comma separated list )

I want to run this quest inside a shell script but I would like to prepare the IN list dynamically where the employee ids will be there in the same directory in a different file in the below format.

File Name - employee_list
234
456
784
123

How can I insert all the employee ID into the PLSQL script in one go ? Any sample code is very helpful. Thanks in advance. Smilie

Last edited by LoneRanger; 07-28-2014 at 06:46 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script dynamically case in VAR

Hallo, I am working on a kdialog. This shall be able to load the required commands from a .conf file. First step runs good by loading the entries (selectabel entries) in a variable: MIRRORSELECT=$(kdialog --radiolist "Select your nearest mirror" $VAR1) The kdialog is accordingly correct... (2 Replies)
Discussion started by: ACTGADE
2 Replies

2. Programming

UNIX Shell Script to Create a Document of a PLSQL code.

Hi All, I am supposed to present the documentation for the PLSQL code (PACKAGES, PROCEDURE, FUNCTIONS) of my application. There are sufficient comments in my code. Has anyone written any Shell Script Utility which can parse the PLSQL code and generate some kind of document ( preferrably HTML not... (1 Reply)
Discussion started by: gauravsachan
1 Replies

3. Shell Programming and Scripting

Shell Script to Parse PLSQL code?

Hi All, I am supposed to present the documentation for the PLSQL code (PACKAGES, PROCEDURE, FUNCTIONS) of my application. There are sufficient comments in my code. Has anyone written any Shell Script Utility which can parse the PLSQL code and generate some kind of document ( preferrably HTML not... (2 Replies)
Discussion started by: gauravsachan
2 Replies

4. Shell Programming and Scripting

Dynamically creating text files using shell script

Hi All, I want to create a shell script which dynamically create text files. i am using the following script $i=1 while do cat > test_$i.txt done but while running the script it was stopping(the cursor not going to next step, i have to enter ctrl+c to make it stop). it is creating only... (2 Replies)
Discussion started by: KiranKumarKarre
2 Replies

5. Programming

running PLSQL scripts through shell script

I am running the following ealth checks on my server there are two databases in my server . MODEL1 and MODEL2 i connect with the first database as sqlplus model1/password Then i exceute a query select x from table (4 Replies)
Discussion started by: asalman.qazi
4 Replies

6. Programming

Executing shell script from PLSQL

Hi All, I have a requirement to mv a file in unix from plsql procedure. for that i have created a java host procedure, a host_command, given all grants as per ORACLE-BASE - Oracle8i Shell Commands From PL/SQL but i am getting an error ""Process err :/bin/sh: mv Not Found"" kindly let me... (1 Reply)
Discussion started by: aryan_styles
1 Replies

7. Shell Programming and Scripting

Execute shell script from plsql trigger

Hi, I have been assigned a job which requires me to send mails from unix(Mailx) upon on certain actions triggered in the database. On insert/update of a certain field into one of the database tables the shell script present in Unix box responsible to send mail though mailx needs to be triggered... (7 Replies)
Discussion started by: hemant.bs11
7 Replies

8. Shell Programming and Scripting

Creating variables dynamically and using it in script?

Hi, I have a problem that I am trying to solve and would greatly appreciate some input to solve this. I have a file containing variable length of line. Each line in the file has values separated by "," and i need to grep for these values in a some files. For example below is a sample file with 3... (12 Replies)
Discussion started by: davidtd
12 Replies

9. Shell Programming and Scripting

calling a plsql procedure through shell script

I have a plsql procedure inside a package which is having one IN parameter .I want to call that procedure through a shell script and that IN parameter is a column of a table in the database. So my requirement is that i need to loop all the entries of that IN parameter from the table through shell... (4 Replies)
Discussion started by: rspnf
4 Replies

10. Homework & Coursework Questions

How to Dynamically Pass Parameter to plsql Function & Capture its Output Value in a Shell Variable?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: 2. Relevant commands, code, scripts, algorithms: #! /bin/ksh v="ORG_ID" ... (2 Replies)
Discussion started by: sujitdas2104
2 Replies
DBIx::DR(3pm)						User Contributed Perl Documentation					     DBIx::DR(3pm)

NAME
DBIx::DR - easy DBI helper (perl inside SQL and blessed results) SYNOPSIS
my $dbh = DBIx::DR->connect($dsn, $login, $passed); $dbh->perform( 'UPDATE tbl SET a = 1 WHERE id = <%= $id %>', id => 123 ); my $rowset = $dbh->select( 'SELECT * FROM tbl WHERE id IN (<% list @$ids %>)', ids => [ 123, 456 ] ); my $rowset = $dbh->select(-f => 'sqlfile.sql.ep', ids => [ 123, 456 ]); while(my $row = $rowset->next) { print "id: %d, value: %s ", $row->id, $row->value; } DESCRIPTION
The package extends DBI and allows You: o to use perl inside Your SQL requests; o to bless resultsets into Your package; o to place Your SQL's into dedicated directory; o to use usual DBI methods. Additional 'connect' options. dr_iterator A string describes iterator class. Default value is 'dbix-dr-iterator#new' (decamelized string). dr_item A string describes item (one row) class. Default value is 'dbix-dr-iterator-item#new' (decamelized string). dr_sql_dir Directory path to seek sql files (If You use dedicated SQLs). dr_decode_errors Decode database errors into utf-8 METHODS
All methods can receive the following arguments: -f => $sql_file_name It will load SQL-request from file. It will seek file in directory that was defined in dr_sql_dir param of connect. You needn't to use suffixes (.sql.ep) here, but You can. -item => 'decamelized_obj_define' It will bless (or construct) row into specified class. See below. Default value defined by dr_item argument of DBI::connect. -noitem Do not bless row into any class. -iterator => 'decamelized_obj_define' It will bless (or construct) rowset into specified class. Default value defined by dr_iterator argument of DBI::connect. -noiterator Do not bless rowset into any class. -dbi => HASHREF Additional DBI arguments. -hash => FIELDNAME Selects into HASH. Iterator will operate by names (not numbers). Decamelized strings Are strings that represent class [ and method ]. foo_bar => FooBar foo_bar#subroutine => FooBar->subroutine foo_bar-baz => FooBar::Baz perform Does SQL-request like 'UPDATE', 'INSERT', etc. $dbh->perform($sql, value => 1, other_value => 'abc'); $dbh->perform(-f => $sql_file_name, value => 1, other_value => 'abc'); select Does SQL-request, pack results into iterator class. By default it uses DBIx::DR::Iterator class. my $res = $dbh->select(-f => $sql_file_name, value => 1); while(my $row = $res->next) { printf "RowId: %d, RowValue: %s ", $row->id, $row->value; } my $row = $row->get(15); # row 15 my $res = $dbh->select(-f => $sql_file_name, value => 1, -hash => 'name'); while(my $row = $res->next) { printf "RowId: %d, RowName: %s ", $row->id, $row->name; } my $row = $row->get('Vasya'); # row with name eq 'Vasya' single Does SQL-request that returns one row. Pack results into item class. Does SQL-request, pack results (one row) into item class. By default it uses DBIx::DR::Iterator::Item class. Template language You can use perl inside Your SQL requests: % my $foo = 1; % my $bar = 2; <% my $foo_bar = $foo + $bar %> .. % use POSIX; % my $gid = POSIX::getgid; There are two functions available inside perl: quote Replaces argument to '?', add argument value into bindlist. You can also use shortcut '=' instead of the function. Example 1 SELECT * FROM tbl WHERE id = <% quote $id %> Result SELECT * FROM tbl WHERE id = ? and bindlist will contain id value. If You use DBIx::DR::ByteStream in place of string the function will recall immediate function. Example 2 SELECT * FROM tbl WHERE id = <%= $id %> immediate Replaces argument to its value. You can also use shortcut '==' instead of the function. Example 1 SELECT * FROM tbl WHERE id = <% immediate $id %> Result SELECT * FROM tbl WHERE id = 123 Where 123 is id value. Be carful! Using the operator You can produce code that will be amenable to SQL-injection. Example 2 SELECT * FROM tbl WHERE id = <%== $id %> Helpers There are a few default helpers. list Expands array into Your SQL request. Example SELECT * FROM tbl WHERE status IN (<% list @$ids %>) Result SELECT * FROM tbl WHERE status IN (?,?,? ...) and bindlist will contain ids values. hlist Expands array of hash into Your SQL request. The first argument can be a list of required keys. Places each group into brackets. Example INSERT INTO tbl ('a', 'b') VALUES <% hlist ['a', 'b'] => @$inserts Result INSERT INTO tbl ('a', 'b') VALUES (?, ?), (?, ?) ... and bindlist will contain all inserts values. include Includes the other SQL-part. Example % include 'other_sql', argument1 => 1, argument2 => 2; User's helpers You can add Your helpers using method set_helper. set_helper Sets (or replaces) helpers. $dbh->set_helper(foo => sub { ... }, bar => sub { ... }); Each helper receives template object as the first argument. Examples: $dbh->set_helper(foo_AxB => sub { my ($tpl, $a, $b) = @_; $tpl->quote($a * $b); }); You can use quote and immediate functions inside Your helpers. If You want use the other helper inside Your helper You have to do that by Yourself. To call the other helper You can also use "$tpl->call_helper" function. call_helper $dbh->set_helper( foo => sub { my ($tpl, $a, $b) = @_; $tpl->quote('foo' . $a . $b); }, bar => sub { my $tpl = shift; $tpl->call_helper(foo => 'b', 'c'); } ); COPYRIGHT
Copyright (C) 2011 Dmitry E. Oboukhov <unera@debian.org> Copyright (C) 2011 Roman V. Nikolaev <rshadow@rambler.ru> This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License. VCS
The project is placed git repo on github: https://github.com/unera/dbix-dr/ <https://github.com/unera/dbix-dr/> perl v5.14.2 2012-05-11 DBIx::DR(3pm)
All times are GMT -4. The time now is 01:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy