Can anyone please assist me?
I have attached 2 input files and one output file. I need to generate the sql update statements using the above 2 input files. if input_file2 has 5 rows, then we should generate 5 update statements because column1 is unique. input_file1 and input_file2 may contain more columns. I have added only few columns in my sample files. The output file should generate the sql update statements for the uncommented columns, but the positions should be correct.
Please let me know if you need any other clarification.
Thanks
Moderator's Comments:
Please use CODE tags (not ICODE tags) when posting full-line and, especially, multi-line sample input, output, and code segments.
Do not bump up posts.
And, do not post the same question in two threads.
I will merge these threads in a few minutes.
Last edited by vinus; 02-01-2016 at 01:44 PM..
Reason: Change ICODE tags to CODE tags. Merge threads.
Hi,
I want to extract data from database table to a flat file using shell scripting. For loading data from file to a table, I had used SQL Loader. How can I do the vice versa using shell scripting.
Thanks in advance (3 Replies)
Hi there
I have a database on a remote box and i have been using shell script to insert data into it for example, i could have a script that did this
SN=123456
n=server1
m=x4140
sql="UPDATE main SET hostname='$n',model='$m' WHERE serial='$SN';"
echo $sql |/usr/sfw/bin/mysql -h... (4 Replies)
Hi,
I have the output (as below) which i want it to be in a table.
For e.g.
space utilization in PSE on path /logs is 0%
space utilization in PSE on path /logs/tuxedo/tuxlsp is 16%
space utilization in PSE on path /ldvarlsp/lsp/log is 37%
space utilization in PSE on path /home is 6%... (7 Replies)
Can i do this
Say one command
sed 's/:*/ /g' $summf
is returning
C1234
C2345
C3434
some no of rows, now this ouput i have to insert it into a DB table
how do i do this?? (2 Replies)
Hi All,
Can anyone give me Shell script sample script to generate Param file by Reading Values from SQL Plus query and it should assign those values to variables like..
$$SChema_Name='ORCL'
Thanks in Advance... Srav... (4 Replies)
I'm having trouble trying to create a BASH shell script.
I want the user to input a command "cat file_name.c" and then the shell script will delete all comments "/* */" from file_name.c else exit.
So far I have this:
#!/bin/bash
read "cat file" // User will input command cat... (7 Replies)
Hi scripting experts.
I have some coding challenges that I'm hoping you can help me out.
I have one file#1 that contains the following sql statement that spans over multiple lines:
sql Select /*+ use_has(a,b) */ *
from customer a,
customer_address b
where a.id = b.id... (1 Reply)
Table TAB1 contains following example data (its a tree sitting in table data format & its driven based CHILD & PARENT column pick the RULE condition to generate the below SQL:
CHILD PARENT SS MID MNM VNM RULE FLG
1 ? S1 ? ? V1 rule004 I
2 1 S1 ? ? V1 0 Z
3 1 S1 ? ? V1 1 Z ... (6 Replies)
Hi Gurus,
I have a very weird requirement and have no clue to resolve the issue. please help me get out this difficulty
below two tables, table1 contains the column name. D means this column used for the rule. for example: rule 0 is all columns have value, rule1 is col3 and col7 have no value.... (2 Replies)
Foe example we have three environments int,qa and prod.Each environment has some number of servers.
int=Server1,Server2,Server3
qa=Server4,Server5,Server6
prod=Server7,Server8,Server9
echo "Enter the Environment i.e int,qa,prod"
read env
case $env in
int)
## Need command where all the... (9 Replies)
Discussion started by: nareshreddy443
9 Replies
LEARN ABOUT CENTOS
values
VALUES(7) PostgreSQL 9.2.7 Documentation VALUES(7)NAME
VALUES - compute a set of rows
SYNOPSIS
VALUES ( expression [, ...] ) [, ...]
[ ORDER BY sort_expression [ ASC | DESC | USING operator ] [, ...] ]
[ LIMIT { count | ALL } ]
[ OFFSET start [ ROW | ROWS ] ]
[ FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } ONLY ]
DESCRIPTION
VALUES computes a row value or set of row values specified by value expressions. It is most commonly used to generate a "constant table"
within a larger command, but it can be used on its own.
When more than one row is specified, all the rows must have the same number of elements. The data types of the resulting table's columns
are determined by combining the explicit or inferred types of the expressions appearing in that column, using the same rules as for UNION
(see Section 10.5, "UNION, CASE, and Related Constructs", in the documentation).
Within larger commands, VALUES is syntactically allowed anywhere that SELECT is. Because it is treated like a SELECT by the grammar, it is
possible to use the ORDER BY, LIMIT (or equivalently FETCH FIRST), and OFFSET clauses with a VALUES command.
PARAMETERS
expression
A constant or expression to compute and insert at the indicated place in the resulting table (set of rows). In a VALUES list appearing
at the top level of an INSERT, an expression can be replaced by DEFAULT to indicate that the destination column's default value should
be inserted. DEFAULT cannot be used when VALUES appears in other contexts.
sort_expression
An expression or integer constant indicating how to sort the result rows. This expression can refer to the columns of the VALUES result
as column1, column2, etc. For more details see ORDER BY Clause.
operator
A sorting operator. For details see ORDER BY Clause.
count
The maximum number of rows to return. For details see LIMIT Clause.
start
The number of rows to skip before starting to return rows. For details see LIMIT Clause.
NOTES
VALUES lists with very large numbers of rows should be avoided, as you might encounter out-of-memory failures or poor performance. VALUES
appearing within INSERT is a special case (because the desired column types are known from the INSERT's target table, and need not be
inferred by scanning the VALUES list), so it can handle larger lists than are practical in other contexts.
EXAMPLES
A bare VALUES command:
VALUES (1, 'one'), (2, 'two'), (3, 'three');
This will return a table of two columns and three rows. It's effectively equivalent to:
SELECT 1 AS column1, 'one' AS column2
UNION ALL
SELECT 2, 'two'
UNION ALL
SELECT 3, 'three';
More usually, VALUES is used within a larger SQL command. The most common use is in INSERT:
INSERT INTO films (code, title, did, date_prod, kind)
VALUES ('T_601', 'Yojimbo', 106, '1961-06-16', 'Drama');
In the context of INSERT, entries of a VALUES list can be DEFAULT to indicate that the column default should be used here instead of
specifying a value:
INSERT INTO films VALUES
('UA502', 'Bananas', 105, DEFAULT, 'Comedy', '82 minutes'),
('T_601', 'Yojimbo', 106, DEFAULT, 'Drama', DEFAULT);
VALUES can also be used where a sub-SELECT might be written, for example in a FROM clause:
SELECT f.*
FROM films f, (VALUES('MGM', 'Horror'), ('UA', 'Sci-Fi')) AS t (studio, kind)
WHERE f.studio = t.studio AND f.kind = t.kind;
UPDATE employees SET salary = salary * v.increase
FROM (VALUES(1, 200000, 1.2), (2, 400000, 1.4)) AS v (depno, target, increase)
WHERE employees.depno = v.depno AND employees.sales >= v.target;
Note that an AS clause is required when VALUES is used in a FROM clause, just as is true for SELECT. It is not required that the AS clause
specify names for all the columns, but it's good practice to do so. (The default column names for VALUES are column1, column2, etc in
PostgreSQL, but these names might be different in other database systems.)
When VALUES is used in INSERT, the values are all automatically coerced to the data type of the corresponding destination column. When it's
used in other contexts, it might be necessary to specify the correct data type. If the entries are all quoted literal constants, coercing
the first is sufficient to determine the assumed type for all:
SELECT * FROM machines
WHERE ip_address IN (VALUES('192.168.0.1'::inet), ('192.168.0.10'), ('192.168.1.43'));
Tip
For simple IN tests, it's better to rely on the list-of-scalars form of IN than to write a VALUES query as shown above. The list of
scalars method requires less writing and is often more efficient.
COMPATIBILITY
VALUES conforms to the SQL standard. LIMIT and OFFSET are PostgreSQL extensions; see also under SELECT(7).
SEE ALSO INSERT(7), SELECT(7)PostgreSQL 9.2.7 2014-02-17 VALUES(7)