Sponsored Content
Full Discussion: SQL selective replace
Top Forums UNIX for Dummies Questions & Answers SQL selective replace Post 302880601 by rsi.245 on Saturday 21st of December 2013 01:49:05 AM
Old 12-21-2013
SQL selective replace

Hi

I have a table which looks like this
Code:
id | name | length | clone | null
1 | string 1 | 12345643 | string 1 | NULL |
2 | string 2 | 2345612 | string 2 | NULL |
3 | string 3 | 3421556 | string 3 | NULL |
4 | string 4 | 1236742 | string 4 | NULL |
5 | string 5 | 2312677 | string 5 | NULL |
6 |string 6 | 12786315 | string 6 | NULL |
7 | string 7 | 2341135 | string 7 | NULL |
8 |string 8 | 452189 | string 8 | NULL |
9 |string 9 | 124343 | string 9 | NULL |
10 | string 10 | 3432344 | string 10 | NULL |
.....

I wanted to replace all names columns having id> 5 to sequence.
Keep the first 5 entries the same but replace all others name = "sequence[id]"
and clone entry to be changed as clone = "sequence[id]"
The table should look like this

Code:
id | name | length | clone | null
1 | string 1 | 12345643 | string 1 | NULL |
2 | string 2 | 2345612 | string 2 | NULL |
3 | string 3 | 3421556 | string 3 | NULL |
4 | string 4 | 1236742 | string 4 | NULL |
5 | string 5 | 2312677 | string 5 | NULL |
6 |sequence 6 | 12786315 | sequence 6 | NULL |
7 | sequence 7 | 2341135 | sequence 7 | NULL |
8 |sequence 8 | 452189 | sequence 8 | NULL |
9 |sequence 9 | 124343 | sequence 9 | NULL |
10 | sequence 10 | 3432344 | sequence 10 | NULL |



i did use this command
Code:
UPDATE tablename 

SET name = "sequence[id]"
where id >5;

What is my error?

Please do advise.

Last edited by Scott; 12-21-2013 at 04:09 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find 5 lines and replace with 18 line in sql file where it contains multiple blocks.

My sql file xyz_abc.sql in this file there are multiple sql block in this block I need to find the following block rem Subset Rows (&&tempName.*) CREATE VIEW &&tempName.* AS SELECT * FROM &&tempName.* WHERE f is not null and replace with following code rem Subset Rows... (9 Replies)
Discussion started by: Zaheer.mic
9 Replies

2. 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

3. UNIX for Dummies Questions & Answers

Selective Replacements: Using sed or awk to replace letters with numbers in a very specific way

Hello all. I am a beginner UNIX user who is using UNIX to work on a bioinformatics project for my university. I have a bit of a complicated issue in trying to use sed (or awk) to "find and replace" bases (letters) in a genetics data spreadsheet (converted to a text file, can be either... (3 Replies)
Discussion started by: Mince
3 Replies

4. Programming

[Solved] SQL SELECT REPLACE

Hi All, I had a query related to sql select update replace command. i have a table named clusters and it looks like this name model characteristics sample1.1 +123 parent sample1.2 -456 clone sample1.3 +122 ... (5 Replies)
Discussion started by: sonia102
5 Replies

5. UNIX for Dummies Questions & Answers

Selective replace

i have a large sequence of format sat_1_g3_g_0_8540 . A 1 15501 . . . ID=sat_1_g3_g_0_8540;parentName=sat_1_g3_g_0_8540;Al=sat_1_g2_g_0_8540; sat_1_g3_g_2_8510 . C 1 25501 . . . ... (11 Replies)
Discussion started by: siya@
11 Replies

6. UNIX for Dummies Questions & Answers

Selective delete in SQL

Hi All This might be a weird query but its related to deleting specific details in database. Bascially I had built a database using a set of files seq1 of 300 mb seq2 of 200 mb seq3 of 350 mb seq4 of 300 mb and after building the database i realized that i didn't need the whole data.... (6 Replies)
Discussion started by: sonia102
6 Replies

7. Shell Programming and Scripting

Selective Replace awk column values

Hi, I have the following data: 2860377|"DATA1"|"DATA2"|"65343"|"DATA2"|"DATA4"|"11"|"DATA5"|"DATA6"|"65343"|"DATA7"|"0"|"8"|"1"|"NEGATIVE" 32340377|"DATA1"|"DATA2"|"65343"|"DATA2"|"DATA4"|"11"|"DATA5"|"DATA6"|"65343"|"DATA7"|"0"|"8"|"1"|"NEG-DID"... (3 Replies)
Discussion started by: sdohn
3 Replies

8. Programming

Sql select replace

Hi All, I had a query related to sql select replace command. i have a table named clusters and it looks like this Code: name characteristics sample 1.1 parent sample 1.2 ... (2 Replies)
Discussion started by: siya@
2 Replies

9. UNIX for Dummies Questions & Answers

Selective replace and delete

Hi My input file looks like this: >BAHMI01000090.1 Details of the shopping list 9800 item00090, whole set of listed artifacts and objects >BAHMI01050012.1 Details of the shopping list 9800 item02310, whole set of listed artifacts and objects >BAHMI01070078.1 Details of the shopping list ... (5 Replies)
Discussion started by: sonia102
5 Replies

10. Shell Programming and Scripting

Replace sql with dynamic values

Hi Guys, I am using a function to replace the values dynamically to frame sql query by reading a file. My file will have column names like file.txt col_1 col_2 expected output: select id,col_1,col_2 from ( select a.id, a.col_1, rank() over (ORDER BY cast(a.col_1 AS double)... (5 Replies)
Discussion started by: Master_Mind
5 Replies
XtFindFile(3)							   XT FUNCTIONS 						     XtFindFile(3)

NAME
XtFindFile - search for a file using substitutions in the path list SYNTAX
String XtFindFile(String path, Substitution substitutions, Cardinal num_substitutions, XtFilePredicate predicate); ARGUMENTS
path Specifies a path of file names, including substitution characters. substitutions Specifies a list of substitutions to make into a path. num_substitutions Specifies the number of substitutions passed in. predicate Specifies a procedure to call to judge a potential file name, or NULL. DESCRIPTION
The path parameter specifies a string that consists of a series of potential file names delimited by colons. Within each name, the percent character specifies a string substitution selected by the following character. The character sequence ``%:'' specifies an embedded colon that is not a delimiter; the sequence is replaced by a single colon. The character sequence ``%%'' specifies a percent character that does not introduce a substitution; the sequence is replaced by a single percent character. If a percent character is followed by any other character, XtFindFile looks through the specified substitutions for that character in the match field and if found replaces the percent and match characters with the string in the corresponding substitution field. A substitution field entry of NULL is equivalent to a pointer to an empty string. If the operating system does not interpret multiple embedded name separators in the path (i.e., ``/'' in POSIX) the same way as a single separator, XtFindFile will collapse multiple separators into a single one after performing all string substitutions. Except for collapsing embedded separators, the contents of the string substitutions are not interpreted by XtFindFile and may therefore contain any operating-system-dependent characters, including additional name separators. Each resulting string is passed to the predicate procedure until a string is found for which the procedure returns True; this string is the return value for XtFindFile. If no string yields a True return from the predicate, XtFindFile returns NULL. If the predicate parameter is NULL, an internal procedure that checks if the file exists, is readable, and is not a directory will be used. It is the responsibility of the caller to free the returned string using XtFree when it is no longer needed. SEE ALSO
X Toolkit Intrinsics - C Language Interface Xlib - C Language X Interface X Version 11 libXt 1.0.5 XtFindFile(3)
All times are GMT -4. The time now is 12:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy