Do I have to use lock when I am reading data from a table

Hi,
When i am reading data from a table , do I have to set a lock on that table .
Is it necessary for us to set the lock on a table when I am reading data from the table.
When I am updating the table , do I have to set a lock on the table ?
If yes, then what sort of lock-read lock,write lock or shared lock?
Regards,
Sushanth H.S.

check it out,
Lock objects are use in SAP to avoid the inconsistancy at the time of data is being insert/change into database.
SAP Provide three type of Lock objects.
- Read Lock(Shared Locked)
protects read access to an object. The read lock allows other transactions read access but not write access to
the locked area of the table
- Write Lock(exclusive lock)
protects write access to an object. The write lock allows other transactions neither read nor write access to
the locked area of the table.
- Enhanced write lock (exclusive lock without cumulating)
works like a write lock except that the enhanced write lock also protects from further accesses from the
same transaction.
You can create a lock on a object of SAP thorugh transaction SE11 and enter any meaningful name start with EZ Example EZTEST_LOCK.
Use: you can see in almost all transaction when you are open an object in Change mode SAP could not allow to any other user to open the same object in change mode.
Example: in HR when we are enter a personal number in master data maintainance screen SAP can't allow to any other user to use same personal number for changes.
Technicaly:
When you create a lock object System automatically creat two function module.
1. ENQUEUE_<Lockobject name>. to insert the object in a queue.
2. DEQUEUE_<Lockobject name>. To remove the object is being queued through above FM.
You have to use these function module in your program.
check this link for example.
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
tables:vbak.
call function 'ENQUEUE_EZLOCK3'
exporting
mode_vbak = 'E'
mandt = sy-mandt
vbeln = vbak-vbeln
X_VBELN = ' '
_SCOPE = '2'
_WAIT = ' '
_COLLECT = ' '
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3
if sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
Normally ABAPers will create the Lock objects, because we know when to lock and how to lock and where to lock the Object then after completing our updations we unlock the Objects in the Tables
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
purpose: If multiple user try to access a database object, inconsistency may occer. To avoid that inconsistency and to let multiple user give the accessibility of the database objects the locking mechanism is used.
Steps: first we create a loc object in se11 . Suppose for a table mara. It will create two functional module.:
1. enque_lockobject
1. deque_lockobject
before updating any table first we lock the table by calling enque_lockobject fm and then after updating we release the lock by deque_lockobject.
Select the radio button "Lock object"..
Give the name starts with EZ or EY..
Example: EYTEST
Press Create button..
Give the short description..
Example: Lock object for table ZTABLE..
In the tables tab..Give the table name..
Example: ZTABLE
Save and generate..
Your lock object is now created..You can see the LOCK MODULES..
In the menu ..GOTO -> LOCK MODULES..There you can see the ENQUEUE and DEQUEUE function
Reward if helpful

Similar Messages

  • Read data from ODS table using value mapping

    hi all;
    can anyone help on how to read data from ODS table using value mapping

    Mudit,
    Take a look at this blog,
    <a href="/people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler">DB Lookup in Mapping</a>
    Regards,
    Bhavesh

  • Using a substitution variable to pull data from a table

    Hello,
    I am working with a simple program that asks the user to enter any info that will relate to a table in the db.
    Thus far I have read 1,000 ways to accomplish this, and none of them work.
    PROMPT
    ACCEPT var PROMPT 'Enter var'
    DECLARE
    BEGIN
    SELECT &var
    FROM &table
    WHERE var=tablevar;
    END;

    Thanks for the feedback. Though I understand your logic, it doesn't seem to properly apply here. This is a more detailed explanation of what I've done.
    First, I create the table
    CREATE TABLE starbright
    (planet_num VARCHAR2(3),
    planet VARCHAR2(20));
    INSERT INTO starbright VALUES
    (257, 'Neptune');
    INSERT INTO starbright VALUES
    (367, 'Venus');
    INSERT INTO starbright VALUES
    (586, 'Mars');
    INSERT INTO starbright VALUES
    (725, 'Earth');Now, with that table created, I want to be able to periodically use PL/SQL to call data from the table, such as below
    DECLARE
    p_no := '&planet_num';
    BEGIN
    INSERT p_no
    INTO starbright;
    SELECT planet_num
    INTO p_no
    FROM starbright
    WHERE planet_num := p_no;
    dbms_output.put_line( 'Result: ' || planet );
    END;This is my generic error
    Error report:
    ORA-06550: line 2, column 6:
    PLS-00103: Encountered the symbol "=" when expecting one of the following:
       constant exception <an identifier>
       <a double-quoted delimited-identifier> table LONG_ double ref
       char time timestamp interval date binary national character
       nchar
    The symbol "<an identifier>" was substituted for "=" to continue.
    ORA-06550: line 6, column 8:
    PLS-00103: Encountered the symbol "P_NO" when expecting one of the following:
       into <a SQL statement>
    ORA-06550: line 11, column 18:
    PLS-00103: Encountered the symbol "=" when expecting one of the following:
       . ( * @ % & = - + ; < / > at for in is mod remainder not rem
       <an exponent (**)> <> or != or ~= >= <= <> and or like LIKE2_
       LIKE4_ LIKEC_ between group h
    06550. 00000 -  "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:

  • Reading data from a table which can have millions of record

    Hi,
    I need to write a query in my report that can be able to fetch records from a z table that have arount 20 lac (= 2 million) records. As far i knoew we can not handle such a huge amount of data in our internal tables. because the size of internal table is fixed and that can be increased only by basis persons.
    So can anybody tell me the approach that i should follow such that i can split the data from this table.
    Or any other approach is also welcome.
    Please reply ASAP when you have the time.
    Thanks And Regards,
    Mayank
    Edited by: Thomas Zloch on Mar 6, 2010 9:25 PM

    Hi Mayank,
    reduce the data selected to the fields you really need, avoid select *. See online help on SELECT, addition PACKAGE SIZE.
    select field1 field2 field3
      into corresponding fields of table lt_table package size nnn WHERE ...
    * process  lt_table
    endselect.
    Regards,
    Clemens
    Edited by: Rob Burbank on Mar 9, 2010 12:29 PM

  • Using a caculated field to get data from another table.

    I have a Products Table that I need to add a  field to. This field gains data from a Supplier table by using the supplier code to find the correct supplier type. All Products have a Supplier Code. So for example in SQL this would be a simple where statement looking something like this.
    SELET Supplier.Type
    From Supplier , Product
    Where Supplier.Code = Product.SupplierCode
    And ProductID = someID
    How would you write this as a caculated field in MDM?

    Hi Chauncey
    My previous post seems to have disappeared into the ether, so here it is again.
    If you only want to do this linking for display purposes, then consider the following possibility:
    The main Products table has a field which looks up to the flat table Suppliers. The flat table Suppliers has a field that either A) looks up to a flat SupplierTypes table or B) is a normal field in which the supplier type is stored. Inside the flat Suppliers table, just set both the SupplierCode and SupplierType fields to be display fields. MDM will automatically display both pieces of data inside the single field in the Products table.
    If you need the SupplierType in a separate field then you cannot do this with an expression (calculation or assignment.) You'll need to write a piece of code using one of the MDM APIs in order to do this lookup.
    HTH,
    Mark

  • Can I use "SerialDemo" or "BlackBox" to read data from hardware device?

    Hi All,
    I want read data comm port which is been connected with hardware device(weight reader).Can I use "SerialDemo" or "BlackBox" sample programs provided with javax.comm package?
    If yes do I need to do any modification in program as per my hardware device?
    Please help
    Thanks in advance to all
    Basavaraj

    You'll need to know what data is being sent from the device, and the example code SHOULD NOT be used.
    It is only to show you HOW to do it.
    Following the example code, build an application that reads from that port. Read the information from the manufacturer's website to get the details about the format of the data sent.

  • Reading Data from a Table using loop

    I have a dynamic table inside the PDF form. I want to loop through the table rows and read the cell contents. I successfully get the rows count in the table. But can't read the values from the cells. I have put editable TextField (txtName) control in each cell and trying to read its value.
    screenshot is below.
    Code I am using is:
    form1.Page1.Subform1.btnReadTable::click - (JavaScript, client)
    var rowCount = MyTable._Row1.count;
    app.alert("Row Count: " + rowCount);
    var i = 0;
    for(i=0 ; i<rowCount ; i++)
        //app.alert(MyTable.Row1[i].txtName.rawValue); // NOT WORKING
        app.alert(MyTable.Row1.txtName.rawValue); // WORKING, But just giving the value for the first row.
    Please tell me how can I get the value of each name in every row by looping.
    Thanks in advance.
    Abhinav

    Hi, Abhinav,
    You need to resolve the node for the particular instance of i. The syntax is:
    xfa.resolveNode("MyTable.Row1[" + i  + "].txtName").rawValue;
    There is an example here that will show the loop in action:
    http://www.assuredynamics.com/index.php/category/portfolio/two-way-binding-in-tables/
    Hope that helps,
    Niall
    Assure Dynamics

  • Using SSIS Script task to populate data from one table to another

    I have two tables Table A and Table B. Need to insert data into Table B from Table A. First, I truncate Table B and then insert. Few columns in Table A and Table are similar. However, I need to join with
    other tables Table C, Table D etc with Table B in order to populate the columns in Table B. Could someone please provide the code snippet to achieve this.

    Appreciate your quick response Prasad. Below is the code I'm using to achieve.
    Public Sub Main()
            Dim connEOCDB As SqlClient.SqlConnection = GetDBProdConnection(Me)
            Dim trans As SqlClient.SqlTransaction = connEOCDB.BeginTransaction()
            Try
                Dim TableA As New DataTable
                Dim TableB As New DataTable
                Dim DataadapterTableA As New SqlClient.SqlDataAdapter()
                DataadapterTableA.SelectCommand = New SqlClient.SqlCommand("select * from TableA", connEOCDB, trans)
                DataadapterTableA.Fill(TableA)
                Dim DataAdapterTableB As New SqlClient.SqlDataAdapter()
                DataAdapterTableB.DeleteCommand = New SqlClient.SqlCommand("Truncate table dbo.TableB", connEOCDB, trans)
                DataAdapterEmpExtdT.InsertCommand = New SqlClient.SqlCommand("insert into dbo.TableB (Col1,Col2,Col3,.....) values (@Col1,@Col2,@Col3...)", connEOCDB, trans)
    Could you please let me know how I can assign values to @Col1, @Col2 etc from
    DataadapterTableA.Fill(TableA). Also, as mentioned earlier, I need to use joins to populate @Col3 etc as well.
    Please advise.

  • Hi experts, how to use open sql to read data from one " maintenance view"?

    i want to use this part of data within report ,so how to use open sql statement to read data from one " maintenance view"?

    Hi
    You can't use OPEN SQl statements to fetch data from maintenance view
    You have to use only Database views
    see the different types of views and the difference
    The followings are different types of views:
    - Database View (SE11)
    Database views are implement an inner join, that is, only records of the primary table (selected via the join operation) for which the corresponding records of the secondary tables also exist are fetched. Inconsistencies between primary and secondary table could, therefore, lead to a reduced selection set.
    In database views, the join conditions can be formulated using equality relationships between any base fields. In the other types of view, they must be taken from existing foreign keys. That is, tables can only be collected in a maintenance or help view if they are linked to one another via foreign keys.
    - Help View ( SE54)
    Help views are used to output additional information when the online help system is called.
    When the F4 button is pressed for a screen field, a check is first made on whether a matchcode is defined for this field. If this is not the case, the help view is displayed in which the check table of the field is the primary table. Thus, for each table no more than one help view can be created, that is, a table can only be primary table in at most one help view.
    - Projection View
    Projection views are used to suppress or mask certain fields in a table (projection), thus minimizing the number of interfaces. This means that only the data that is actually required is exchanged when the database is accessed.
    A projection view can draw upon only one table. Selection conditions cannot be specified for projection views.
    - Maintenance View ( SE54 )
    Maintenance views enable a business-oriented approach to looking at data, while at the same time, making it possible to maintain the data involved. Data from several tables can be summarized in a maintenance view and maintained collectively via this view. That is, the data is entered via the view and then distributed to the underlying tables by the system.
    Please have a look at below link. It will help you.
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ed06446011d189700000e8322d00/frameset.htm
    for more detailed info look on:
    http://www.sap-img.com/abap/what-is-the-different-types-and-usage-of-views.htm
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/abap+dictionary&
    Reward points for useful Answers
    Regards
    Anji

  • Loading data from one table to another using cursor

    Hi,
    I have given the below command to load the data from 1 table to another using cursor.
    declare
    cursor mycursor IS
    SELECT extract_name,from_date,to_date,BETA from temp_table where EXTRACT_NAME='GIFTCARD_DETAILS';
    Begin
    for mycursor_1 IN mycursor loop
    insert into tmp_tab columns(col1,col2,col3,col5) values(mycursor_1.EXTRACT_NAME,mycursor_1.from_date,mycursor_1.to_date,mycursor_1.BETA);
    End loop;
    commit;
    end;
    It is working fine.
    But I want to hard code some of the columns ( like flags ) which are not there in 1st table and load them into 2nd table.
    In db2 we will give commands like
    varSqlStatus=`db2 "declare mycurs cursor for select extract_name,from_date,to_date,BETA,'N','Y' from temp_table"`
    varSqlStatus=`db2 "load from mycurs of cursor modified by identityignore insert into tmp_tab(col1,col2,col3,col5,col6,col7) nonrecoverable"`
    But I want it in oracle 10g, Can any one help me in this.

    Have you tried either of the two options :
    1. Modify the CURSOR itself :
    cursor mycursor IS
    SELECT extract_name,from_date,to_date,BETA,'N','Y' from temp_table where EXTRACT_NAME='GIFTCARD_DETAILS';2. Modify the INSERT statement itself :
    insert into tmp_tab columns(col1,col2,col3,col5,col6,col7) values(mycursor_1.EXTRACT_NAME,mycursor_1.from_date,mycursor_1.to_date,mycursor_1.BETA,'N','Y');

  • Using FDM to load data from oracle table (Integration Import Script)

    Hi,
    I am using Integration Import Script to load data from oracle table to worktables in FDM.
    i am getting following error while running the script.
    Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done
    Attaching the full error report
    ERROR:
    Code............................................. -2147217887
    Description...................................... Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
    At line: 22
    Procedure........................................ clsImpProcessMgr.fLoadAndProcessFile
    Component........................................ upsWObjectsDM
    Version.......................................... 1112
    Thread........................................... 6260
    IDENTIFICATION:
    User............................................. ******
    Computer Name.................................... *******
    App Name......................................... FDMAPP
    Client App....................................... WebClient
    CONNECTION:
    Provider......................................... ORAOLEDB.ORACLE
    Data Server......................................
    Database Name.................................... DBNAME
    Trusted Connect.................................. False
    Connect Status.. Connection Open
    GLOBALS:
    Location......................................... SCRTEST
    Location ID...................................... 750
    Location Seg..................................... 4
    Category......................................... FDM ACTUAL
    Category ID...................................... 13
    Period........................................... Jun - 2011
    Period ID........................................ 6/30/2011
    POV Local........................................ True
    Language......................................... 1033
    User Level....................................... 1
    All Partitions................................... True
    Is Auditor....................................... False
    I am using the following script
    Function ImpScrTest(strLoc, lngCatKey, dblPerKey, strWorkTableName)
    'Oracle Hyperion FDM Integration Import Script:
    'Created By:     Dhananjay
    'Date Created:     1/17/2012 10:29:53 AM
    'Purpose:A test script to import data from Oracle EBS tables
    Dim cnSS 'ADODB.Connection
    Dim strSQL 'SQL string
    Dim rs 'Recordset
    Dim rsAppend 'tTB table append rs object
    'Initialize objects
    Set cnSS = CreateObject("ADODB.Connection")
    Set rs = CreateObject("ADODB.Recordset")
    Set rsAppend = DW.DataAccess.farsTable(strWorkTableName)
    'Connect to SQL Server database
    cnss.open "Provider=OraOLEDB.Oracle.1;Data Source= +server+;Initial Catalog= +catalog+;User ID= +uid+;Password= +pass+"
    'Create query string
    strSQL = "Select AMOUNT,DESCRIPTION,ACCOUNT,ENTITY FROM +catalog+.TEST_TMP"
    'Get data
    rs.Open strSQL, cnSS
    'Check for data
    If rs.bof And rs.eof Then
    RES.PlngActionType = 2
    RES.PstrActionValue = "No Records to load!"
    Exit Function
    End If
    'Loop through records and append to tTB table in location’s DB
    If Not rs.bof And Not rs.eof Then
    Do While Not rs.eof
    rsAppend.AddNew
    rsAppend.Fields("PartitionKey") = RES.PlngLocKey
    rsAppend.Fields("CatKey") = RES.PlngCatKey
    rsAppend.Fields("PeriodKey") = RES.PdtePerKey
    rsAppend.Fields("DataView") = "YTD"
    rsAppend.Fields("CalcAcctType") = 9
    rsAppend.Fields("Amount") = rs.fields("Amount").Value
    rsAppend.Fields("Desc1") = rs.fields("Description").Value
    rsAppend.Fields("Account") = rs.fields("Account").Value
    rsAppend.Fields("Entity") = rs.fields("Entity").Value
    rsAppend.Update
    rs.movenext
    Loop
    End If
    'Records loaded
    RES.PlngActionType = 6
    RES.PstrActionValue = "Import successful!"
    'Assign Return value
    SQLIntegration = True
    End Function
    Please help me on this
    Thanks,
    Dhananjay
    Edited by: DBS on Feb 9, 2012 10:21 PM

    Hi,
    I found the problem.It was because of the connection string.The format was different for oracle tables.
    PFB the format
    *cnss.open"Provider=OraOLEDB.Oracle.1;Data Source= servername:port/SID;Database= DB;User Id=aaaa;Password=aaaa;"*
    And thanks *SH* for quick response.
    So closing the thread......
    Thanks,
    Dhananjay

  • I have downloaded pages 5 and installed and have been using it. when i turned my computer on today and tried to open a document, it was not there! How do i find pages 5?

    i have downloaded pages 5 and installed and have been using it. when i turned my computer on today and tried to open a document, it was not there! How do i find pages 5?

    Are you sure you are in the same User account as you installed Pages 5?
    Peter

  • Hi all, my ipad mute hardware button just stopped functioning, I have to use lock rotation to enjoy some apps..what do I do?

    Hi all, my ipad mute hardware button just stopped functioning, I have to use lock rotation to enjoy some apps..what do I do?

    Your statement doesn't make sense to me.... But it could just be me not understanding what you mean. Let me explain how the side switch and the control center work for screen rotation lock and system sounds.
    System sounds can be muted and controlled two different ways. The screen lock rotation can be controlled in the same manner as well.
    Settings>General>Use Side Switch to: Mute System sounds. If this option is selected, the switch on the side of the iPad above the volume rocker will mute system sounds.
    If you choose Lock Screen Rotation, then the switch locks the screen. If the screen is locked, you will see a lock icon in the upper right corner next to the battery indicator gauge.
    If you have the side switch set to lock screen rotation then the system sound control is in the control center. Swipe up from the bottom of the screen to get to control center . Tap on the bell icon and system sounds will return.
    If you have the side switch set to mute system sounds, then the screen lock can be accessed in the same manner as described above.
    This support article from Apple explains how the side switch works.
    http://support.apple.com/kb/HT4085

  • Multiple select queries used in Excel BI report ,fetching data from Sharepoint DB(SP2010_Prod_ProjectServer) causing blockage on DB ,when more than one workbook(same copy of Excel BI Report) refreshed using Refresh All option.

    I am using mutiple select queries to fetch data from Project Server 2010 DB(its sharepoint DB) and these queries fetch data in Excel BI report by establishing connection with DB using instance name and all. I have enhance all these select queries and data
    is being fetched in secs. but when more than one copy of same Excel BI report is refreshed using 'Refresh All' option, then these select queries cause blockage on DB.
    Please let me know mitigation for this blockage issue.
    Should I use begin transaction and commit transaction statements/ shared lock statements.
    please reply

    Hi,
    run same query at the same time?

  • I used the Migration Assistant to move data from my Time Machine to my new Mac.   Most data has been moved successfully but none of my iPhoto pictures have been moved.   Looking at my Time Machine now I find that the earliest back-up is dated after the Mi

    I used the Migration Assistant to move data from my Time Machine to my new Mac.   Most data seems to have been transferred successfully but none of my iPhoto pictures have been transferred.
    My Time Machine now shows the earliest available Back-up to be after the Migration Date.   My iPhoto pictures seem to have either been lost in the migration process or are locked in my Time Machine prior to the earliest back-up date now accessible.  
    Any advice on recovering my old iPhoto pictures would be greatly appreciated.

    First go to iPhoto Preferences, look in both General and Advanced tabs to make sure that things are set to import from camera into iPhoto.
    Then if that doesn't help, connect the camera and open Image Capture in your Applications > Utilities folder and see if you can use Image Capture to reset the import path from the camera to iPhoto.
    Image Capture: Free import tool on Mac OS X - Macgasm
    Message was edited by: den.thed
    Sorry John, I didn't see your post when I clicked the reply button. Dennis

Maybe you are looking for