Dynamically built query on execution How to save the data in Object Type

Hi,
In pl/sql I am building and executing a query dynamically. How can I stored the output of the query in object type. I have defined the following object type and need to store the
output of the query in it. Here is the Object Type I have
CREATE OR REPLACE TYPE DEMO.FIRST_RECORDTYPE AS OBJECT(
pkid NUMBER,
pkname VARCHAR2(100);
pkcity VARCHAR2(100);
pkcounty VARCHAR2(100)
CREATE OR REPLACE TYPE DEMO.FIRST_RECORDTYPETAB AS TABLE OF FIRST_RECORDTYPE;Here is the query generated at runtime and is inside a LOOP
--I initialize my Object Type*
data := new FIRST_RECORDTYPETAB();
FOR some_cursor IN c_get_ids (username)
LOOP
x_context_count := x_context_count + 1;
-- here I build the query dynamically and the same query generated is
sql_query := 'SELECT pkid as pid ,pkname as pname,pkcity as pcity, pkcounty as pcounty FROM cities WHERE passed = <this value changes on every iteration of the cursor>'
-- and now I need to execute the above query but need to store the output
EXECUTE IMMEDIATE sql_query
INTO *<I need to save the out put in the Type I defined>*
END LOOP;
How can I save the output of the dynamically built query in the Object Type. As I am looping so the type can have several records.
Any help is appreciated.
Thanks

hai ,
solution for Dynamically built query on execution How to save the data in Object Type.
Step 1:(Object creation)
SQL> ED
Wrote file afiedt.buf
1 Create Or Replace Type contract_details As Object(
2 contract_number Varchar2(15),
3 contrcat_branch Varchar2(15)
4* );
SQL> /
Type created.
Step 2:(table creation with object)
SQL> Create Table contract_dtls(Id Number,contract contract_details)
2 /
Table created.
Step 3:(execution Of procedure to insert the dynamic ouput into object types):
Declare
LV_V_SQL_QUERY Varchar2(4000);
LV_N_CURSOR Integer;
LV_N_EXECUTE_CURSOR Integer;
LV_V_CONTRACT_BR Varchar2(15) := 'TNW'; -- change the branch name by making this as input parameter for a procedure or function
OV_V_CONTRACT_NUMBER Varchar2(15);
LV_V_CONTRACT_BRANCH Varchar2(15);
Begin
LV_V_SQL_QUERY := 'SELECT CONTRACT_NUMBER,CONTRACT_BRANCH FROM CC_CONTRACT_MASTER WHERE CONTRACT_BRANCH = '''||LV_V_CONTRACT_BR||'''';
LV_N_CURSOR := Dbms_Sql.open_Cursor;
Dbms_Sql.parse(LV_N_CURSOR,LV_V_SQL_QUERY,2);
Dbms_Sql.define_Column(LV_N_CURSOR,1,OV_V_CONTRACT_NUMBER,15);
Dbms_Sql.define_Column(LV_N_CURSOR,2,LV_V_CONTRACT_BRANCH,15);
LV_N_EXECUTE_CURSOR := Dbms_Sql.Execute(LV_N_CURSOR);
Loop
Exit When Dbms_Sql.fetch_Rows (LV_N_CURSOR)= 0;
Dbms_Sql.column_Value(LV_N_CURSOR,1,OV_V_CONTRACT_NUMBER);
Dbms_Sql.column_Value(LV_N_CURSOR,2,LV_V_CONTRACT_BRANCH);
Dbms_Output.put_Line('CONTRACT_BRANCH--'||LV_V_CONTRACT_BRANCH);
Dbms_Output.put_Line('CONTRACT_NUMBER--'||OV_V_CONTRACT_NUMBER);
INSERT INTO contract_dtls VALUES(1,CONTRACT_DETAILS(OV_V_CONTRACT_NUMBER,LV_V_CONTRACT_BRANCH));
End Loop;
Dbms_Sql.close_Cursor (LV_N_CURSOR);
COMMIT;
Exception
When Others Then
Dbms_Output.put_Line('SQLERRM--'||Sqlerrm);
Dbms_Output.put_Line('SQLERRM--'||Sqlcode);
End;
step 4:check the values are inseted in the object included table
SELECT * FROM contract_dtls;
Regards
C.karukkuvel

Similar Messages

  • How to save the data to sap abap using Adobe Flex

    Hi Everybody......
    I am new to Adobe flex with sap abap.
          How to save the data in sap abap using Adobe Flex coding is Action Script and using RFC web service.
    Please give me any suggisions on that.
    Thank you
    Venkatesh V

    Hi Venkatesh,
    Try with folowing coding...
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
         initialize="initApp()">
         <mx:Label x="10" y="23" text="Airline" width="90" id="lblAirline"/>
         <mx:TextInput x="108" y="21" id="txtAirline"/>
         <mx:Button x="10" y="49" label="Get Data" id="btnGetData" enabled="false" click="getData()"/>
         <mx:DataGrid x="10" y="97" id="dgFlightData" dataProvider="">
         </mx:DataGrid>
           <mx:Script>
              <![CDATA[
                   import mx.collections.ArrayCollection;
                   import mx.rpc.AbstractOperation;
                   import mx.rpc.events.FaultEvent;
                   import mx.rpc.soap.LoadEvent;
                   import mx.rpc.events.ResultEvent;
                   import mx.rpc.soap.WebService;
                   [Bindable] public var flightData:ArrayCollection;
        private var flightWS:WebService;
         private function initApp():void{
              flightWS = new WebService();
              flightWS.wsdl = "http://uscib20.wdf.sap.corp:50021/sap/bc/soap/wsdl11?services=ZGTEST&sap-client=000";
            flightWS.addEventListener(FaultEvent.FAULT,onWSError);
              flightWS.addEventListener(LoadEvent.LOAD,onWSDLLoaded);
             flightWS.addEventListener(ResultEvent.RESULT,onFlightWSGotResult);
              flightWS.loadWSDL();
    private function getData():void{
              var operation:AbstractOperation = flightWS.getOperation("ZGTEST");
              var input:Object = new Object();
              input.Airline = txtAirline.text.toUpperCase();
              operation.arguments = input;
              operation.send();
         private function onWSError  (event:FaultEvent):void{
         private function onWSDLLoaded(event:LoadEvent):void{
              btnGetData.enabled = true;
         private function onFlightWSGotResult(event:ResultEvent):void{
              flightData = event.result.SFLIGHT;
              ]]>
         </mx:Script>
    </mx:Application>
    Regards,
    Vinoth

  • How to save the data present in TEXT BOX?

    Hi friends i am able to create a text editor in one of my screen but i want to know how to save the data when the text is entered in that text box and retrive when they open the screen?

    Hi ,
    Please check the format below since it is based on a working code
    first you need to create a text in s010 function module...
    there should be some key based on which you plan to save the text..imagine it is Purchase order then..PO+item numner is always unique.eg:0090010(900PO/item10).so in the code you can append these two and they will be unique..so you can always retrieve them,overwrite,save them anytime you need
    **************data declarations
    TYPES: BEGIN OF TY_EDITOR,
    EDIT(254) TYPE C,
    END OF TY_EDITOR.
    data: int_line type table of tline with header line.
    data: gw_thead like thead.
    data: int_table type standard table of ty_editor.
    ****************fill header..from SO10 t-code..when you save you need the unique key..youfill it here and pass it in save_text function module
    GW_THEAD-TDNAME = loc_nam. " unique key for the text -> our unique key to identify the text
    GW_THEAD-TDID = 'ST'. " Text ID from SO10
    GW_THEAD-TDSPRAS = SY-LANGU. "current language
    GW_THEAD-TDOBJECT = 'ZXXX'. "name of the text object created in SO10
    *To Read from Container and get data to int_table
    CALL METHOD EDITOR ->GET_TEXT_AS_R3TABLE
    IMPORTING
    TABLE = int_table
    EXCEPTIONS
    ERROR_DP = 1
    ERROR_CNTL_CALL_METHOD = 2
    ERROR_DP_CREATE = 3
    POTENTIAL_DATA_LOSS = 4
    others = 5.
    IF SY-SUBRC 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    loop data from int_table and save to int_line-tdline appending it.
    *save the text
    CALL FUNCTION 'SAVE_TEXT'
    EXPORTING
    HEADER = GW_THEAD
    TABLES
    LINES = InT_LINE
    EXCEPTIONS
    ID = 1
    LANGUAGE = 2
    NAME = 3
    OBJECT = 4
    OTHERS = 5.
    IF SY-SUBRC 0.
    ENDIF.
    *To pass to Container
    CALL METHOD EDITOR ->SET_TEXT
    hope that the above sample with helps you solve the problem
    Please check and revert,
    Reward if helpful
    Regards
    Byju

  • How to save the data on the database

    Please tells me how to save the data on the database as soon as posible.
    Thank!!
    Michael

    Michael,
    What database? Citadel, or something that has an SQL?
    If the latter, use the SQL toolkit. You can get it from NI.
    Please elaborate if this is not your situation.
    Thank you

  • How to save the data of ABAP report into a notepad in desktop location???

    HI all,
    Can any one tell me how to transfer the data of ABAP report into a Notepad.
    Actually I have to schedule a ABAP report in background on daily basis and I want to transfer the
    whole record into Notepad.
    If any program is available for this..please clearify the relevent code for transferring.
    Thanks
    Rajeev

    declare a character type internal table.
    now move your data from it_data ( internal table with data ) into table itab.
    since you are running this report in background, you cannot save it to the desktop. Instead give any app server location
    data: itab(400) occurs 0 with header line.
    field-symbols: <fs1> type any.
    data: gv_file type rlgrap-filename default 'TEST.TXT'.
    data: gv_filepath type rlgrap-filename default <path>.
    LOOP AT it_data.
        DO 100 TIMES.
          ASSIGN COMPONENT sy-index OF STRUCTURE it_data TO <fs1>.
          IF sy-subrc = 0.
            CONCATENATE itab <fs1> INTO itab SEPARATED BY ' '.
          ELSE.
            EXIT.
          ENDIF.
        ENDDO.
        SHIFT itab LEFT DELETING LEADING ' '.
        APPEND itab.
        CLEAR itab.
      ENDLOOP.
      concatenate gv_filepath '/' gv_file into gv_file.
      OPEN DATASET gv_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
      IF sy-subrc = 0.
        LOOP AT itab.
          TRANSFER itab TO gv_file.
        ENDLOOP.
        CLOSE DATASET gv_file.
      ENDIF.

  • How to save the data that a user has written in a table (front panel) by using a "press button"?

    Hi,
    I have the following situation. I need to be able to save the data I write in a table (front panel) when desired.
    This allows me to modify, add new data, etc in the "Table" when wanted and to SAVE the latest information when wanted.
    I need to save all the table data by using ONLY one button.
    Thanks for the help!
    Kind regards,
    Amaloa S.

    Hi,
    Thanks for the feedback. :-)
    Your answered helped.
    In this case I need to save the Data into an ARRAY.
    Now I have the following issue. I will try to explain:
    Suppose that I have following:
    1. Several GROUPS of Data like this:
        ER-1234
        ER-3245
        ER-4786
        ER-9080
    2. Each GROUP has the following ELEMENTS:
        A, Bi, Pb, Sn, Sn, Cr, Ni, Ca, ...., Al
       So it would be like
        ER-1234: A, Bi, Pb, Sn, Sn, Cr, Ni, Ca, ...., Al
        ER-3245: A, Bi, Pb, Sn, Sn, Cr, Ni, Ca, ...., Al
        ER-4786: A, Bi, Pb, Sn, Sn, Cr, Ni, Ca, ...., Al
        ER-9080: A, Bi, Pb, Sn, Sn, Cr, Ni, Ca, ...., Al
     3. An each ELEMENT has DATA that I need to save, BUT! that I need to be able to get by specifying the group and the element.
        A:
             2,3   2,4    2, 8,   2,8 
             2,2   2,3    2, 7,   2,6
             2,1   2,6    2, 6,   2,7 
             2,5   2,4    2, 5,   2,3
    How can I save the ELEMENT "A" Data with the label of the GROUP and the ELEMENT so that I can recongnize it when I need to get the DATA again?
    Thanks for the help!
    Best regards,
    Amaloa.

  • How to save the data in form before submit to sap backend

    Hi experts,
                 i have to create one form . In this form i have to save the data and that form should sent to another person  to submit it in to sap back end. is there any possiblities to create form like this...
    Please any one help me...

    Hi Himanshu
    I already searched but no use... can you recollect once and help me..
    Regards
    Sharada

  • How to save the data in Planning query in Analyser?

    HI all,
    I am new in Integrated Planning I have made a planning query and I am inputting data in the query, right clicking to excel sheet and saving it saved data into cube but if I want a save button specific to query not specific to workbook how can I make it as generic, as when I run the query in analyser the button should be displayed in the Planning query on clicking it the data gets saved to cube.
    Abhijit.

    Hi Abhi,
    Hope this will be helpful to you.
    http://help.sap.com/saphelp_nw70/helpdata/en/43/a033e0f56e21b5e10000000a1553f6/frameset.htm
    Thanking You,
    Sappie

  • How to save the data in a Subvi

    Dear people,
    I am currently making a program which is calling with a Call by Reference Node. after that, I read out data (in this case an array of clusters) and I am writing new data to the cluster of the subvi.
    My problem is that the new data isn't stored in the subVI. If I close my Caller VI and i take a look in the SubVI all the 'new' data is erased and it seems to me that the program returned to its Default Values...
    How can I make a program so that the new data is stored in the subVI after I called it. I tried already with a invoke Node and then as method: Make all current Values Default. Actually, the SubVI is in the wrong state to execute that node...So I don't know how to go...
    Message Edited by btwesseling on 09-21-2006 07:37 AM

    Yes, I can explain,
    I am making a test program which is testing a device. There are around 400 different tests, and it is important that all the tests go in a sequential order.
    Before I actually run a test I need to give up some parameters. The parameters are been given in a mainprogram.
    so, if I load my main program, it is scanning which tests are available.  From each test I would like to see the paramters in my main-program. I am doing this by putting it into a cluster, which is been read-out by my main program. 
    I also would like to change the paramters, and then save the paramters back into the SubVI. For Example, In my main prgram I can set if a test is enabled or disabled.
    After setting the paramters the subvi closes. At the begin of testing, I scan all the tests outputs using a 'Call by Reference' node and I look if they are enabled or not. If yes, I make up an array of paths and after that all the tests which are in that array are been called and executed. the results aretransferred back to the main program, stored, and finally written in a TSV file (Tab Separated Value file.)
    the reason for a dynamically load is that in the case of someone wants to add a new test, it is dificult to change the mainprogram. In other words, the program which I am writing is for people who don't know much about labview, so I want to make it as user-friendly as possible. I am planning to make a kind of an wizard that helps the engineers to add tests.
    the second reason is that there are different devices which needs to be tested.  If I load all my tests in one time, that means that for each different device I have to load all the tests. that means that I have to load over 5000 tests in one time, which is not so nice.
    iI hope it is more clear now, but If you have more questions please let me know!

  • How to save the data from AI Read.vi?

    Hi,
    The main target is that testing the strength of a object which is extended by a force. The desired results are
    1. The strength of object under the force(main target, I am trying now);
    2. Displacement of object being extended(I have mimicly done);
    3. Images of deformation of the object extended(I have mimicly done).
    4. The sub procedure will stop when the object under testing is broken. I intend to use the big pulse from force sensor by analizing the data acquired.( it is more difficult if using machine vision).
    What I am mainly trying to do now is implementation of a sub vi to collect the data which is acquired from channel 0 of PCI-6052E which is connected to a force sensor. I have tried to use an existing exam
    ple as attached with some modifications. I have tested the data from the sensor by comparing to measurement by multimeter and it takes sense. But
    1. I still don't know how to save data displayed by AI Read.vi? And use what kind data type could save more memory?
    2. I think that memory management is very important because each points of the result includes its strength, image and displacement. How can I acquire enough significant points for the final results being reliable and save these data down to an array or cluster synchronously? (each sub procedure has no time limited)
    3.Because I think that a continuous data acquisition would occupy ALL CPU TIME and their related images and displacements would have no chance to be taken down by CPU at the same moment. Am I right?--I am sure that it is not very difficult problem but my mind is still in caose and the time is quite limited to me now.
    I am looking for your sugguestion or solution or control philosophy too. You can modify the fi
    le attached if you can. I will learn from your idea.
    Thank you very much for your time and energy!
    Your
    Swedlin
    Attachments:
    Acquire_N_Scans_1_10.vi ‏75 KB

    Hello;
    Regarding your question on the data type that would use less storage space, the answer is binary type. Actually, you can use another shipping example as start point of your application. The example I'm mentioning is a data logger, that saves binary data to a file on your hard drive. You can find that example at Search Examples->I/O Interfaces->Data Acquisition->Data Logger->High Speed Data Logger.
    Regarding your question about the CPU time, the statement is valid. In case you use a synchronous AI task, the CPU execution will get stuck inside the AI Read.vi untill the buffer is ready to be read. One thing you can do about that is to change the acquisition task to be asynchronous. There is a good example in Labview showing how you can accomplish that.
    You can find the example at Search Examples->I/O Interfaces->Data Acquisition->Analog Input->DAQ Occurrences.
    You can combine both examples to accomplish the task you need.
    Hope this helps.
    Filipe A.
    Applications Engineer
    National Instruments

  • How to save the data for multiple sittings

    Hello All
    i have one sign up form. user enter only 4 to 5 fields & he may not fill the the manditory field & he left. but data base don’t give the error to him. but next day he will come at then he want to complet his sign up i.e. when he commit the all detail that time all validation will hapen.
    for that i use one table without constrain to store the temarory detail.& use other table (with constrains) for final submition.
    1) i creat the view n entity for temparory table
    2) & also i create views n entity for Final table
    n i create one methos in AmImple file in that file I create one method & expose to client n I drag n drop this method as a ADF Button & in that method I write the following logic
    1) taking the data from one view (from temporary table) & setting the value to other view(Final table).
    using this i set the value from tempary to final table...
    but when user left the manditory field then it allow to submit the data in temparory field but when i copy that data to final table(with constrain) n user submit the data then validation happn i.e. "this fild is mandatory".when i click this error message it goes to first screen.
    I try to implement this functionality…but its not working.
    can u plz suggest other way to implement this functionality in ADF using jdevloper11g
    Thanks in Advance

    User,
    I don't get it :-(
    How do you find out if a user comes back or is completely new? You have to have some information about the user to remember him. At least this information has to be mandatory (even for the temporary table).
    Let's assume you have figured out that the user has been on your page before:
    load his credentials from the temporary table to the form, let him fill in the rest and if he hit save save it in the final table.
    Timo

  • How to save the date in Sqlite in Adobe Air application

    hi friends,
    i am doing a flex Adobe AIR Application with SQLITE Data base,in that i want to save Date in the following format DD/MM/YYYY, but in my TABLE i gave the data type is DATE,
    So it store the value like this Sun Dec 2 00:00:00 GMT+0530 2012.i want to store the value in DD/MM/YYYY.How to do that?
    looking for useful suggession.
    Cheers,
    B.venkatesan.

    Hi, maybe cannot help much on this since I have not much experiense on handling SQLITE in AIR.
    But I know there are a command/example for reading SQL:
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/data/SQLConnectio n.html
    http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118666ade46-7d49.html
    And in mxml you should have an id for each individual TextInput component, also have a button:
    <Button click="updateSQLHandler(event)"/>
    When the button is click the handler function is launched.
    The updateSQLHandler(event:MouseEvent) is a script that read the each individual TextInput component by getting (id of textinput component).text.
    Then, you create a String varible that is an SQL commands with the texts in the form, and update the SQL database following the below using the execute() command (refer to http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118666ade46-7d49.html ).
    Hope this help.

  • How to save the data from alv output

    My ALV output is editable one.I want that user can edit the output and  save the output details into database.How to do it?
    Moderator Message: Basic Question. This site is not an alternative for your Consultancy work. Put some effort of your own before turning to the forums for help. This is your LAST warning. One more violation will lead to Account deletion.
    Edited by: kishan P on Dec 6, 2010 6:45 PM

    Hi
    U need to implement an user_command and manage the functionality SAVE: when the user press SAVE you'll store the data into db.
    There are several programs demo in SAP and many solution in SCN forum: try to search it
    Max
    Moderator message: please think twice before replying. By now you should know which type of questions will be locked, so no point in replying, in a double sense.
    Edited by: Thomas Zloch on Dec 6, 2010 2:49 PM

  • How to save the data present in the description box?

    HI friends,
                   I have got a requirement where i am having one description box (custom_container) in one screen and the line length is 250. Code is like this...
    DATA: CUSTOM_CONTAINER TYPE REF TO     CL_GUI_CUSTOM_CONTAINER,
    EDITOR TYPE REF TO CL_GUI_TEXTEDIT,
    REPID LIKE SY-REPID.
    CONSTANTS: LINE_LENGTH TYPE I VALUE 250.
    MODULE STATUS_101 OUTPUT........
    My description box is working fine.....
    here i want to store the data entered in the description box(text box) when i press SAVE.
    Can any one provide me the solution.

    Hi,
    Since you are using the class CL_GUI_TEXTEDIT, you can call its' method GET_TEXT_AS_R3TABLE to save the text in internal table.
    If you wan ease the work of creating Z-Table to store them, you may use FM 'SAVE_TEXT':
    SAPscript: Save text
    The function module writes a text module to the text file or text memory, depending on the specific text object.
    The module can be used to change existing texts and to create new texts. If it is clear that it is a new text, this can be specified via the parameter INSERT. The result is better performance as a test read is not performed.
    Parameters
    CLIENT
    HEADER
    INSERT
    SAVEMODE_DIRECT
    OWNER_SPECIFIED
    LOCAL_CAT
    FUNCTION
    NEWHEADER
    LINES
    Exceptions
    ID
    LANGUAGE
    NAME
    OBJECT
    Function Group
    STXD
    Hope this helps you.
    Thanks,
    Anfernee

  • How to handle the Date & Time Object?

    Hi,
    I have big problem.I am working on j2ee application(using jsp & servlets).I am using Jboss App Server. The server is placed in India.
    But there is two offices, one is in India ,another one is in USA.
    But i want to handle the date and timestamp object commonly,
    But this object should be able to calculate their own date & timestamp object( e.g.,India,USA ).How can i solve this issue?.
    Help appreciated!
    P.Saravanan

    Hi,
    I have big problem.I am working on j2ee application(using jsp & servlets).I am using Jboss App Server. The server is placed in India.
    But there is two offices, one is in India ,another one is in USA.
    But i want to handle the date and timestamp object commonly,
    But this object should be able to calculate their own date & timestamp object( e.g.,India,USA ).How can i solve this issue?.
    Help appreciated!
    P.Saravanan

Maybe you are looking for

  • Use ODI to Extract Data from Hyperion Planning & Budgeting report to Excel

    Hello Can someone tell me please how to Extract Data from (Financial Reporting in) Hyperion Planning & Budgeting into Excel Using ODI? Would the steps be the same as Creating an ODI Project and Interface: Exporting a Flat File to a Flat File? If not,

  • Mouse clicking, clicking, clicking, and...

    I've got a 17" PowerBook G4. It's a little bit sick but it works. I have a hard time using the track pad, though, because of lack of precision. And I've always used a wired Apple Mouse. Occasionally when I open the computer and plug in the mouse, the

  • Add web service proxy generator

    Hi, when I try to add a web service the proxy generator dropdown menu shows the text "Edit proxy generator list".  When I click on it it displays several proxy generators including .net vb, the one I want.  When I click done it returnes to the previo

  • Output String Handling in Java

    Hi, guys............... How can I format my output I have a long text formula which consist of alot of "()","{ }" "[ ]" and some other special char. I want to see in a readable format. This output formula is approximately you can say 1 or 2 pages but

  • I need to reset my security questions so i can make purchases. Please help

    How do i reset my security questions?