This is a discussion on Simple Cursor within the Oracle Miscellaneous forums, part of the Oracle Database category; --> Ive been looking online and cant seem to find a good example of a cursor I need to create..I ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Ive been looking online and cant seem to find a good example of a cursor I need to create..I want to assign variables in a cursor then select them in a recordset....its simple to do in sql server..but i cant seem to find a way in oracle....I dont have permission to create temp tables and Im not looking to do db outputs...if someone could provide an example that would be great... Thanks -Jim |
| |||
| Jimbo schreef: > Ive been looking online and cant seem to find a good example of a > cursor I need to create..I want to assign variables in a cursor then > select them in a recordset....its simple to do in sql server..but i > cant seem to find a way in oracle....I dont have permission to create > temp tables and Im not looking to do db outputs...if someone could > provide an example that would be great... > > > Thanks > > -Jim > AAARRRRGGHHH!!! Temp tables, TEMP tables, TEMPTABLES?!?! A cursor returns a pointer into your recordset, so I fail to see how you can "assign variables in a cursor" and "then select them". what do you want to do - and why use a cursor? Never use pl/sql when you can do it in SQL. Why would you: declare cursor c_sel_emp IS select * from emp; l_out varchar2(240); begin for r_emp in c_sel_emp loop l_out := r_emp.ename; dbms_output.put_line(l_out); end loop; end; when you can: select ename from emp; -- Regards, Frank van Bortel Top-posting is one way to shut me up... |
| |||
| ok heres what Im trying to do....Im trying to flatten a record set...so say case number 07 has orders 1 and 3 associated with it....if you do a select youll get. case number order number ----------------- -------------------- 07 1 07 3 I want to use a cursor so I can concatenate the order number field and return case number order numbers order count ------------------ --------------------- ----------------- 07 1, 3 2 I can only think to do this with a cursor....if you know another way Im all ears -Jim |
| |||
| Jimbo wrote: > ok heres what Im trying to do....Im trying to flatten a record > set...so say case number 07 has orders 1 and 3 associated with > it....if you do a select youll get. > > case number order number > ----------------- -------------------- > 07 1 > 07 3 > > I want to use a cursor so I can concatenate the order number field and > return > > case number order numbers order count > ------------------ --------------------- ----------------- > 07 1, 3 2 > > I can only think to do this with a cursor....if you know another way > Im all ears > > -Jim Have you heard of cross-tabulation? Pivot tables? Use DECODE. Example at www.psoug.org Click on Morgan's Library Click on DECODE. -- Daniel A. Morgan University of Washington damorgan@x.washington.edu (replace x with u to respond) Puget Sound Oracle Users Group www.psoug.org |
| |||
| On 27 apr, 00:22, Jimbo <jamesfer...@hotmail.com> wrote: > ok heres what Im trying to do....Im trying to flatten a record > set...so say case number 07 has orders 1 and 3 associated with > it....if you do a select youll get. > > case number order number > ----------------- -------------------- > 07 1 > 07 3 > > I want to use a cursor so I can concatenate the order number field and > return > > case number order numbers order count > ------------------ --------------------- ----------------- > 07 1, 3 2 > > I can only think to do this with a cursor....if you know another way > Im all ears > > -Jim Why would you want to flatten (denormalize) a record - what's the bigger picture behind this - probably you focus on a little piece where te big picture can give a completely different (and for Oracle, far more effective!) solution. |
| ||||
| I found an example of how to do what I was talking about...yes I want to do a pivot table...and yes a cursor is needed....heres the link... http://weblogs.asp.net/stevencohn/ar...28/362373.aspx Thanks for all your help... -Jim |