Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

I need an update statement

Posted on 2012-04-05
7
Medium Priority
?
347 Views
Last Modified: 2012-06-09
Hello Experts,

I've the following select statement in a column:

select
      to_char(column1), to_number( Null ), credavlby, tenor, tenordays,
      to_char(column2)
from
      Test

I need this select statement to be as the following by using an update statement:

select
      replace(to_char(column1),''__'',chr(10)),
      to_number( Null ), credavlby, tenor, tenordays,
      replace(to_char(column2),''__'',chr(10))
from
      Test


I need to replace     "to_char"     with     "replace(to_char"
        And keep "column1"     and     "column2"     as it is,
        The value for coulmn1 and column2     is Changeable not a fixed value
        Then after "(column1)"     add     ",''__'',chr(10))"

Thanks in advance,
Ramez Nabil
0
Comment
Question by:Ramez
  • 3
  • 2
  • 2
7 Comments
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 37810621
I'm not understanding what you are wanting.

Can you post some sample data and expected results?
0
 

Author Comment

by:Ramez
ID: 37811653
Well the select statement is a text value of a column
I need to update this text from:

select
      to_char(column1)
from
      Test


To be like this:
-----------------

select
      replace(to_char(column1),''__'',chr(10))
from
      Test


The part of "column1" should not be changed.
Also I need to add   ,''__'',chr(10))    After (column1)
0
 
LVL 32

Accepted Solution

by:
awking00 earned 1000 total points
ID: 37811831
The question is still not clear. Can you show a sample value for column1 and what it should look like in your select statement? Would it be something like the following?
column1 value =
abc__def__ghi
select value =
abc
def
ghi
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 78

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 1000 total points
ID: 37812105
I agree.  I still do not completely understand what you want but I'll take a guess you are wanting to concatenate/append values to the end of the column:


select
      column1 || ',''__'',' ||chr(10)
from
      Test
0
 

Author Comment

by:Ramez
ID: 37818576
Sorry guys, I'm really trying!

OK, I've a a column by name "Statement" on table "Report", the value of this column is a select statement as the following:

select
      to_char(column1)
from
      Test

I want to make an update statement on table "Report" to update value of column "Statement" to be as following instead of the above value:

select
      replace(to_char(column1),''__'',chr(10))
from
      Test

The part of column value "to_char" sould be changed to "replace(to_char"
The part of column value "column1" has got a different value above the table, its value is "ID" on one record and on another record is "social_no", so this part should be remains as it is in each row wthout any changes.
After the part of "column1" we should add the part of ",''__'',chr(10))" to the end of select clause.
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 37823111
Please provide sample data and expeected results.

What we are looking for is something like:
Given the data below:
col1, col2, col3
a,b,c
d,e,f
g,h,i

I need to update the table and end up with:
???????????
0
 
LVL 32

Expert Comment

by:awking00
ID: 37823153
Can you post some sample values for the statement column as they exist in the report table and what they should look like after the update, including some that may change and some that remain the same?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses
Course of the Month20 days, 16 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question