09-27-2010
To create a file writing a SQL into it from another file
Hi,
I have a file in which I have database information along with 1 SELECT statement. Only 1 statement would be there. I want to grep this SELECT STATEMENT only and write into a separate file.
Input File format:
Database_Name:<database>
Schema_Name:<schema>
Table_Name:<table>
Select * from <schema>.<table>
I have 2 ways, either I can use the 2nd and 3rd line to create the SELECT statament and write into a separate file:
Select * from <i'll extract schema name (2nd line) and table name (3rd line)>
or
I can grep SELECT statement mentioned in the 4th line and write into a separate file.
--------------------------------------------------------------------------
Other info:
Database is DB2
Let me know if more details are required.
Regards....
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hi All,
Not sure if this would be in a dummies sectiin or advanced. I'm looking for a script if someone has doen something like this.
I have list of files -
adc_earnedpoints.20070630.txt
adc_earnedpoints.20070707.txt
adc_earnedpoints.20070714.txt
adc_earnedpoints.20070721.txt... (1 Reply)
Discussion started by: thebeginer
1 Replies
2. Programming
Hi I am new to using pl/sql on a unix platform and am having trouble writing to a file from within a block. Below is an example of the code that I have. I know that I need to use UTL_FILE to accomplish this; however, I keep getting errors. Can someone please help me?
I am trying to create a... (1 Reply)
Discussion started by: stky13
1 Replies
3. UNIX for Dummies Questions & Answers
Hi,
I have a sql file which has CREATE and INSERT commands in it. Basically, inside this file, a table will be created and the data will be inserted into the table. I was wondering if there is a way for me to create directories from this file?
Thanks in advance (4 Replies)
Discussion started by: tezarin
4 Replies
4. Shell Programming and Scripting
Hi All,
Please help me writing the below script.
I have two sql queries.
1. Select count(1),Client_id from TABLE_A group by Client_id;
2. Select count(1),Client_id from TABLE_B group by Client_id;
I need the output of above two sql queries in a single file. The output 2nd query should be... (4 Replies)
Discussion started by: 46019
4 Replies
5. Shell Programming and Scripting
Hi ,
I used the below script to get the sql data into csv file using unix scripting.
I m getting the output into an output file but the output file is not displayed in a separe columns .
#!/bin/ksh
export FILE_PATH=/maav/home/xyz/abc/
rm $FILE_PATH/sample.csv
sqlplus -s... (2 Replies)
Discussion started by: Nareshp
2 Replies
6. Shell Programming and Scripting
I'm having problems with writing my sql results to a file:
sqlplus -S username/password@DB <<!!
set echo off
set verify off
set showmode off
set feedback off
set timing off
set linesize 250
set wrap off
set pagesize 0
set newpage none
set tab off
set trimspool on
set colsep... (1 Reply)
Discussion started by: avillanueva
1 Replies
7. Shell Programming and Scripting
Hi,
I have two text files. Need to create a third text file extracting specific data from first two existing files..
Text File 1: Format contains:
SQL*Loader: Release 10.2.0.1.0 - Production on Wed Aug 4 21:06:34 2010
some text ............so on...and somwhere text like:
Record 1:... (1 Reply)
Discussion started by: shashi143ibm
1 Replies
8. Shell Programming and Scripting
Can someone help me on creating a script that will manage/create a csv file from Pl/Sql using UNIX?Any advice is welcome,thank you so much,:) (2 Replies)
Discussion started by: Atrap
2 Replies
9. Programming
this is my issue.
4 parameters are passed from korn shell to sql script.
parameter_1= varchar2 datatype or no value entered my user.
parameter_2= number datatype or no value entered my user.
parameter_3= number datatype or no value entered my user.
parameter_4= number datatype or no... (5 Replies)
Discussion started by: megha2525
5 Replies
10. Shell Programming and Scripting
Hi all.
This is my first post on this forum. I've previously found great help in the huge knowledgebase that is here, but this time I have not been able to find a solution to my problem.
I have a large text file that looks like this:
typedef struct ABC_struct_nbr1_ {
char attr1; /*... (0 Replies)
Discussion started by: Yagi Uda
0 Replies
LEARN ABOUT REDHAT
create_view
CREATE
VIEW(7) SQL Commands CREATE VIEW(7)
NAME
CREATE VIEW - define a new view
SYNOPSIS
CREATE [ OR REPLACE ] VIEW view [ ( column name list ) ] AS SELECT query
INPUTS
view The name (optionally schema-qualified) of a view to be created.
column name list
An optional list of names to be used for columns of the view. If given, these names override the column names that would be deduced
from the SQL query.
query An SQL query (that is, a SELECT statement) which will provide the columns and rows of the view.
Refer to SELECT [select(7)] for more information about valid arguments.
OUTPUTS
CREATE VIEW
The message returned if the view is successfully created.
ERROR: Relation 'view' already exists
This error occurs if the view specified already exists in the database.
WARNING: Attribute 'column' has an unknown type
The view will be created having a column with an unknown type if you do not specify it. For example, the following command gives a
warning:
CREATE VIEW vista AS SELECT 'Hello World'
whereas this command does not:
CREATE VIEW vista AS SELECT text 'Hello World'
DESCRIPTION
CREATE VIEW defines a view of a query. The view is not physically materialized. Instead, a query rewrite rule (an ON SELECT rule) is auto-
matically generated to support SELECT operations on views.
CREATE OR REPLACE VIEW is similar, but if a view of the same name already exists, it is replaced. You can only replace a view with a new
query that generates the identical set of columns (i.e., same column names and data types).
If a schema name is given (for example, CREATE VIEW myschema.myview ...) then the view is created in the specified schema. Otherwise it is
created in the current schema (the one at the front of the search path; see CURRENT_SCHEMA()). The view name must be distinct from the
name of any other view, table, sequence, or index in the same schema.
NOTES
Currently, views are read only: the system will not allow an insert, update, or delete on a view. You can get the effect of an updatable
view by creating rules that rewrite inserts, etc. on the view into appropriate actions on other tables. For more information see CREATE
RULE [create_rule(7)].
Use the DROP VIEW statement to drop views.
USAGE
Create a view consisting of all Comedy films:
CREATE VIEW kinds AS
SELECT *
FROM films
WHERE kind = 'Comedy';
SELECT * FROM kinds;
code | title | did | date_prod | kind | len
-------+---------------------------+-----+------------+--------+-------
UA502 | Bananas | 105 | 1971-07-13 | Comedy | 01:22
C_701 | There's a Girl in my Soup | 107 | 1970-06-11 | Comedy | 01:36
(2 rows)
COMPATIBILITY
SQL92
SQL92 specifies some additional capabilities for the CREATE VIEW statement:
CREATE VIEW view [ column [, ...] ]
AS SELECT expression [ AS colname ] [, ...]
FROM table [ WHERE condition ]
[ WITH [ CASCADE | LOCAL ] CHECK OPTION ]
The optional clauses for the full SQL92 command are:
CHECK OPTION
This option is to do with updatable views. All INSERT and UPDATE commands on the view will be checked to ensure data satisfy the
view-defining condition. If they do not, the update will be rejected.
LOCAL Check for integrity on this view.
CASCADE
Check for integrity on this view and on any dependent view. CASCADE is assumed if neither CASCADE nor LOCAL is specified.
CREATE OR REPLACE VIEW is a PostgreSQL language extension.
SQL - Language Statements 2002-11-22 CREATE VIEW(7)