How to Convert a Column value to Rows which has ';' as delimitter.
COLA COLB
1 London University; Harvard University(1947; Masters; Distinction); Stanford University(1948, Masters; Distinction); Cambridge University(1949; Graduation, First class)
Which needs to be transformed as
COLA COLB
1 London University
1 Harvard University(1947 Masters Distinction)
1 Stanford University(1948, Masters Distinction)
1 Cambridge University(1949 Graduation, First class)
Thanks in Advance.
Regards,
Balakrishna
maybe this example might help.
SQL> select trim(replace(decode(c.semicolon_pos,0,substr(c.str,decode(c.lg,0,1,c.lg)),substr(c.str,decode(c.lg,0,1,c.lg),(c.semicolon_pos - c.lg))),';',null)) single_string
2 from (select b.rn, b.str, b.semicolon_cnt, b.semicolon_pos,
3 nvl(lag(b.semicolon_pos) over (order by b.rn, b.str),0) lg
4 from (select rownum rn, a.str, a.semicolon_cnt,
5 instr(a.str,';',1,rownum) semicolon_pos
6 from (select vt.str,
7 (length(vt.str) - length(replace(vt.str, ';'))) semicolon_cnt
8 from (select '1 London University; Harvard University(1947, Masters, Distinction); Stanford University(1948, Masters, Distinction); Cambridge University(1949, Graduation, First class)' str from dual) vt) a
9 connect by level <= a.semicolon_cnt+1) b) c;
SINGLE_STRING
1 London University
Harvard University(1947, Masters, Distinction)
Stanford University(1948, Masters, Distinction)
Cambridge University(1949, Graduation, First class)
SQL>
Similar Messages
-
How to convert single column into single row
I need to convert single column into single row having n no.of.values in a column. without using case or decode. I need a query to display as below.
emp_id
100
101
102
102
103
200
I need output like 100,101,102,103,104.........200.I assume you want to convert 200 rows with one column into one row with 200 columns. If so, this is called pivot. If you know number of rows (max possible number of rows) and you are on 11G you can use PIVOT operator (on lower versions GROUP BY + CASE). Otherwise, if row number isn't known, you can use dynamic SQL or assemble select on clent side. Below is example emp_id = 1,2,..5 (to give you idea) and you are on 11G:
with emp as (
select level emp_id
from dual
connect by level <= 5
select *
from emp
pivot(
max(emp_id) for emp_id in (1 emp_id1,2 emp_id2,3 emp_id3,4 emp_id4,5 emp_id5)
EMP_ID1 EMP_ID2 EMP_ID3 EMP_ID4 EMP_ID5
1 2 3 4 5
SQL>
SY. -
How to refer a column value of a single row in conditional column display?
Hello,
does anybody have an idea, how i can refer a column value of a single row in conditional display of a column?
So my idea is, that a report has a column, which value is only displayed, when another column value of this row has a specific value.
I want to solve this problem with condition type: PL/SQL Function Body returning a boolean.
But I do not know how to refer the column value of each single row!
Thank you,
TimHere's a solution that, to me, seems easier to implement but, that's, of course, in the eye of the implementer.
Rather than using APEX to generate a link column for you, actually create the link as part of your SQL.
select '<a href="f?p=102:3:491847682940364::::P3_CONTACT_ID:' || CONTACT_ID || "><img src="/i/themes/theme_1/ed-item.gif" alt="Edit"></a>' CONTACT_LINK, ...
etc.
Test this out. You'll see that it works just like making a column a link using the column attributes.
Next, we'll change the SQL to use a DECODE statement to either display the link or nothing depending on what your criteria is. For example, let's assume you only want a link for active contacts.
select Decode( CONTACT_STATUS, 'A', '<a href="f?p=102:3:491847682940364::::P3_CONTACT_ID:' || CONTACT_ID || "><img src="/i/themes/theme_1/ed-item.gif" alt="Edit"></a>', NULL ) CONTACT_LINK, ...
etc.
This will not display the link in any rows in which the CONTACT_STATUS is not active, i.e. "A"
-Joe -
How to convert a string value to date
Dear All,
I am new to powershell script, i was trying to store a Ad user password set date to a variable add, add a number of days to get the expire date.
but when i try to convert the variable to date value, I am getting the error as below.
Please help me......
PS C:\script> $passwordSetDate = (get-aduser user1 -properties * | select PasswordLastSet)
PS C:\script> $passwordSetDate
PasswordLastSet
7/15/2014 8:17:24 PM
PS C:\script> $a = [datetime]::ParseExact($passwordSetDate,"MM/dd/yyyy HH:MM:SS", $null)
Cannot find an overload for "ParseExact" and the argument count: "3".
At line:1 char:1
+ $a = [datetime]::ParseExact($passwordSetDate,"MM/dd/yyyy HH:MM:SS", $null)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
PS C:\script> $a = [datetime]::ParseExact($passwordSetDate,"MM/dd/yyyy HH:MM:SS", $null)Dear All,
I am new to powershell script, i was trying to store a Ad user password set date to a variable add, add a number of days to get the expire date.
but when i try to convert the variable to date value, I am getting the error as below.
Please help me......
PS C:\script> $passwordSetDate = (get-aduser user1 -properties * | select PasswordLastSet)
PS C:\script> $passwordSetDate
PasswordLastSet
7/15/2014 8:17:24 PM
PS C:\script> $a = [datetime]::ParseExact($passwordSetDate,"MM/dd/yyyy HH:MM:SS", $null)
Cannot find an overload for "ParseExact" and the argument count: "3".
At line:1 char:1
+ $a = [datetime]::ParseExact($passwordSetDate,"MM/dd/yyyy HH:MM:SS", $null)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
PS C:\script> $a = [datetime]::ParseExact($passwordSetDate,"MM/dd/yyyy HH:MM:SS", $null)
In your post you ask how to convert a string value to a date. The value returned from the Get-AdUser is already a date. It does not need to be converted.
Bill has sshown one way to convert a date to a string and there are other methods. You need to clarify your question.
If you are really trying ot convert strings to dates then you can start with this:
[datetime]'01/21/1965 13:33:23'
Most date strings aer autodetected by the class.
¯\_(ツ)_/¯ -
plz help me to print column values into row values.
for eg.
1
2
output will be 1,2Check this out.. might be useful
recursive select? -
How to convert ResultSet's value to String
Dear JDC's
plz tell me how to convert ResultSet's value to String.
kashifI want to read a whole array from a table into a String[]
and then send it to another servlet before I forward it all to anther servlet with request.setParameter.....
Any ideas how to solve it....that is how far I got so far:
rs=pgresult("select count (answer) from answers where qid="+idnum);
numberofquestions = rs.getInt("mynumber");
rs=pgresult("SELECT answer FROM answers WHERE qgroup="+qgroup);
allanswers = new String[numberofquestions];
allanswers = (String[])rs.getArray(1).getArray();
req.setParameter("allanswers",allanswers);
RequestDispatcher dispatcher = req.getRequestDispatcher("editanswers");
dispatcher.forward(req,res);
Tobi -
hi
i am new to programming... i would like to know how to get the column values... i have a resultset object
i need code .... asap
thnx@OP: It is always good to type complete sentences and describe your problem at length. It helps in letting people know what you really need instead of making wild guesses or silly jokes. You post mentions that you get the ResultSet. Then you should look up the API docs for java.sql.ResultSet and take a look at the getxxx() method signatures. Use the ones which suit the specific case.
Besides, it is good to refrain from using asap and urgent. Even if something is urgent to you, it need not be urgent to others. Wording a question properly would attract better replies.
Finally, would you mind getting down to specifics of your problem? From what I perceived, the JDBC tutorial and the API docs should provide all the information you need. -
How to check if all values from a dataset has come to an internal table
How to check if all values from a dataset has come to an internal table ?
Hi,
After OPEN DATASET statement check if sy-subrc = 0 if its success then proceed with split statement and save the dataset values into a internal table and while debugging the internal table you will find that whether all values get into internal table.
Checking sy-subrc after OPEN DATASET statement is must to fill up the values in the internal table.
For e.g.
OPEN DATASET p_inpfile FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
WRITE :/ 'No such input file' .
EXIT.
ELSE.
READ DATASET p_inpfile INTO loc_string.
IF sy-subrc NE 0.
EXIT.
ELSE.
CLEAR loc2.
*Spliting fields in the file-
REPLACE ALL OCCURRENCES OF '#' IN wa_string WITH ' '.
SPLIT wa_string AT const INTO loc2-pernr
loc2-werks
loc2-persk
loc2-vdsk1.
Hope you get some idea.
Thanks,
Sakthi C -
Hi everyone, again landed up with a problem.
After trying a lot to do it myself, finally decided to post here..
I have created a form in form builder 6i, in which on clicking a button the data gets exported to excel sheet.
It is working fine with a single table. The problem now is that i am unable to do the same with 2 tables.
Because both the tables have same number of columns & column names.
Below are 2 tables with column names:
Table-1 (MONTHLY_PART_1)
Table-2 (MONTHLY_PART_2)
SL_NO
SL_NO
COMP
COMP
DUE_DATE
DUE_DATE
U-1
U-1
U-2
U-2
U-4
U-4
U-20
U-20
U-25
U-25
Since both the tables have same column names, I'm getting the following error :
Error 402 at line 103, column 4
alias required in SELECT list of cursor to avoid duplicate column names.
So How can i export the data to excel which has 2 tables with same number of columns & column names?
Should i paste the code? Should i post this query in 'SQL and PL/SQL' Forum?
Help me with this please.
Thank You.You'll have to *alias* your columns, not prefix it with the table names:
$[CHE_TEST@asterix1_impl] r
1 declare
2 cursor cData is
3 with data as (
4 select 1 id, 'test1' val1, 'a' val2 from dual
5 union all
6 select 1 id, '1test' val1, 'b' val2 from dual
7 union all
8 select 2 id, 'test2' val1, 'a' val2 from dual
9 union all
10 select 2 id, '2test' val1, 'b' val2 from dual
11 )
12 select a.id, b.id, a.val1, b.val1, a.val2, b.val2
13 from data a, data b
14 where a.id = b.id
15 and a.val2 = 'a'
16 and b.val2 = 'b';
17 begin
18 for rData in cData loop
19 null;
20 end loop;
21* end;
for rData in cData loop
ERROR at line 18:
ORA-06550: line 18, column 3:
PLS-00402: alias required in SELECT list of cursor to avoid duplicate column names
ORA-06550: line 18, column 3:
PL/SQL: Statement ignored
$[CHE_TEST@asterix1_impl] r
1 declare
2 cursor cData is
3 with data as (
4 select 1 id, 'test1' val1, 'a' val2 from dual
5 union all
6 select 1 id, '1test' val1, 'b' val2 from dual
7 union all
8 select 2 id, 'test2' val1, 'a' val2 from dual
9 union all
10 select 2 id, '2test' val1, 'b' val2 from dual
11 )
12 select a.id a_id, b.id b_id, a.val1 a_val1, b.val1 b_val1, a.val2 a_val2, b.val2 b_val2
13 from data a, data b
14 where a.id = b.id
15 and a.val2 = 'a'
16 and b.val2 = 'b';
17 begin
18 for rData in cData loop
19 null;
20 end loop;
21* end;
PL/SQL procedure successfully completed.
cheers -
How to export data from a spread sheet which has multiple work sheets?
How to export data from a spread sheet which has multiple work sheets to a single text file with fixed length fields?
Hello s1,
saving them as CSV will not give a fixed legth output but, as the naming says, a Character Separated Value file.
Regards
Marcus -
How to Create a datatype for a storeprocedure which has got array ?
Hi All,
Please tell me how to create a datatype for a storeprocedure which has got an array structure ?
Thanks,
Sindhu.Hi Sindhu.
You would have to use a JDBC Cursor for this but it's possible only Output parameters, not Input parameters.
It's describle in a help link:
Defining an EXECUTE Statement http://help.sap.com/saphelp_nwpi711/helpdata/en/44/7b72b2fde93673e10000000a114a6b/frameset.htm
The following SQL data types are supported:
INTEGER, BIT, TINYINT, SMALLINT, BIGINT, FLOAT, REAL, DOUBLE, NUMERIC, DECIMAL, CHAR, VARCHAR, STRING, LONGVARCHAR, DATE, TIME, TIMESTAMP, BINARY, VARBINARY, LONGVARBINARY, BLOB (input and output), CLOB (input and output), CURSOR (output; only in connection with the Oracle JDBC driver)
I think you can execute your StoreProcedure many times depends of array occurs.
Regards.
Bruno. -
How to remove payment block for AP invoices which has been cleared
How to remove payment block for AP invoices which has been cleared
Thanks
ChiruHi,
Thanks for immediate response in fb02 is in deable mode
mrbr unable to change
please provide to to remove blocking code i will assign points
Thnaks
Chiru -
How can I use Airdrop in my iMac which has OX 10.9.2
How can I use Airdrop in my iMac which has OX 10.9.2
If you have an iPhone5 and an IMac,
- you should have your photos in phototstream (last 1000)
- your iphone should have your icloud account linked
- your imac should have your icloud account linked
more info http://support.apple.com/kb/HT4486 -
How to Update some column values in some rows in an advanced table
Hi Gurus,
Can any body help on this issue.
I am having a results table which is showing all the queried parties data queried in a seeded page in OCO module.
Lets assume the table contains 10 rows with the below columns
Party Name, Registry ID, Address Country, Match Percentage, Certification Level, Certification Reason, Internal Indicator, Status .
Certification Level, Certification Reason and Internal Indicator are the dropdowns.
The user want to update some of these fields values for some rows randomly.
After doing this if he click on Save button, Only thosed changed rows need to get update using a Custom Procedure.
But here all the rows irrespective of the change getting updated.
So how to capture the modified rows.
Appreciate any inputs..
Thanks
Palepu
Edited by: Palepu on 9 Aug, 2012 4:25 PMNot sure if you got the answer. You need to capture the row which got changed using the below and get the column value using the getAttribute method. This works for single selection row, if it is multi selection then you will have to loop through all selected rows and find the VO attribute value.
String rowReference = pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
Row currentRow = am.findRowByRef(rowReference);
String param1= (String)currentRow.getAttribute("VOAttribute");
Let me know if there are any issues.
Thanks
Shree -
How to convert into columns rows
Hi all,
How to convert columns into rows.
thank you
regards
P PrakashWhats your DB Version. If its 11g and above you can check out PIVOT and UNPIVOT clause of SELECT statement. Its a new feature of 11g.
For previous version just search this forum you will get lots of examples.
Maybe you are looking for
-
Hi All, We are seeing an issue with the FTP Adapter Communication Channel in SAP PI 7.1. When the communication channel is connecting to a FTP Server and if the connection request timeout ( ex: SFTP Server down ) we see a connection error . However t
-
FCP wants to scatter my media files everywhere - should I force it not to?
Hey, We're an up and coming church starting with FCP on a couple of machines here, and before we make too many projects I'd like for us to make our naming and storing conventions consistent. So I wrote down what I thought would be a decent system - i
-
Can Audition 2.0 be uninstalled after Audition 3.0 installed?
I had upgraded from Audition 2.0 to Audition 3.0 a couple of years ago, but I notice that Audition 2.0 is still installed on my machine. When I installed Audition 3.0 I assumed it would override/replace/upgrade Audition 2.0 and not install another v
-
Recording a mix into Logic??
I'm wanting to record a mix, but not sure whether you can do it in Logic...anyone got any ideas? Cheers Ibook G4 1.33 GHz Mac OS X (10.4.3)
-
hi everyone, Could you guide me regarding calculating WHTax on down payment, and if down payment is for partial amount and invoice amount is more than down payment then how sys will adjust WHTax amount ..what configuration need to be done.. help will