I need a resultset with 10 rows from dual
Which is the easiest SELECT I have to write, when the question is: "I need a resultset with 10 rows from dual"
one solution is
SELECT 'X' FROM EMP WHERE ROWNUM <= 10;
problem: if emp has fewer than 10 rows, I have an incorrect resultset
another problem: if I need 1000 and not 10 dummy-rows, than is emp definitely the wrong way, because the default-emp table has only 14 rows.
Is there an easy generic solution for this problem? If I need only one row, Oracle has the workaround with the DUAL-table.
What about this new method (dedicated by me to this great FORUM!). It is easy to use, easy to understand, and very fast:
SQL> set echo on
SQL> set timing on
SQL> select rownum
2 from all_objects
3 where rownum <=10;
ROWNUM
1
2
3
4
5
6
7
8
9
10
10 rows selected.
Elapsed: 00:00:00.00
SQL> select COUNT(rownum)
2 from all_objects
3 where rownum <=1000;
COUNT(ROWNUM)
1000
Elapsed: 00:00:00.00
SQL> with r1000
2 as (select rownum
3 from all_objects
4 where rownum <=1000)
5 select count(rownum)
6 from r1000, r1000
7 where rownum <= 1000000;
COUNT(ROWNUM)
1000000
Elapsed: 00:00:00.05 -- !for 1 million numbers!
SQL> with r1000
2 as (select rownum
3 from all_objects
4 where rownum <=1000)
5 select count(rownum)
6 from r1000, r1000, r1000
7 where rownum <= 10000000;
COUNT(ROWNUM)
10000000
Elapsed: 00:00:04.09 -- !for 10 millions numbers!
Similar Messages
-
Create a view with datatype from dual
I have Windows XP with 10g 10.2.0.1.0
I need to create a view from dual and with data type, such as NUMBER(5,2), NUMBER or VARCHAR2(20) .
such as:
create view test(view_test varchar2(20)) as (select view_test from dual)
Please help. Thanks in advance.It does seem kind of odd, but you can do something like this with the CAST function:
SQL> create view dual_view as
2 select cast(null as number(5,2)) col1
3 ,cast(null as date) col2
4 ,cast(null as varchar2(30)) col3
5 from dual;
View created.
SQL> desc dual_view
Name Null? Type
COL1 NUMBER(5,2)
COL2 DATE
COL3 VARCHAR2(30)I used NULLs but you can use actual values if you want. -
Select multiple rows from dual table
Is it possible to select multiple rows from dual table using a single select statement.
i.e., i want the out put to be
column_name
1
2
3
4
Edited by: vidya.ramachandra on Dec 14, 2009 8:24 AMAside from the fact you're responding to an old thread...
1002424 wrote:
While using CONNECT BY, I see it always leave behind one row.
Suppose I have a condition based on which I have to generate constant rows like
SELECT 1 FROM DUAL WHERE ROWNUM < N;
Here if N = 0, still it gives out single row.... you are obviously doing something wrong in your code elsewhere, because that SQL statement does not always return a single row...
SQL> SELECT 1 FROM DUAL WHERE ROWNUM < 0;
no rows selected
SQL> -
Need to delete blank rows from various worksheets in same workbook-reg
Hi Team,
I am searching for a macro to delete the blank rows from my worksheets.
Sub testIt()
Dim r As Long, endRow As Long, pasteRowIndex As Long, Worksheet As Object
Application.ScreenUpdating = False
endRow = 1000
pasteRowIndex = 1
For r = 1 To endRow
If Cells(r, Columns("A").Column).Value = "12345" Then
Rows(r).Select
Selection.Copy
Sheets("12345").Select
Rows(pasteRowIndex).Select
ActiveSheet.Paste
CutCopyMode = False
pasteRowIndex = pasteRowIndex + 1
Sheets("NORMAL").Select
End If
If Cells(r, Columns("A").Column).Value = "45678" Then
Rows(r).Select
Selection.Copy
Sheets("45678").Select
Rows(pasteRowIndex).Select
ActiveSheet.Paste
pasteRowIndex = pasteRowIndex + 1
Sheets("NORMAL").Select
End If
If Cells(r, Columns("A").Column).Value = "36925" Then
Rows(r).Select
Selection.Copy
Sheets("36925").Select
Rows(pasteRowIndex).Select
ActiveSheet.Paste
pasteRowIndex = pasteRowIndex + 1
Sheets("NORMAL").Select
End If
If Cells(r, Columns("A").Column).Value = "789456" Then
Rows(r).Select
Selection.Copy
Sheets("789456").Select
Rows(pasteRowIndex).Select
ActiveSheet.Paste
pasteRowIndex = pasteRowIndex + 1
Sheets("NORMAL").Select
next r
end sub()
the above code searches for the value "12345" "45678" "36925" "789456" if found in worksheet (normal) then it picks the value and paste it in new corresponding worksheet with sheet number (12345). while pasting like
this it has some blank rows so it need to delete the rows help me out of this problem. thanks in advanceHi vigneshvicky,
This code snippet works fine to delete the blank rows, please try it:
ActiveSheet.UsedRange.Select
'Deletes the entire row within the selection if the ENTIRE row contains no data.
Dim i As Long
'Turn off calculation and screenupdating to speed up the macro.
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
'Work backwards because we are deleting rows.
For i = Selection.Rows.Count To 1 Step -1
If WorksheetFunction.CountA(Selection.Rows(i)) = 0 Then
Selection.Rows(i).EntireRow.Delete
End If
Next i
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Need to remove duplicate rows from a table
Hi Gurus ,
I am using oracle 11.2.0.3 .
SQL> desc osstage.S_EVT_ACT_X;
Name Null? Type
ROW_ID NOT NULL VARCHAR2(15 CHAR)
LAST_UPD NOT NULL DATE
PAR_ROW_ID NOT NULL VARCHAR2(15 CHAR)
ATTRIB_17 NUMBER(22,7)
ATTRIB_26 DATE
ATTRIB_02 VARCHAR2(100 CHAR)
PROCESS_TIMESTAMP TIMESTAMP(6);
now when i give the below command it gives the error as someone has disabled the constraint accidently .
alter table s_evt_act_x enable constraint S_EVT_ACT_X_P1;
Error starting at line 3 in command:
alter table s_evt_act_x enable constraint S_EVT_ACT_X_P1
Error report:
SQL Error: ORA-02437: cannot validate (OSSTAGE.S_EVT_ACT_X_P1) - primary key violated
02437. 00000 - "cannot validate (%s.%s) - primary key violated"
*Cause: attempted to validate a primary key with duplicate values or null
values.
*Action: remove the duplicates and null values before enabling a primary
key.
Can you please guide me with this issue .Please refer
Script: Deleting Duplicate Rows from a Table (Doc ID 31413.1)
How to Find or Delete Duplicate Rows in a Table (Doc ID 1004425.6) -
In need of help with Shockwave from experts and community please.
I have seen posts where people are having the same issue with Chrome, but I am using Windows 8 playing my FB games using Firefox. I have filled out their little "box" that they ask me to about 10 times and I am over it. I went to see if my Adobe SW was installed right, but it doesn't show anything moving. The strange thing is...I had already uninstalled it and reinstalled it the day before. I do have screen shots that I would like to share, and I am asking if anyone else is getting this same error.
***What happens is I will be playing my game and then "poof" out of nowhere the 2 tabs I had opened are gone and I am back to my desktop.
***Another issue that comes up all the time, and then the tabs will close, is that a small rectangular box will come up and it goes away so fast you don't get a chance to read it.
But as I said I have screen shots.
Everything on my computer is up to date, my husband works in the IT field and he can build a computer from the guts up. That's how I know it is not on my end. Y'all don't know how much I really do appreciate the fact that you took the time to read my post and any suggestions on how to solve this issue.
Have a very great day,
snoopyfan6200
********** As you see I am a Huge Snoopy Fan. I have about 450 items in my collection. And the 6/2/00....well that was the day my Dad passed away.********Hi,
This is a forum for Adobe FormsCentral. Please post your questions on Flash Player forum at http://forums.adobe.com/community/flashplayer. I believe you'll get help over there.
Thanks,
Wenlan -
Need to remove duplicate rows from distinct query
Hello,
I have the following query:
SELECT tiab.abnr abnr, tiab.namn namn, (CAST(tiab.GATUNR||' '||tiab.gata AS VARCHAR2(254))) ADR, tiab.boxpnr boxpnr, tiab.boxort boxort,
(CAST(tiab.RIKTNRDISPLAY AS VARCHAR2(254))) RIKTNR, (CAST(tiab.TELNRDISPLAY AS VARCHAR2(254))) TELNR,
DECODE((select count(tior.tigilopnr) from tis.tior where abnr = tiab.abnr and inplnr IN (3797886)),0 ,NULL , 1, tior.tigilopnr, 'N/A') tigilopnr
FROM tis.tiab
JOIN tis.tior on tiab.abnr = tior.abnr
WHERE tior.inplnr IN (3797886)
ORDER BY tiab.ABNR )
ORDER BY abnr;
It returns the following:
14684940 Pizza Station Inc The Lafayette 26170 St Marys 304 684-2411
15123161 Chris Test 554 Easy St n 43333 Columbus 614 555-5555
15123162 Chris Test2 5556 Easy St 43333 Columbus 614 555-5151 2553304 --> keep this one
15123162 Chris Test2 5556 Easy St 43333 Columbus 614 555-5151 -- not show this
I have tried several different things as well as looking through the forums but have not found anything that will only give me unique records based only on the first column. This query works fine as long as there
are not 2 records returned with column1 being identical.
Final results should look like this:
14684940 Pizza Station Inc The Lafayette 26170 St Marys 304 684-2411
15123161 Chris Test 554 Easy St n 43333 Columbus 614 555-5555
15123162 Chris Test2 5556 Easy St 43333 Columbus 614 555-5151 2553304
Thanks in advance for the assistance.Hello,
Try:
SELECT abnr, namn, ADR, boxpnr, boxort,RIKTNR, TELNR,tigilopnr
FROM (
SELECT tiab.abnr abnr, tiab.namn namn, (CAST(tiab.GATUNR||' '||tiab.gata AS VARCHAR2(254))) ADR, tiab.boxpnr boxpnr, tiab.boxort boxort,
(CAST(tiab.RIKTNRDISPLAY AS VARCHAR2(254))) RIKTNR, (CAST(tiab.TELNRDISPLAY AS VARCHAR2(254))) TELNR,
DECODE((select count(tior.tigilopnr) from tis.tior where abnr = tiab.abnr and inplnr IN (3797886)),0 ,NULL , 1, tior.tigilopnr, 'N/A') tigilopnr,
ROW_NUMBER () OVER (PARTITION BY tiab.abnr ORDER BY (CAST(tiab.TELNRDISPLAY AS VARCHAR2(254))) NULLS LAST) row_num
FROM tis.tiab
JOIN tis.tior on tiab.abnr = tior.abnr
WHERE tior.inplnr IN (3797886))
WHERE row_num <= 1
ORDER BY abnr;Or, with your current query:
SELECT abnr, namn, ADR, boxpnr, boxort,RIKTNR, TELNR,tigilopnr
FROM (
SELECT distinct tiab.abnr abnr, tiab.namn namn, (CAST(tiab.GATUNR||' '||tiab.gata AS VARCHAR2(254))) ADR, tiab.boxpnr boxpnr, tiab.boxort boxort,
(CAST(tiab.RIKTNRDISPLAY AS VARCHAR2(254))) RIKTNR, (CAST(tiab.TELNRDISPLAY AS VARCHAR2(254))) TELNR,
DECODE((select count(tior.tigilopnr) from tis.tior where abnr = tiab.abnr and inplnr IN (3797886)),0 ,NULL , 1, tior.tigilopnr, 'N/A') tigilopnr,
ROW_NUMBER () OVER (PARTITION BY tiab.abnr ORDER BY (CAST(tiab.TELNRDISPLAY AS VARCHAR2(254))) NULLS LAST) row_num
FROM tis.tiab
JOIN tis.tior on tiab.abnr = tior.abnr
WHERE tior.inplnr IN (3797886))
WHERE row_num <= 1
ORDER BY abnr; -
How to get multiple rows from database table?
hello !
I need to get multiple rows from a OLEDB database table and display them on a table object.
I did "Wrap in subfrom" on the table, set subform of the table to "flowed", and checked "Repeat row for each data item" of Row1 of the table.
But I can get only one row on the table object.
I need your help.
ThanksHi,
best practices when deleting multiple rows is to do this on the business service, not the view layer for performance reasons. When you selected the rows to delete and press submit, then in a managed bean you access thetable instance (put a reference to a managed bean from the table "binding" property") and call getSeletedRowKeys. In JDeveloper 11g, ADF Faces returns the RowKeySet as a Set of List, where each list conatins the server side row key (e.g. oracle.jbo.Key) if you use ADF BC. Then you create a List (ArrayList) with this keys in it and call a method exposed on the business service (through a method activity in ADF) and pass the list as an argument. On the server side you then access the View Object that holds the data and find the row to delte by the keys in the list
Example 134 here: http://blogs.oracle.com/smuenchadf/examples/#134 provides you with the code
Frank -
Remove a row from multiple tables
Hello,
I have a form that has what appears to be one table. Since I needed 30 columns (29 of them are single character fields) I had to use 2 table objects. Then I needed the ability to add and remove rows. Adding a row at the end is easy enough. Deleting a specific row is the problem. At the moment, I added a third table which has a header row and a item body row. the body row is a button with the intention of removing that entire row from the large table. This means it needs to remove the row from all 3 tables.
My structure is:
form1
(Some other flowed subform that doesn't matter for us)
SubformPersonnel (a flowed subform)
SubformHeader (a positioned subform)
TextOverallHeader (text to label the oeverall 3 tables)
ButtonAddRow (adds a row to the end of all 3 tables)
SubformPersonnelTable (a positioned subform)
ContractorTableRemove (a table with 1 column for the Remove button)
HeaderRow (A hidden row to align the table with the other 2)
Item (A row with the Remove button)CellRemoveButton (the cell with the remove button and associated JavaScript)
ContractorTableLeft (a table with the left 15 printed columns)
HeaderRow
Contractor (A row of data to be removed when CellButton above is clicked)
ContractorTableRight (a table with the right 15 printed columns)
HeaderRow
Contractor (A row of data to be removed when CellButton above is clicked)
(Some other flowed subforms that I am not worried about at the moment)
The 3 tables are aligned so the headers all line up, with no spaces between them. The body rows then line up and this looks like one large table. From left to right, they are:
ContractorTableRemove, ContractorTableLeft, ContractorTableRight
So Item and Contractor rows are added when ButtonAddRow is clicked in the overall header. The intial count is set to 8 for each table, so I get 8 rows at startup. The minimum count is set to 1 for each. I know that each row of each table has the same index number because I filled those into a cell in each table durig the cell's initialize. This line, in the CellRemoveButton's click event deletes that cell's row in that table:
this.parent.parent._Item.removeInstance(this.parent.index);
I have tried all sorts of ways to delete the same row (using same index #) in the other 2 tables: ContractorTableLeft and ContractorTableRight, but don't seem to be getting the correct syntax correct. I have tried hard coding the references, using .parent as shown below, and also tried using an index of 1 just to try deleting a row with no results.
this.parent.parent.parent.ContractorTableLeft._Contractor.removeInstance(this.parent.inde x);
Can someone get me the correct syntax here?
I have seen examples of putting a hidden delete button on each table and clicking that, but I am concerned that it will get in the way of the tables on either side of the table it is in. I reeally want to just reference the row and remove it so I can avoid any problems these additional delete problems may cause.
I have copied the form to https://acrobat.com/#d=7M8R50rEHf4AaVXppwyKLwThank you, Niall. Much appreciated!
The Delete button was more to make sure one could delete these outside a button in the actual row and I see I had the index wrong such that I was deleting the second row and not the first. I had toyed with using this as a hidden button if I could pass the index to the event's function.
I had not thought of adding the reference to each row as a variable. It seems to work very well.
For future reference to others, here is the code from the cellRemoveButton click event:
// Declare some variables
var i = this.parent.index;
var oContractorLeft = ContractorTableLeft.Contractor;
var oContractorRight = ContractorTableRight.Contractor;
// Remove this row by accessing its index within the set of 'Item' row instances of the parent table
_Item.removeInstance(i);
// Since this table is actually 3 tables, we need to remove the other two table's instances as well.
// Their index should be the same, so we just need to get their names correct.
oContractorLeft.instanceManager.removeInstance(i);
oContractorRight.instanceManager.removeInstance(i);
// removing the row doesn't trigger calculations in tables in the form's current target (fixed in later versions of Acrobat)
// force calculations to fire so the ItemIndex field's value is updated according to the remaining row's indexes
// see http://forms.stefcameron.com/2006/05/20/add-recalculate/
xfa.form.recalculate(1);
Again, thank you!
Karl -
Selective deletion of a row from a cube
Hi Friends,
I need to delete a row from a cube through selective deletion from manage tab. I had struck while giving selecting the criteria for that deletion.
My Quesion is;
1) What criteria i need to give to delete the row apart from business related information?
2) What is data packet SID ? what i have to mention in that column?
3) What is Request id SID? what i have to mention in that column?
Please help me on the above issue.
regards,
MaheshHallo
Of xourse you do it for example from Infoprovider, right click maanage, Content (first tab) Selective deletion.
Then you get a tab where you can schedule the job according to the selections in the tab Selective Deletion where you can set a filter for the characteristics included in the Cube.
You can select single Characteristics vlue oder range or multiple.
If you want to dlete a record than you have to know the key of this records. For example if you have
customer
company
month
if you select only month, then you delete all month but if you restrict to month and cusotmer than you delete the combination of them.
Reuest sid is the identifier of the request which you see on the tab manage of the cube. you select on that and in this case you will delete all request it means all records loaded with the request.
http://help.sap.com/saphelp_nw04/helpdata/en/e3/e60138fede083de10000009b38f8cf/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/e3/e60138fede083de10000009b38f8cf/frameset.htm
Mike
Best Regards
Mike -
How to delete the committed row from a table from its VOImpl class ??
I am new to ADF and I have problem to solve. To perform roll back I am using fetching key before roll back and setting it after undo operation, so that I can stay back in the currently selected row. But in my case I am using application model commit for one LOV attribute selection in the row. So when ever I am performing roll back operation after inserting a row, the values other than this committed LOV attribute gets roll backed, but I need remove the entire row from table. Does there any option to remove a row based on the attribute values of a row from VO's row implementation or from bean class in a performance optimized way ?
Thanks in advance..........http://java.sun.com/javase/6/docs/api/javax/swing/table/DefaultTableModel.html#removeRow(int)
Why did you mark it answered but gave no dukes to finalight? That's not how it works.
You should mark his answer as correct and give him at least one duke, for the effort! -
Deleting Rows From A Table After Running a Report
I've created a report that inserts rows into a table on the asp page then calls a BI Publisher report to display the data. After running the report in BI Publisher I need to delete the rows from the table that had just been inserted. How is the best way to go about this in BI Publisher?
The best way I know of would be to use an "afterReport trigger".
An afterReport trigger fires after the XML output has been generated.
Thanks,
Bipuser -
JDeveloper + WebServices, RETURN multiple rows from pl/sql
I need to return multiple rows from pl/sql procedure or function and publish it as a Web Service through JDeveloper.
I try to use ref cursor, but then found that it is impossible to use ref cursor as a return value in Web Services.
Please, help me to achieve result.Hello. I tried to make commands from article, but got errors
"C:\Program Files\Java\jdk1.6.0_18\bin\java" -jar D:\oracle\Middleware\oracle_common\modules\oracle.webservices_11.1.1\wsa.jar -plsqlAssemble -appName Echo -sql wo -dataSource jdbc/OracleManagedDS -dbConnection jdbc:oracle:thin:@192.168.246.2:1521:data -dbUser syd/manager -style rpc -use encoded
Error: Interface oracle.generated.wo: The class could not be loaded from the class path. -
Mission:
To create a summary table with Rows from several (yet to be determined) instances
Coordinates of the enemy (or Row in question):
ROOT.category[*].sub_category_total.sub_category_summary.Row1
Background information:
An order form with option for several categories (2 – 10) with subcategories (2 – 20).
Since the finished form might be up to 20 pages long I would like to get to the point
with a click of a button (so to speak)
Therefore a summary list seems the only logic solution.
Reward:
Unending gratefulness and publishing of finished sample for others to learn from
Additional Note:
Should you choose to accept this mission I will never deny your existence and will
always give credit to whom credit belongs.
This message will NOT self-destruct.Hi Steve,
thanks for the example ... nice and close but not 100 % solution.
The sample requires me to set up the summary table with fixed rows.
But I don't know how many main categories & subcategories will be there - it can vary between 2 and 20.
One solution would be to set up a table with 20+ rows and hide them if rawValue ... equals 0.
Might work - but is not very elegant ....
I guess I was looking for the script that counts the instances and then creates automatically the necessary rows.
I know it is a lot to ask in a forum ... but I guess it might be possible. Isn't it??
Please let me know if I'm reaching for the impossible
Jixin -
Removing Duplicate Rows from resultSet
I have a query pulling data from 5 tables in 12 columns. I have rows where all of the data is duplicated with the exception of one date column. How would I go about deleting rows that are duplicates with the exception of this one column? I still need to pull the date from the date column with the Max(date).
i.e.
Bob Smith 1 2 3 4 12-Jul-2006
Bob Smith 1 2 3 4 02-Aug-2006
Bob Smith 1 2 3 4 21-Jan-2006
Form this resultset I only want one row
Thanks.this example might be of help.
SQL> select * from employees;
YEAR EM NAME PO
2001 02 Scott 91
2001 02 Scott 01
2001 02 Scott 07
2001 03 Tom 81
2001 03 Tom 84
2001 03 Tom 87
6 rows selected.
SQL> select year, empcode, name, position,
2 row_number() over (partition by year, empcode, name
3 order by year, empcode, name, position) as rn
4 from employees;
YEAR EM NAME PO RN
2001 02 Scott 01 1
2001 02 Scott 07 2
2001 02 Scott 91 3
2001 03 Tom 81 1
2001 03 Tom 84 2
2001 03 Tom 87 3
6 rows selected.
SQL> Select year, empcode, name, position
2 From (Select year, empcode, name, position,
3 row_number() over (partition by year, empcode, name
4 order by year, empcode, name, position) as rn
5 From employees) emp
6 Where rn = 1;
YEAR EM NAME PO
2001 02 Scott 01
2001 03 Tom 81
SQL> Delete From employees
2 Where rowid in (Select emp.rid
3 From (Select year, empcode, name, position,
4 rowid as rid,
5 row_number() over (partition by year, empcode, name
6 order by year, empcode, name, position) as rn
7 From employees) emp
8 Where emp.rn > 1);
4 rows deleted.
SQL> select * from employees;
YEAR EM NAME PO
2001 02 Scott 01
2001 03 Tom 81
SQL> if you can post a sample create tables and data it will help us provide you a some solutions.
Maybe you are looking for
-
Hi there, I got a problem with starting my MacBook Pro, I started my macbook this morning, and the macbook keeps loading in Chrome, and then I force shut down it by long time pressing the Power button... After that, I cannot open my Macbook, it keep
-
Qty sharing of same material b/w 2 suppliers
Hello experts, we have a scenario where in we have to share same part for two supplers. is it possible through Quto arrangement ?. if it has to be shared for 50% each how to do that. please explain.
-
HT4061 can not access I-Phone was locked by younger child trying pass code
See question above
-
In iMovie 09 can record video w/ iSight with external microphone?
In iMovie '09 is there a way to capture video using iSight camera while having the audio come from a different microphone other than the iSight microphone? If so, how? I've attached an external microphone and selected it under settings and for the vo
-
Hello, LV7.1 et USB 6008 et ni daq 8.6 Je réalise un chart avec 2 entrées analogiques. Au bout d'un certain temps ( 1 heures )la 2 ème courbes s'affiche par intermitance. pourquoi? et comment supprimer ce problème. Autre question: La 2ème courbes est