Sponsored Content
Top Forums Shell Programming and Scripting Passing variable from file to sql from script Post 302924284 by Ditto on Friday 7th of November 2014 01:55:29 PM
Old 11-07-2014
Quote:
Originally Posted by junior-helper
I see! I think I finally understand what you are talking about Smilie

Loading the data from the file using SQL*loader into a table "newtable" and then performing the select statement like

Code:
SELECT * FROM sometable WHERE somecolumn IN (SELECT number FROM newtable);

Right?

Btw. paste won't work in Oracle like DEFINE won't work on UNIX/Linux shell.
Yep Smilie (sorry if I didn't make that clearer earlier Smilie sometimes you get so used to things, you "assume" they're obvious .. Smilie )
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing PL/SQL variable value to Shell Varible

Hi my UNIX Friends, Im calling some SQL scripts through Unix Shell scripting. How do I export the value of PL/SQL variable value into a Unix shell script variable? Also could any one inform me about the 'search' and 'cut' utility of PL/SQL (like 'grep' and 'cut' in Shell scripting). ... (10 Replies)
Discussion started by: ganapati
10 Replies

2. UNIX for Advanced & Expert Users

passing value to a variable in a SQL

Hi Folks, This is a small chunk of the bigger problem which i am facing and some help here will help me resolve the rest of the issue. Problem is that i need to pass the value of a variable from a shell script to a SQL query (infact a lot of SQL's) i have the following solution but somehow... (4 Replies)
Discussion started by: kamitsin
4 Replies

3. Shell Programming and Scripting

Passing argumnets from shell script to sql

hi I all , I have sql statment in my shell script , I pass two argument to the script I need to pass the this two arguments to the sql statment example : runsql.sh "1" "2" sql : updat tables_x set y=0 where A=:x should subsituted by "1" and B=:y shuold subsituted bt "2"... (1 Reply)
Discussion started by: habuzahra
1 Replies

4. Shell Programming and Scripting

passing arguments to sql script

Hi Gurus, i have one requirement in unix script, i have a file called abc.txt in that few lines are there with the empid, i need to read each line and pass to .sql script. ex: abc.txt 2345 2346 1243 1234 i need to pass these arguments to .sql script rom unix ex: select * from... (1 Reply)
Discussion started by: Devendar
1 Replies

5. UNIX for Advanced & Expert Users

Passing Hash variable in to sql query in perl

Hi Everyone, Can anyone help me how do i call hash variable in to sql query in perl. Please see the script below i have defined two Hash %lc and %tab as below $lc{'REFF'}='V_RES_CLASS'; $lc{'CALE'}='V_CAP_CLASS'; $lc{'XRPD'}='V_XFMR_CLASS'; $tab{'V_RES_CLASS'}='V_MFR_SERS';... (6 Replies)
Discussion started by: jam_prasanna
6 Replies

6. Shell Programming and Scripting

Replace a var in sql file with shell script variable

I have a requirement where i have a sql file (filetext.sql). This file contains a variable ss_code. Now in a shell script im trying to replace the variable ss_code with a value contained in the shell script variable MTK_DC..tried the below in the script MTK_DC="mit,cit,bit" OUT=`awk -v... (4 Replies)
Discussion started by: michaelrozar17
4 Replies

7. UNIX for Dummies Questions & Answers

SQL Script to use variable value from input file

Here is the requirement, When I run the "run file KSH (sql)", it should substitute '${pCW_Bgn_DT}' with 201120 and '${pCW_End_DT}' with 201124 Input File ---------- $ cat prevwk.dat 201124 20110711 run file KSH (sql) ------------------ In this file, I want to use the variables... (1 Reply)
Discussion started by: shanrice
1 Replies

8. Shell Programming and Scripting

Passing a string variable from Unix to Sql Plus

Hi Guys, I am trying to pass a string variable from Unix shell script to sqlplus as a parameter. I have tried using single quotes with the variable name but it does not work. Please help me with it. I am using BASH. My code: Your help is much appreciated. Thanks, shil (2 Replies)
Discussion started by: infintenumbers
2 Replies

9. Shell Programming and Scripting

Passing variable to sql

How to pass variable to sql file. Im tryin in two ways, Method 1: my.sql select * from table where col1 = '$1' and col2 = 'text'; Method 1execute: dbaccess database my.sql $var Method2: select * from table col1 in (`cat inputfile`) and col2 = 'text'; method... (2 Replies)
Discussion started by: Roozo
2 Replies

10. Shell Programming and Scripting

Passing string from SQL to a BASH script

OS Solaris 10, DB oracle 10g Hello, We currently have a BASH script that runs and moves image files from a remote server to the local db server. A snippet of the code shows that we are picking up all Images that are 'mtime -1' some code... for file in `ssh user@10.200.200.10 'find... (3 Replies)
Discussion started by: JonP
3 Replies
CLUSTER(7)							   SQL Commands 							CLUSTER(7)

NAME
CLUSTER - cluster a table according to an index SYNOPSIS
CLUSTER indexname ON tablename INPUTS indexname The name of an index. table The name (possibly schema-qualified) of a table. OUTPUTS CLUSTER The clustering was done successfully. DESCRIPTION
CLUSTER instructs PostgreSQL to cluster the table specified by table based on the index specified by indexname. The index must already have been defined on tablename. When a table is clustered, it is physically reordered based on the index information. Clustering is a one-time operation: when the table is subsequently updated, the changes are not clustered. That is, no attempt is made to store new or updated tuples according to their index order. If one wishes, one can periodically re-cluster by issuing the command again. NOTES In cases where you are accessing single rows randomly within a table, the actual order of the data in the heap table is unimportant. How- ever, if you tend to access some data more than others, and there is an index that groups them together, you will benefit from using CLUS- TER. Another place where CLUSTER is helpful is in cases where you use an index to pull out several rows from a table. If you are requesting a range of indexed values from a table, or a single indexed value that has multiple rows that match, CLUSTER will help because once the index identifies the heap page for the first row that matches, all other rows that match are probably already on the same heap page, saving disk accesses and speeding up the query. During the cluster operation, a temporary copy of the table is created that contains the table data in the index order. Temporary copies of each index on the table are created as well. Therefore, you need free space on disk at least equal to the sum of the table size and the index sizes. CLUSTER preserves GRANT, inheritance, index, foreign key, and other ancillary information about the table. Because the optimizer records statistics about the ordering of tables, it is advisable to run ANALYZE on the newly clustered table. Other- wise, the optimizer may make poor choices of query plans. There is another way to cluster data. The CLUSTER command reorders the original table using the ordering of the index you specify. This can be slow on large tables because the rows are fetched from the heap in index order, and if the heap table is unordered, the entries are on random pages, so there is one disk page retrieved for every row moved. (PostgreSQL has a cache, but the majority of a big table will not fit in the cache.) The other way to cluster a table is to use SELECT columnlist INTO TABLE newtable FROM table ORDER BY columnlist which uses the PostgreSQL sorting code in the ORDER BY clause to create the desired order; this is usually much faster than an index scan for unordered data. You then drop the old table, use ALTER TABLE...RENAME to rename newtable to the old name, and recreate the table's indexes. However, this approach does not preserve OIDs, constraints, foreign key relationships, granted privileges, and other ancillary properties of the table --- all such items must be manually recreated. USAGE
Cluster the employees relation on the basis of its ID attribute: CLUSTER emp_ind ON emp; COMPATIBILITY
SQL92 There is no CLUSTER statement in SQL92. SQL - Language Statements 2002-11-22 CLUSTER(7)
All times are GMT -4. The time now is 01:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy