?
Solved

I need an update statement

Posted on 2012-04-05
7
Medium Priority
?
344 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 77

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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 77

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 77

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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.
This video shows how to recover a database from a user managed backup
Suggested Courses

801 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