Dynamis table and columns in Cursor

Hi,
I´m implementing an oracle function find a row position when I order the table by a dynamic column passed into the function. below is the algorithm, but I don´t know some sintax keywords to loop from my cursor and how to implement a dynamic cursor constructed from function parameters.
Can someone Help me please?
Thanks in advance
CREATE OR REPLACE
FUNCTION GET_ROW_POSITION (tableName VARCHAR2, columnId VARCHAR2, columnOrder VARCHAR2, idToShearch VARCHAR2)
RETURN VARCHAR2 IS
TYPE GenericCurTyp IS REF CURSOR;
cur1 GenericCurTyp;
i integer = 0;
begin
SELECT columnId into cur1 FROM tableName order by columnOrder;
Loop in cur1
i++;
if(cur1.columnId = idToShearch) then
CLOSE cur1;
return i;
end if;
end loop;
CLOSE cur1;
RETURN NULL;
END;
Operator

Generally speaking, this kind of generic function is a bad thing, but if you insist, then you need to do it the most efficient way you can, and that does not include scrolling through a cursor. It does require dynamic sql though.
I would (if forced at gunpoint) write it like:
CREATE OR REPLACE FUNCTION get_row_position (p_tab  VARCHAR2,
                                             p_col  VARCHAR2,
                                             p_sort VARCHAR2,
                                             p_id   VARCHAR2) RETURN NUMBER IS
   l_ret NUMBER;
   l_sql VARCHAR2(4000);
BEGIN
   l_sql := 'SELECT rn FROM (SELECT '||p_col||
            ' col, ROW_NUMBER() OVER (ORDER BY '||p_sort||') rn FROM '||
            p_tab||') WHERE col = :b1';
   EXECUTE IMMEDIATE l_sql INTO l_ret USING p_id;
   return l_ret;
END;John

Similar Messages

  • Dynamic table and columns

    Dear experts,
    is it possible to build a form with a table, defined in web dynpro abap?
    in my scenario, there should be a web dynpro screen defining the columns to be visible or not. These values have to be passed to an interactive form.
    Does anyone know how to achieve this?
    The only way I know to build a table on an interactive form is using table creation assistent in layout tab.
    Regards,
    Florian

    Hello,
    1) you should NOT use the tables at all, I mean the tables like in MS Word, the tables not based on subforms, they´re not flexible, weird in all aspects
    2) you should understand how it works in Adobe: you must create everything you will possibly use in the form and then hide the parts you don´t use. That means for table: you must create the whle table - all columns - and on runtime you can hide few columns if you like. But you cannot make visible something you have not created before
    3) I am looking forward to see you around with some SDN points received. That would, in my eyes, mean that you help people with their beginners´ questions if you ask your own.
    Regards Otto

  • Get description of tables and columns

    Good afternoon.
    Is there any option in SAP B1 to get a description of table and column dynamically? That is, without the "Tools -> Queries -> Query Generator"?
    I am developing an add-on, which lists all the tables and columns of the sap, and I have to bring the descriptions automatically. If you do not have to get the SDK route descriptions, as you suggest doing this?
    Edited by: Harley Rodrigues on Feb 1, 2012 9:38 PM

    Hi Harley,
    Welcome to the Forum!
    please refer to your SDK Help. you can find it from this path C:\Program Files\SAP\SAP Business One SDK\Help
    also alternatively you can view it from your MS SQL Server Management under Databases
    regards,
    Fidel

  • Can we hide the tables and columns from subject areas in the front end

    Hi,
    Is there any way to hide the tables and columns from the subject area in front end.I need to create a report with some tables which the user does not want to see.So after creating the reprot can I hide those tables and columns in the front end

    Hi,
    Your question is not that clear to me...do you want to hide the entire table/column that dont want to show up in the front end then you could do in Presneation Layer in the RPD by going Permissions in the property of that object.
    But if you want to hide the column in the report that can be visible in the subject Area: go to column properties -> Column fomat...thereis Hide option.
    Can you please elaborate your question...what exactly you are looking for...
    --SK                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Using of already existing logical tables and columns in a new subject area.

    Hi Every one,
    i am new to OBIEE technology.
    In my project i need to create a new subject area for already existing RPD.
    In that RPD there are some logical tables and column created for previous project and i need to use those in this new subject area that i am going to create.
    My question is what is the best way to use them .
    I mean just to drag and drop them into new subject area or any other way.
    please have your valuable suggestions
    thanking you

    Yes, you can basically copy paste all the tables that you need from BMM layer into your new folder in the presentation layer. Just make sure all the joins are defined well between all the tables that exists in the new folder, so you wont end up running into ODBC errors when you run analysis.
    Hope this helps.
    Thanks,
    -Amith.

  • Retrieve tables and column names in a universe

    Hi - Is there a way to retrieve tables and columns used in a given universe? We have to do analysis and need to know the tables as well as fields used anywhere in any object defined in the universe.
    I tried Query Builder and did some selection on ci_infoobjects and ci_appobjects; they don't seem to have that kind of information.
    Please advise.
    Thanks

    Hi.
    Are you try with the option save as ... and choose to pdf inside the designer?
    In designer tools->option you can choose what you want it print/PDF.
    I hope it be helpfull for you.
    Regards.

  • To get the input values from the dynamic tables and save in the SAPdatabase

    HI EXPERTS,
    I AM NEW TO WEB DYNPRO ABAP. MY QUERY IS HOW TO GET THE VALUES THE USER ENTERS IN THE DYNAMIC TABLE AND SAVE THE SAME IN THE SAP DATABASE. I HAVE CREATED THE TABLES BUTTON EVERYTHING BUT I DONT KNOW THE CODE HOW TO DO. PLEASE HELP ME OUT.

    >
    vadiv_maha wrote:
    > HI EXPERTS,
    >
    > I AM NEW TO WEB DYNPRO ABAP. MY QUERY IS HOW TO GET THE VALUES THE USER ENTERS IN THE DYNAMIC TABLE AND SAVE THE SAME IN THE SAP DATABASE. I HAVE CREATED THE TABLES BUTTON EVERYTHING BUT I DONT KNOW THE CODE HOW TO DO. PLEASE HELP ME OUT.
    hi,
    1 there is one property OnAction of the button...
    2 So, in this event handler,you have to read the context node to which ur table is binded
    3 use the code wizard
    control+f7
    , and use the method
    get_static_attribute_table
    4 now u have got the vaues in internal table,so now as pointed in the previous reply, you can use the
    Update
    or
    Modify
    statement...
    regards,
    Amit

  • Tables and Columns used in Universe (BO 6.5)

    Hi All,
    Please help me out with the below queries:
    1. Is there any automated way to find out which report is using which universe? (may be through a SQL fired in BO repository)
    (Note: As per the BO Documentation, OBJ_X_DOCUMENTS This is the only table in the document domain. It stores the binary content of all documents sent to the repository (through the user actions Publish to corporate documents, Send to users or Send to Broadcast Agent). The document contents are stored as BLOBs (Binary Large Objects) stored in slices.)
    2. I need to identify the universes which use certain tables and columns.
    I fired the following SQL in BO repository:
    SELECT
    UNV_UNIVERSE.UNI_FILENAME,
    UNV_UNIVERSE.UNI_LONGNAME,
    UNV_TABLE.TAB_NAME,
    UNV_COLUMNS.COLUMN_NAME
    FROM UNV_UNIVERSE, UNV_TABLE,UNV_COLUMNS
    WHERE
    UNV_UNIVERSE.UNIVERSE_ID = UNV_TABLE.UNIVERSE_ID
    AND UNV_TABLE.TABLE_ID = UNV_COLUMNS.TABLE_ID
    But as 'UNV_COLUMNS' table is empty, no data is returned. My question is is this table supposed to be empty in BO repository?
    Is there any other way to find out this (identify the universes which use certain tables and columns)?
    Many Thanks & Regards,
    Sandeep

    Hi,
    Please find the below list of tables created in the BO repository, which helps you to retrieve the information related to reports, universes, users e.t.c.
    OBJ_M_ACTOR
    OBJ_M_ACTORDOC
    OBJ_M_ACTORLINK
    OBJ_M_CATEG
    OBJ_M_CONNECTDATA
    OBJ_M_CONNECTION
    OBJ_M_DOCAT
    OBJ_M_DOCATVAR
    OBJ_M_DOCCATEG
    OBJ_M_DOCCST
    OBJ_M_DOCUMENTS
    OBJ_M_GENPAR
    OBJ_M_MAGICID
    OBJ_M_OBJSLICE
    OBJ_M_REPOSITORY
    OBJ_M_RESERVATION
    OBJ_M_RESLINK
    OBJ_M_TIMESTAMP
    OBJ_M_UNIVCST
    OBJ_M_UNIVDBCST
    OBJ_M_UNIVERSES
    OBJ_M_UNIVSLC
    OBJ_M_USRATTR
    OBJ_X_DOCUMENTS
    UNV_AUDIT
    UNV_CLASS
    UNV_CLASS_DATA
    UNV_COLUMNS
    UNV_COLUMN_DATA
    UNV_CONTEXT
    UNV_CONTEXT_DATA
    UNV_CTX_JOIN
    UNV_DIMENSION
    UNV_DIM_OBJ
    UNV_JOIN
    UNV_JOINCONTENT
    UNV_JOIN_DATA
    UNV_JOIN_OBJECT
    UNV_OBJCONTENT
    UNV_OBJECT
    UNV_OBJECT_DATA
    UNV_OBJECT_KEY
    UNV_OBJ_COLUMN
    UNV_OBJ_TAB
    UNV_PROPERTY
    UNV_PROP_DATA
    UNV_PROP_TAB
    UNV_RELATIONS
    UNV_TABLE
    UNV_TABLE_DATA
    UNV_TAB_OBJ
    UNV_TAB_PROP
    UNV_UNIVERSE
    UNV_UNIVERSE_DATA
    UNV_X_UNIVERSES
    Hope this tables helps you.

  • Sql query parsing (retrieve tables and columns used in query)

    Hi,
    1. Is there any view in Oracle which can tell me, which tables and columns were used in the last ran query, no matter how complex the query is.
    2. Secondly I can get table names, used in stored procedures and views, using USER_DEPENDENCIES VIEW, however this System View does not return column names, used in that procedure / view, any idea please .
    Thanks and Regards,
    Luqman

    luqman123 wrote:
    Hi,
    1. Is there any view in Oracle which can tell me, which tables and columns were used in the last ran query, no matter how complex the query is.I don't believe so. You can look at V$SQL and retrieve the actual SQL text from there.
    2. Secondly I can get table names, used in stored procedures and views, using USER_DEPENDENCIES VIEW, however this System View does not return column names, used in that procedure / view, any idea please .Oracle added fine grained dependency tracking in 11g, but didn't expose any views to query this information. However, it has been reverse engineered a bit: About Oracle: DBA_DEPENDENCY_COLUMNS

  • Help with adding a table and column which are strings to a database

    I want to add a column and table into a database.
    I want to do this both for the Table and Column.
    I want (Data) and Test to be replaced with my strings.
    String MyData = "My column"; // This will change at times.
    String MyData2 = "My table";
    String sql = "Insert into Test (Data) Values (?)";     
    How can I change (Data) and Test to add variables "MyData" and "MyData2".
    Thanks.

    This is a fairly short intro to JDBC that gives the details:
    http://java.sun.com/docs/books/tutorial/jdbc/basics/index.html

  • Including table and column comment in the Data Modeler

    Hi all,
    I used Oracle's SQL Developer Data Modeler (Version 3.0.0.665) and created a data model for my project. I e-mailed a PDF format of the data model to our Systems Analyst. She asked if I could re-create the data model and include table and column comments. Is this a possibility and if so how is this done?
    Thank you for your input,
    Seyed

    Hi Kent,
    Using the information you provided and Oracle’s Working with SQL Developer Modeler Reporting I did the following:
    1) Created a Reporting Schema User
    1.1) Using my Oracle 10g Personal Edition, I created a new user and gave him DBA administrative privileges
    2) Exported Relational Design to Reporting Schema
    2.1) Opened the Relational Design
    2.2) Exported it to the Reporting Schema. Note, I never got a message ‘Design has been exported successfully’.
    3) Reviewed the Report Results
    I think exporting the relational design was not successful, and didn’t get any error messages. Had step 2 completed successfully, I would have reviewed the Report Results in SQL Developer. By the way, I know I have marked this topic as closed, but would like to learn your method too.
    Thank you for your help,
    Seyed

  • Table and columns separation  in string

    Hi,
    I am having one column data containing combining table and column names like
    act_hand_table.work_order
    i want seperate table and column names
    i want separte . filed
    Please help me
    Regards,
    Kiran

    Kiran Bathula wrote:
    Hi,
    I am having one column data containing combining table and column names like
    act_hand_table.work_order
    i want seperate table and column names
    i want separte . filed
    Please help me
    Regards,
    KiranTry
    SQL> ed
    Wrote file afiedt.buf
      1  with t as
      2  (select 'act_hand_table.work_order' col from dual)
      3* select substr(col,1,instr(col,'.',1)-1)tbl,substr(col,instr(col,'.',1)+1) from t
    SQL> /
    TBL            SUBSTR(COL
    act_hand_table work_orderHope this helps
    Regards,
    Achyut

  • Parse SQL query and extract source tables and columns

    Hello,
    I have a set of SQL queries and I have to extract the source tables and columns from them.
    For example:
    Let's imagine that we have two tables
    CREATE TABLE T1 (col1 number, col2 number, col3 number)
    CREATE TABLE T2 (col1 number, col2 number, col3 number)
    We have the following query:
    SELECT
    T1.col1,
    T1.col2 + T1.col3 as field2
    FROM T1 INNER JOIN T2 ON T1.col2=T2.col2
    WHERE T2.col1 = 1
    So, as a result I would like to have:
    Order Table Column
    1 T1 col1
    2 T1 col2
    2 T1 col3
    Optionally, I would like to have a list of all dependency columns (columns used in "ON", "WHERE" and "GROUP BY" clauses:
    Table Column
    T1 col2
    T2 col1
    T2 col2
    I have tried different approaches but without any success. Any help is appreciated. Thank you in advance.
    Best regards,
    Beroetz

    I have a set of SQL queries and I have to extract the source tables and columns from them. In a recent db version you can use Re: sql injection question for this.

  • Dynamic tables and conditional page break

    I have inserted a table in my form and have included an Add New Row button to insert additonal rows.   I want a maximum of 16 rows added with a subtotal field.  I want the table, then to automatically go to a new page with a subtotal field.  At the end of all pages I want to include a total field.   The table goes to the next page after a number of rows are entered, but there is not a break;  the original form continues.  How do conditionally break the page and have a (new) table display in the second page?
    Thanks for your help.

    Hi Paul,
    Thanks for working with me on this.   I have sent a copy to the gmail.com address.  I'm new to LiveCycle, so please forgive me.
    Date: Thu, 29 Jul 2010 09:18:53 -0600
    From: [email protected]
    To: [email protected]
    Subject: dynamic tables and conditional page break
    You can accomplish that with a single table and some creative script. I suggest that you get the table worked out and working correctly then we can add in the page totals and final total afterwards. Once the table is ready email the form to mailto:[email protected] and I will put together a sample for you that shows what to do. Please include a description of what you want to do with the email as the mail message and this forum are not tied together. Also if you have a data file  that fills out the table that would be useful as well.
    Paul
    >

  • The new table and Columns to look for in picking headers, etc

    Hi,
    What are the new tables and columns to look for mapping the following old ones:
    1) Pick_Slip_Number from So_Picking_Headers,
    2) Sequence_Number from SO_Picking_lines
    3) Line_ID from So_Note_References
    Thanks and Regards,
    Praveen

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by ravi alladi ([email protected]):
    Actually would it be possible to get a list of all changes in Order Management between 11 and 11i? ie what tables added, what have been modified and which ones are obsolete<HR></BLOCKQUOTE>
    Ravi
    Actually, we are working on that same analysis. If you receive any responses, please forward to myself as well.
    Thank you
    Sha Green

Maybe you are looking for

  • Dates and Exception message in MD04

    Hi all ,               When i view in MD04 t-code for one purchase order the system shown the below exception message Exception  30 = Plan process according to schedule (08/01/10/07/25/10)            06 = Start date in the past I cant understand the

  • Dynamicaly getting xml into java file

    hi, i want to xml dynamically into my java file . Is anyone having ida about it. Thanks

  • Ipod keeps needing to be restored

    I haven't been able to synch my ipod to my computer since itunes version 7.6. Every time I connect my ipod to my computer it says that itunes detects an ipod in recovery mode and the ipod should be restored. But once I restore, itunes just keeps sayi

  • Illustrator 10 and leopard

    Does anyone know if Illustrator 10 works on Leopard. Someone I work with is about to purchase a new Mac and wants to run her copy Illustrator 10. She is looking to upgrade to CS3, but it won't happen for a few months. Any input is appreciated. Thanks

  • Wf and concurrent

    Hi; Is anyone know how i can find concurrent list which i belong WF and for specific time like between 1pm to 2 pm. How i can find which package or function is working behind of those concurrent? Thanks for advice Helios