ORA-13773: insufficient privileges to select data from the cursor cache

We are trying to create STS using the below query:
exec sys.dbms_sqltune.create_sqlset(sqlset_name => 'TEST_STS', -
sqlset_owner => 'SCOTT');
The below procedure will load sql starting with 'select /*MY_CRITICAL_SQL*/%' from cursor cache into STS TEST_STS.
DECLARE
stscur dbms_sqltune.sqlset_cursor;
BEGIN
OPEN stscur FOR
SELECT VALUE(P)
FROM TABLE(dbms_sqltune.select_cursor_cache(
'sql_text like ''select /*MY_CRITICAL_SQL*/%''',
null, null, null, null, null, null, 'ALL')) P;
dbms_sqltune.load_sqlset(sqlset_name => 'TEST_STS',
populate_cursor => stscur,
sqlset_owner => 'SCOTT');
END;
We were getting the following error: ORA-13761: invalid filter
After granting the below privileges to the user we are getting the below error:
Err msg:
ERROR at line 1:
ORA-13773: insufficient privileges to select data from the cursor cache
ORA-06512: at "SYS.DBMS_SQLTUNE", line 2957
ORA-06512: at line 10
For SQL Tuning Sets:
GRANT ADMINISTER ANY SQL TUNING SET TO scott;
For Managing SQL Profiles:
GRANT CREATE ANY SQL PROFILE TO scott;
GRANT ALTER ANY SQL PROFILE TO scott;
GRANT DROP ANY SQL PROFILE TO scott;
For SQL Tuning Advisor:
GRANT ADVISOR TO scott;
Others:
GRANT SELECT ON V_$SQL TO SCOTT;
GRANT SELECT ON V_$SQLAREA TO SCOTT;
GRANT SELECT ON V$SQLAREA_PLAN_HASH TO SCOTT;
GRANT SELECT ON V_$SQLSTATS TO SCOTT;
grant select on sys.DBA_HIST_BASELINE to SCOTT;
grant select on sys.DBA_HIST_SQLTEXT to SCOTT;
grant select on sys.DBA_HIST_SQLSTAT to SCOTT;
grant select on sys.DBA_HIST_SQLBIND to SCOTT;
grant select on sys.DBA_HIST_OPTIMIZER_ENV to SCOTT;
grant select on sys.DBA_HIST_SNAPSHOT to SCOTT;
Any info from your end to resolve the issue will be of great help.
Thanks

What is the alert log reporting. Are you seeing any other errors than these in the alert log too?

Similar Messages

  • Error reading data from static cursor cache.

    Hi,
    Does anyone know what causes this error below. It just started happening out of the blue. I'm running Apache Tomcat 4.1 on Win 2000 server with MS SQL Server 2000 database.
    Error:
    java.sql.SQLException: [Microsoft][SQLServer JDBC Driver]Error reading data from static cursor cache.
    Thanks,
    TR

    hi,
    i had a similar sort of error, something along the lines of "error setting up static cursor cache" using the SQL JDBC drivers on Win2K. i deleted the file entries in the TEMP folder of c:\documents and settings\<user>\Local Settings\TEMP and everything was cool after it. i'm not sure what the exact issue is (probably something like maximum folder size had been reached). i ran the FileMon utility from www.sysinternals.com and it reported a DISK_FULL error on a temporary file being read by the process. to cut a long story short, everything is NOW cool.
    cheer,
    dara

  • ORA-01031: Insufficient privileges error in upgrading from 9.2.0.5 to 10.2

    Hi, I am using DBUA to upgrade oracle 9i database to 10g. In step 1 of 7 when I select 9i datagase to upgrade I get ORA-01031: Insufficient privileges error. However, I can connect to the database from 9i as well as 10g using SQLPlus. Any idea what could be going wrong? Thanks. Manish
    Edited by: user635081 on Jul 22, 2009 10:38 AM

    Check your REMOTE_LOGIN_PASSWORDFILE . If it is set to NONE, then make sure that SQLNET.AUTHENTICATION_SERVICES = (NTS) in your sqlnet.ora file.
    the OS user should be in ORA_DBA group.
    Try connecting as SYS,
    SQL> sqlplus /nolog
    SQL> connect / as sysdba
    HTH
    Anantha

  • How to restrict user to select date from the calendar into a text item

    Hi All,
    I am using oracle 10g.IN a form i am having a block 'client_block' in that i am having a text_item ' entry_date' which is a datebase item and i have set enabled false in property palette and i created an image item on the same form and i have an calendar icon on it .In when_image_pressed trigger for image item i have written this code
    SET_ITEM_PROPERTY('CLIENT_BLOCK.ENTRY_DATE',ENABLED,PROPERTY_TRUE);
    DATE_LOV.Get_Date(sysdate,'CLIENT_BLOCK.ENTRY_DATE');
    This is working perfectly but user can enter or delete date into the text_item through keyboard i want to restrict that they can only select date from calendar.
    I have tried setting item property enabled false in triggers but it is not working.
    Can someone help me what trigger i have to use and how?.
    Thanks
    Sri

    Hi,
    This is working perfectly but user can enter or delete date into the text_item >>>through keyboard i want to restrict that they can only select date from calendarSet Insert allowed to 'NO' in property pallete of item ENTRY_DATE.
    In ON-ERROR Trigger::
    BEGIN
    DECLARE
    err_code CONSTANT NUMBER := error_code;
    err_type CONSTANT VARCHAR2(3) := error_type;
    BEGIN
    IF (err_type = 'FRM'
    AND err_code IN (40200)) THEN
    Message('Updates Not allowed, Please Select Your Date from Calendar');
    Message(' ');
    ELSE
    NULL;
    END IF;
    END;
    END;
    Thanks,
    Bhujendra

  • Project select data from the serial port

    Hi everyone,
    The project is about use labview to receive data from a serial
    port wirelessly. The serial port will receive two values (X1 and X2) every 10
    minutes. I want to use those two values as two inputs for my formula. How to
    make selection? Many thanks.
    Baicy
    Solved!
    Go to Solution.
    Attachments:
    port read.png ‏23 KB

    Scan From String.
    Using the first option, and putting some numbers in for the zeroes so it shows some kind of meaningful result.
    Attachments:
    Example_VI.png ‏12 KB

  • ORA-01031: insufficient privileges problem

    Hi all,
    I am trying to create the below procedure in the BOLMIN schema which in turn selects data from the tables of VALMIN schema. and I get ORA-01031: insufficient privileges error.
    CREATE OR REPLACE PROCEDURE BOLMIN.prcs_load_data
    IS
    BEGIN
    FOR c
    IN (SELECT DISTINCT AL4.GOAL_TEXT,
    AL5.RESPONSE_TEXT,
    AL7.SAMPLE_ID,
    AL7.ACADEMY_NAME,
    AL8.NAME
    FROM VALMIN.USER_PROFILE AL3,
    VALMIN.STUDENT_GOALS AL4,
    VALMIN.STUDENT_QUESTION_DETAILS AL5,
    VALMIN.STUDENT_QUESTION_RESPONSE AL6,
    VALMIN.SAMPLE AL7,
    VALMIN.NAME AL8
    WHERE ( AL3.GOAL_ID = AL4.GOAL_ID(+)
    AND AL3.USER_ID = AL6.USER_ID(+)
    AND AL6.QUESTION_TYPE_SUB_ID = AL5.QUESTION_TYPE_SUB_ID(+)
    AND AL7.NAME_ID = AL8.NAME_ID(+)))
    LOOP
    NULL;
    END LOOP;
    END;
    I checked the grants of each of the VALMIN schema tables involved in the associated sql query & they all have SELECT grant (to BOLMIN schema). Also, the SQL query itself, when executed in BOLMIN schema runs perfectly fine. The problem is occurring only when I enclose the query in a procedure. Isn't that weird? or am I missing something here? Any help regarding this issue is appreciated. Thanks.
    The BOLMIN schema as CREATE PROCEDURE privilege as I have already created other procedures for other purposes.
    Thanks,
    Sirisha
    Edited by: siri_me on Oct 2, 2010 9:23 AM

    siri_me wrote:
    All Roles are disabled in PL/SQL and explicit privileges are needed right from creating procedures to the accessing the underlying tables.WRONG. Roles are disabled in definer rights stored objects - stored procedures, functions, packages triggers. Stored procedures, functions, packages with authid current user and anonymous PL/SQL block honor roles.
    SY.

  • ORA-01039:Insufficient Privileges on the Underlying Objects of the View

    Hi,
    I have a Query where it is using (SELECT name from v$DATABASE as a Inline View).
    But when my running the Explain Plan in Toad it is giving the Error as
    'ORA-01039:Insufficient Privileges on the Underlying Objects of the View'
    Any help will be appreciable
    Thanks and Regards

    you need SELECT ANY DICTIONARY privelage Below is a small demonstration.
    First iam connecting as a SYSDBA and doing an explain plan on v$database.
    SQL*Plus: Release 9.2.0.1.0 - Production on Mon Sep 1 12:36:53 2008
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Enter user-name: akivadba/akivadba@akivatst as sysdba
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> set linesize 250
    SQL>
    SQL> explain plan for select * from v$database
      2  /
    Explained.
    SQL> select * from table(dbms_xplan.display)
      2  /
    PLAN_TABLE_OUTPUT
    Plan hash value: 735420252
    | Id  | Operation            | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT     |          |   100 | 77200 |     0   (0)| 00:00:01 |
    |   1 |  MERGE JOIN CARTESIAN|          |   100 | 77200 |     0   (0)| 00:00:01 |
    |*  2 |   FIXED TABLE FULL   | X$KCCDI  |     1 |   710 |     0   (0)| 00:00:01 |
    |   3 |   BUFFER SORT        |          |   100 |  6200 |     0   (0)| 00:00:01 |
    |   4 |    FIXED TABLE FULL  | X$KCCDI2 |   100 |  6200 |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter("DI"."INST_ID"=USERENV('INSTANCE'))
    16 rows selected.No problem till now every thing is fine. Now iam connecting as a normal user and doing the same.
    SQL> connect
    Enter user-name: sysadm/sysadm@akivatst
    Connected.
    SQL>
    SQL> explain plan for select * from v$database
      2  /
    explain plan for select * from v$database
    ERROR at line 1:
    ORA-01039: insufficient privileges on underlying objects of the viewLook i got the insufficient privileges error. Now let me grant the required privileges.
    SQL> connect
    Enter user-name: akivadba/akivadba@akivatst as sysdba
    Connected.
    SQL> GRANT SELECT ANY DICTIONARY TO SYSADM
      2  /
    Grant succeeded.Now connect back to the user and try again.
    SQL> connect
    Enter user-name: sysadm/sysadm@akivatst
    Connected.
    SQL> explain plan for select * from v$database
      2  /
    Explained.
    SQL> select * from table(dbms_xplan.display)
      2  /
    PLAN_TABLE_OUTPUT
    Plan hash value: 735420252
    | Id  | Operation            | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT     |          |   100 | 77200 |     0   (0)| 00:00:01 |
    |   1 |  MERGE JOIN CARTESIAN|          |   100 | 77200 |     0   (0)| 00:00:01 |
    |*  2 |   FIXED TABLE FULL   | X$KCCDI  |     1 |   710 |     0   (0)| 00:00:01 |
    |   3 |   BUFFER SORT        |          |   100 |  6200 |     0   (0)| 00:00:01 |
    |   4 |    FIXED TABLE FULL  | X$KCCDI2 |   100 |  6200 |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter("DI"."INST_ID"=USERENV('INSTANCE'))
    16 rows selected.
    SQL>Thanks,
    Karthick.
    Edited by: karthick_arp on Sep 1, 2008 12:21 AM

  • Weird Error - sometime getting ORA-01031: insufficient privileges

    Problem - Java process throwing java.sql.SQLException: ORA-01031: insufficient privileges for simple select statement select * from MYTABLE , table having only three rows
    Observation - While investigating. I did same select from sql developer using same credential, I get same ORA-01031: insufficient privileges error in sql developer too BUT ONLY if I create new connection. (Disconnect and connect again), If I fire same query again in same connection it runs fine.
    SELECT * FROM MYTABLE;
    there is no problem if I run query in small case (notice only select and from in small case), even if it is fresh connection there is no error.
    select * from MYTABLE;
    I am out of any clue what is going on. Any help?
    Java stack track -
    Caused by: java.sql.SQLException: ORA-01031: insufficient privileges
            at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
            at oracle.jdbc.driver.T2CConnection.checkError(T2CConnection.java:676)
            at oracle.jdbc.driver.T2CConnection.checkError(T2CConnection.java:602)
            at oracle.jdbc.driver.T2CPreparedStatement.executeForDescribe(T2CPreparedStatement.java:571)
            at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1039)
            at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1134)
            at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3339)
            at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3384)
            at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
            at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:648)
            at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:591)
    Oracle SQL Developerer Error
    ORA-01031: insufficient privileges
    01031. 00000 -  "insufficient privileges"
    *Cause:    An attempt was made to change the current username or password
               without the appropriate privilege. This error also occurs if
               attempting to install a database without the necessary operating
               system privileges.
               When Trusted Oracle is configure in DBMS MAC, this error may occur
               if the user was granted the necessary privilege at a higher label
               than the current login.
    *Action:   Ask the database administrator to perform the operation or grant
               the required privileges.
               For Trusted Oracle users getting this error although granted the
               the appropriate privilege at a higher label, ask the database
               administrator to regrant the privilege at the appropriate label.

    Guys...
    I'm having the same problem.
    The platform is a Windows 2003 R2 64bit (SP2) with Oracle 11g.
    In the production server from the same client, the connection is usually ... however, to a server where I have the same instances retrieved from an RMAN backup, does not connect!
    In the Productoion Server:
    C:\>sqlplus sys@bmknfe as sysdba
    SQL*Plus: Release 10.2.0.1.0 - Production on Wed Aug 18 17:43:41 2010
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Enter password:
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL>
    In the Recovered Server:
    C:\>sqlplus sys@bmknfe_rt as sysdba
    SQL*Plus: Release 10.2.0.1.0 - Production on Wed Aug 18 17:42:39 2010
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Enter password:
    ERROR:
    ORA-01031: insufficient privileges
    I've tried recreating the password file, but is not resolving ...
    Can someone give me a light?

  • Getting ORA-01031: insufficient privileges if try to connect in sqlplus

    Hi,
    I've tried to connect to my db which stands at host (Solaris), but getting
    ORA-01031: insufficient privileges.
    The client I've used is sqlplus.
    SQL> conn sys@REP as sysdba
    ERROR:
    ORA-01031: insufficient privileges
    At the same time I can successfully connect to the same db from the same PC with the same connection string at PL/SQL Developer.
    How it can be possible?

    Guys...
    I'm having the same problem.
    The platform is a Windows 2003 R2 64bit (SP2) with Oracle 11g.
    In the production server from the same client, the connection is usually ... however, to a server where I have the same instances retrieved from an RMAN backup, does not connect!
    In the Productoion Server:
    C:\>sqlplus sys@bmknfe as sysdba
    SQL*Plus: Release 10.2.0.1.0 - Production on Wed Aug 18 17:43:41 2010
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Enter password:
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL>
    In the Recovered Server:
    C:\>sqlplus sys@bmknfe_rt as sysdba
    SQL*Plus: Release 10.2.0.1.0 - Production on Wed Aug 18 17:42:39 2010
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Enter password:
    ERROR:
    ORA-01031: insufficient privileges
    I've tried recreating the password file, but is not resolving ...
    Can someone give me a light?

  • ORA-01039: insufficient privileges... on EXPLAIN PLAN but OK when run

    I get
    ORA-01039: insufficient privileges on underlying objects of the viewwhen I use EXPLAIN PLAN but if I actually run the SQL it is fine!
    SQL> explain plan for select * from ifsinfo.gscdb_xref;
    explain plan for select * from ifsinfo.gscdb_xref
    ERROR at line 1:
    ORA-01039: insufficient privileges on underlying objects of the view
    SQL>select * from ifsinfo.gscdb_xref;
    GSCDB_COMPANY                  COMPANY                        VARCHAR2
    GSCDB_COMPANY                  NAME                           VARCHAR2
    GSCDB_COMPANY                  ADDRESS1                       VARCHAR2
    GSCDB_COMPANY                  ADDRESS2                       VARCHAR2
    GSCDB_COMPANY                  ZIP_CODE                       VARCHAR2
    GSCDB_COMPANY                  CITY                           VARCHAR2
    GSCDB_COMPANY                  COUNTY                         VARCHAR2
    GSCDB_COMPANY                  STATE                          VARCHAR2
    GSCDB_COMPANY                  COUNTRY_DB                     VARCHAR2
    GSCDB_COMPANY                  GSCDB_LAST_UPDATE              VARCHAR2
    GSCDB_CUSTOMER                 CUSTOMER_ID                    VARCHAR2
    GSCDB_CUSTOMER                 NAME                           VARCHAR2
    GSCDB_CUSTOMER                 ADDRESS_ID                     VARCHAR2
    :

    ...in which case (providing the SQLs in question are SELECT statements) you may be better off with DBMS_SQL.PARSE rather than explain plan.

  • Why Am I Getting ORA-01031: insufficient privileges To Add Trandata?

    I create a table C##TOM.CUSTOMERS in SQL Plus.
    I go to the ggsci command line and attempt to add trandata and get the following insufficient privileges response:
    GGSCI (TPFAEFFL-LAP) 11> add trandata C##TOM.CUSTOMERS
    ERROR: Error (1031, ORA-01031: insufficient privileges) start select in get_total_columns.
    I have already granted connect, dba, flashback, create session, alter session, select any dictionary, select any table, select any transaction, and select unlimited tablespace to the user.
    What privileges am I missing?
    TIA.

    Did you use the DBMS_GOLDENGATE_AUTH.GRANT_ADMIN_PRIVILEGE procedure to the DBLOGIN user?  
    This call grants all of the required privileges for ADD SCHEMATRANDATA and ADD TRANDATA - whether it is classic or integrated capture.  

  • Incorrect year conversion when selecting date from DatePicker

    Hi,
    I have a problem when I select date from the date picker calendar to the inputDate item.
    The date in input item and date picker calendar are displayed as Buddhist year (Gregorian year + 543) ex. year 2012 is 2555 Buddhist year.
    When I selected date from the date picker, the year put in the inputDate item is converted to Gregorian year (2012). It should be buddhist year (2555)
    Does anybody know where I can check how the year is converted?
    Thanks.
    nat...

    Hi Bijesh,
    I use version 11.1.2.2.0. Actually, I got the patch from Oracle support already but it is not working properly with my application. The behavior is like this...
    - First, I set the current date as a default date in the inputDate item and date is shown correctly -- 10/10/2555.
    - The calendar in datePicker is also displayed correctly with year 2555.
    - But when I selected the date from the datePicker, it put 10/10/2012 in the inputDate item.
    I am not sure where I can check how the year is converted back to Gregorian. Any clue?
    Thanks.
    nat...

  • Reading selected data in the table control

    Hi Friends,
    I have final data in my table control now the user wants to select only few records from the displayed data, for that I kept a check box for selection, But my question is I am unable to read the selected data.
    Actually user requirement is he has to update only the selected data from the displayed data in the table control.
    Can any one tell me how to read the selected records after displaying in the table control.
    Thanx in advance,
    Line

    Hi
    If your table control has a check box, your internal table should have a field for it. Its value will be X if the checkbox is setted else it'll be SPACE.
    So in the PAI u should read only the records where that flag is X:
    LOOP AT ITAB WHERE MARK = 'X'.
    ENDLOOP.
    Max

  • Selecting data in the table control

    Hi Friends,
    I have final data in my table control now the user wants to select only few records from the displayed data, for that I kept a check box for selection, But my question is I am unable to read the selected data.
    Actually user requirement is he has to update only the selected data from the displayed data in the table control.
    Can any one tell me how to read the selected records after displaying in the table control.
    Thanx in advance,
    Line

    Hello Line,
    As gopi has suggested do the following..
    for the table control properties u have an option called W/SelColumn.
    Give in some name (ROW_SEL)to that and also include a field CHK in the internal which is being passed to the table control.
    and in the PAI of the table control module wirte like this...
    Then in your code..
    PROCESS BEFORE OUTPUT.
    PBO FLOW LOGIC FOR TABLECONTROL 'TABCONTROL'
    MODULE TABCONTROL_CHANGE_TC_ATTR.
    MODULE TABCONTROL_CHANGE_COL_ATTR.
    LOOP AT lt_final
    INTO lw_final
    WITH CONTROL tabcontrol
    CURSOR tabcontrol-current_line.
    MODULE tabcontrol_get_lines.
    MODULE TABCONTROL_CHANGE_FIELD_ATTR
    ENDLOOP.
    MODULE status_0101.
    PROCESS AFTER INPUT.
    PAI FLOW LOGIC FOR TABLECONTROL 'TABCONTROL'
    LOOP AT lt_final.
    MODULE read_data.
    MODULE tabcontrol_user_command.
    ENDLOOP.
    MODULE TABCONTROL_CHANGE_TC_ATTR.
    MODULE TABCONTROL_CHANGE_COL_ATTR.
    MODULE user_command_0101.
    MODULE tabcontrol_user_command input.
    if lt_final-chek = 'X'.
    *put your logic here something like
    move corresponding lt_final to gt_final.
    *now you have selcted rows data in gt_final.
    endif.
    endmodule.
    Regards

  • Featching Data From The Data Base Using DI API in Matrix

    Hi
       All of u i am shahid i faced a problem when i retrive
       the selected data from the data base using matrix plz.
       Healp me!.
       Thanks
       Mohd Shahid.
       SAP Techinical Consultent
      Option Strict Off
    Option Explicit On
    Friend Class UseMatrix
        '// This parameter will use us to manipulate the
        '// SAP Business One Application
        Private WithEvents SBO_Application As SAPbouiCOM.Application
        Private oForm As SAPbouiCOM.Form
        Private oMatrix As SAPbouiCOM.Matrix
        Private oColumns As SAPbouiCOM.Columns
        Private oColumn As SAPbouiCOM.Column
        '// declareing a DB data source for all the Data binded columns
        Private oDBDataSource As SAPbouiCOM.DBDataSource
        '// declaring a User data source for the "Remarks" Column
        Private oUserDataSource As SAPbouiCOM.UserDataSource
        ' This Function is called automatically when an instance
        ' of the class is created.
        ' Indise this function
        Public Sub New()
            MyBase.New()
            '// set SBO_Application with an initialized application object
            SetApplication()
            '// Create the UI
            CreateFormWithMatrix()
            '// Add Data Sources to the Form
            AddDataSourceToForm()
            '// Bind the Form's items with the desired data source
            BindDataToForm()
            '// Load date to matrix
            GetDataFromDataSource()
            '// Make the form visible
            oForm.Visible = True
        End Sub
        Private Sub SetApplication()
            '// Use an SboGuiApi object to establish connection
            '// with the SAP Business One application and return an
            '// initialized appliction object
            Dim SboGuiApi As SAPbouiCOM.SboGuiApi
            Dim sConnectionString As String
            SboGuiApi = New SAPbouiCOM.SboGuiApi
            '// by following the steps specified above, the following
            '// statment should be suficient for either development or run mode
            sConnectionString = Environment.GetCommandLineArgs.GetValue(1)
            '// connect to a running SBO Application
            Try ' If there's no active application the connection will fail
                SboGuiApi.Connect(sConnectionString)
            Catch ' Connection failed
                System.Windows.Forms.MessageBox.Show("No SAP Business One Application was found")
                End
            End Try
            '// get an initialized application object
            SBO_Application = SboGuiApi.GetApplication()
            'SBO_Application.MessageBox("Hello World")
        End Sub
        Private Sub SBO_Application_AppEvent(ByVal EventType As SAPbouiCOM.BoAppEventTypes) Handles SBO_Application.AppEvent
            Select Case EventType
                Case SAPbouiCOM.BoAppEventTypes.aet_ShutDown
                    SBO_Application.MessageBox("A Shut Down Event has been caught" & _
                        Environment.NewLine() & "Terminating 'Add Menu Item' Add On...")
                    '// terminating the Add On
                    System.Windows.Forms.Application.Exit()
            End Select
        End Sub
        Private Sub CreateFormWithMatrix()
            '// Don't Forget:
            '// it is much more efficient to load a form from xml.
            '// use code only to create your form.
            '// once you have created it save it as XML.
            '// see "WorkingWithXML" sample project
            '// we will use the following object to add items to our form
            Dim oItem As SAPbouiCOM.Item
            '// we will use the following objects to set
            '// the specific values of every item
            '// we add.
            '// this is the best way to do so
            Dim oButton As SAPbouiCOM.Button
            Dim oStaticText As SAPbouiCOM.StaticText
            Dim oEditText As SAPbouiCOM.EditText
            '// The following object is needed to create our form
            Dim creationPackage
            creationPackage = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)
            creationPackage.UniqueID = "UidFrmMatrix14"
            creationPackage.FormType = "TypeFrmMatrix14"
            '// Add our form to the SBO application
            oForm = SBO_Application.Forms.AddEx(creationPackage)
            '// Set the form properties
            oForm.Title = "Quality Check"
            oForm.Left = 336
            oForm.ClientWidth = 620
            oForm.Top = 44
            oForm.ClientHeight = 200
            '// Adding Items to the form
            '// and setting their properties
            '// Adding an Ok button
            '// We get automatic event handling for
            '// the Ok and Cancel Buttons by setting
            '// their UIDs to 1 and 2 respectively
            oItem = oForm.Items.Add("1", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
            oItem.Left = 5
            oItem.Width = 65
            oItem.Top = 170
            oItem.Height = 19
            oButton = oItem.Specific
            oButton.Caption = "Ok"
            '// Adding a Cancel button
            oItem = oForm.Items.Add("2", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
            oItem.Left = 75
            oItem.Width = 65
            oItem.Top = 170
            oItem.Height = 19
            oButton = oItem.Specific
            oButton.Caption = "Cancel"
            '// Adding a Text Edit item
            'oItem = oForm.Items.Add("txtPhone", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            ' oItem.Left = 265
            'oItem.Width = 163
            'oItem.Top = 172
            'oItem.Height = 14
            '// Adding an Add Phone prefix column button
            ' oItem = oForm.Items.Add("BtnPhone", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
            ' oItem.Left = 160
            ' oItem.Width = 100
            ' oItem.Top = 170
            ' oItem.Height = 19
            ' oButton = oItem.Specific
            ' oButton.Caption = "Add Phone prefix"
            '// Add the matrix to the form
            AddMatrixToForm()
        End Sub
        Private Sub AddMatrixToForm()
            '// we will use the following object to add items to our form
            Dim oItem As SAPbouiCOM.Item
            '// we will use the following object to set a linked button
            Dim oLink As SAPbouiCOM.LinkedButton
            '// Adding a Matrix item
            oItem = oForm.Items.Add("Matrix1", SAPbouiCOM.BoFormItemTypes.it_MATRIX)
            oItem.Left = 5
            oItem.Width = 500
            oItem.Top = 5
            oItem.Height = 150
            oMatrix = oItem.Specific
            oColumns = oMatrix.Columns
            '// Adding Culomn items to the matrix
            oColumn = oColumns.Add("#", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "#"
            oColumn.Width = 30
            oColumn.Editable = False
            '// Add a column for Item Code
            oColumn = oColumns.Add("DSItemCode", SAPbouiCOM.BoFormItemTypes.it_LINKED_BUTTON)
            oColumn.TitleObject.Caption = "Item Code"
            oColumn.Width = 40
            oColumn.Editable = True
            '// Link the column to the ITEM master data system form
            oLink = oColumn.ExtendedObject
            oLink.LinkedObject = SAPbouiCOM.BoLinkedObject.lf_Items
            oColumn = oColumns.Add("DSItemName", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "Item Name"
            oColumn.Width = 80
            oColumn.Editable = True
            '// Add a column for BP Card Phone
            oColumn = oColumns.Add("DSWhs", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "Ware House"
            oColumn.Width = 40
            oColumn.Editable = True
            '// Add a column for BP Card Phone
            oColumn = oColumns.Add("DSQuantity", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "Quantity"
            oColumn.Width = 40
            oColumn.Editable = True
            '// Add a column for Combo Box
            oColumn = oColumns.Add("DSQuality", SAPbouiCOM.BoFormItemTypes.it_CHECK_BOX)
            oColumn.TitleObject.Caption = "Quality"
            ' oColumn.ValidValues.Add("OK", "")
            'oColumn.ValidValues.Add("NOT OK", "")
            oColumn.Width = 40
            oColumn.Editable = True
            oColumn = oColumns.Add("DSReport", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oColumn.TitleObject.Caption = "Remarks"
            ' oColumn.ValidValues.Add("OK", "")
            'oColumn.ValidValues.Add("NOT OK", "")
            oColumn.Width = 40
            oColumn.Editable = True
            '// Add a column for BP Card Phone
            ' oColumn = oColumns.Add("DSPhoneInt", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            ' oColumn.TitleObject.Caption = "Int. Phone"
            'oColumn.Width = 40
            'oColumn.Editable = True
        End Sub
        Public Sub AddDataSourceToForm()
            '// every item must be binded to a Data Source
            '// prior of binding the data we must add Data sources to the form
            '// Add user data sources to the "International Phone" column in the matrix
            ' oUserDataSource = oForm.DataSources.UserDataSources.Add("IntPhone", SAPbouiCOM.BoDataType.dt_SHORT_TEXT, 20)
            '// Add DB data sources for the DB bound columns in the matrix
            oDBDataSource = oForm.DataSources.DBDataSources.Add("OITW")
        End Sub
        Public Sub BindDataToForm()
            '// getting the matrix column by the UID
            oColumn = oColumns.Item("DSItemCode")
            'oColumn.DataBind.SetBound(True, "", "DSCardCode")
            oColumn.DataBind.SetBound(True, "OITW", "ItemCode")
            'oColumn = oColumns.Item("DSItemName")
            'oColumn.DataBind.SetBound(True, "OITW", "ItemName")
            oColumn = oColumns.Item("DSWhs")
            oColumn.DataBind.SetBound(True, "OITW", "WhsCode")
            oColumn = oColumns.Item("DSQuantity")
            oColumn.DataBind.SetBound(True, "OITW", "U_QCStock")
            '// to Data Bind an item with a user Data source
            '// the table name value should be an empty string
            ' oColumn = oColumns.Item("DSPhoneInt")
            'oColumn.DataBind.SetBound(True, "", "IntPhone")
        End Sub
        Public Sub GetDataFromDataSource()
            '// Ready Matrix to populate data
            oMatrix.Clear()
            oMatrix.AutoResizeColumns()
            '// Querying the DB Data source
            oDBDataSource.Query()
            '// setting the user data source data
            'oUserDataSource.Value = "Phone with prefix"
            oMatrix.LoadFromDataSource()
        End Sub
        Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent
            If (pVal.FormUid = "UidFrmMatrix") Then
                If ((pVal.itemUID = "BtnPhone") And _
                    (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) And _
                    (pVal.Before_Action = False)) Then
                    AddPrefix()
                End If
                If ((pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_UNLOAD) And _
                    (pVal.Before_Action = False)) Then
                    SBO_Application.MessageBox("Form Unloaded, Addon will terminate")
                    System.Windows.Forms.Application.Exit()
                End If
            End If
        End Sub
        Public Sub AddPrefix()
            Dim i As Integer
            Dim PhoneExtCol As SAPbouiCOM.Column
            Dim newPhone As String
            Dim oItem As SAPbouiCOM.Item
            Dim oEditTxt As SAPbouiCOM.EditText
            '// Get the prefix edit text item
            oItem = oForm.Items.Item("txtPhone")
            oEditTxt = oItem.Specific
            '// Flush user input into datasources
            oMatrix.FlushToDataSource()
            '// Get the DBdatasource we base the matrix on
            oDBDataSource = oForm.DataSources.DBDataSources.Item("OCRD")
            '// Iterate all the records and add a prefix to the phone
            For i = 0 To oDBDataSource.Size - 1
                newPhone = oDBDataSource.GetValue("phone1", i)
                newPhone = newPhone.Trim(" ")
                oDBDataSource.SetValue("phone1", i, oEditTxt.String + newPhone)
            Next
            '// Load data back to
            oMatrix.LoadFromDataSource()
        End Sub
    End Class

    Hi Shahid,
    I am not sure what your question is. The code you pasted looks like the MatrixAndDataSources example that comes with the SDK. What are you trying to do?
    Thanks,
    Adele

Maybe you are looking for