Stored procedure for creating tables

Is it possible to create a stored procedure which only contains create tables? I prepare everything on an environment and want to transfer everything, except the data, on anothe environment. Therfore I thought of an stored procedure which does everything automatically. Additional I want to create a package which contains all necessary stored procedures (which are already finished). Is it better to insert the create-table-lines in the package?
Thanks for your help!

PL/SQL is not the appropriate tool for this.
What does Oracle RDBMS products like Apex use to install? SQL*Plus scripts. A combination of SQL code and anonymous PL/SQL blocks.
This is also what we use to install any one of a dozen Oracle systems we have developed.. it is as simple as running 'sqlplus "/ as sysdba" @installer <tablespace> <schema> <password>'.
Trying to do this type of thing in PL/SQL... lots of disadvantages, lots of complexities, and very little (if any) benefit.

Similar Messages

  • Stored procedures for User Tables

    Can somebody please help me with this matter?. I need to add stored procedures for user tables. Is there any way  of doing so?.
    Thanks in advance.
    Ernesto.

    Ernesto,
    You have posted multiple threads for the same question.  Please check the other thread and close this one:
    Stored procedures in User Tables
    Thanks,
    Gordon

  • Stored Procedure to create table for PdO Change Log

    Hi Experts,
    I have read in the forums that the only way to get a Change Log was to create a Stored Prodedure and create a new Table that is populated with the Change when ever a User update a Production Order.
    I started on this Stored Procedure and have hit a wall on a error. I'm fairly new to queries...
    Here is what I have so far:
    if((@transaction_type = 'U')and(@object_type = '202'))
    BEGIN
    set @PdO = case @object_type
              INSERT INTO ChangeLogPdO2 (DocEntry, Status, ItemCode, PlannedQty, DueDate)
              SELECT T0.DocEntry, T0.Status, T0.ItemCode, T0.PlannedQty, T0.DueDate
              FROM OWOR T0      
              WHERE T0.DocEntry = @list_of_cols_val_tab_del
        END
    if(@PdO = 'true')
    begin
          select @error = 1
          select @error_message = N'My Error message'
    end
    I plan to add more columns, but only started with these. Also how do I put a time stamp on this?
    Thanks,
    Marli
    Edited by: Marli Schutte on Feb 3, 2010 7:09 PM

    Gordon,
    I created a new UDT named CLPdO.
    Then I did as you suggested and I get the error message 'Incorrect syntax near the keyword 'INSERT''.
    Here is how the Sotred Procedure now look:
    [code}
    if((@transaction_type = 'U')and(@object_type = '202'))
    BEGIN
    set @PdO = case @object_type
              INSERT INTO dbo@CLPdO (DocEntry, Status, ItemCode, PlannedQty, DueDate)
              SELECT T0.DocEntry, T0.Status, T0.ItemCode, T0.PlannedQty, T0.DueDate
              FROM OWOR T0      
              WHERE T0.DocEntry = @list_of_cols_val_tab_del
        END
    if(@PdO = 'true')
    begin
          select @error = 1
          select @error_message = N'My Error message'
    end
    Any help will be appreciated.
    Marli

  • Procedure for creating transparent table, data element and domain

    Hi,
    Can anybody let me know the procedure for creating transparent table, data element and domain.
    Thanks,
    Mahathi

    Hi
    Database table and its components
    A database table is the central data structure of the ABAP/4 data dictionary.
    The structure of the objects of application development are mapped in tables on the underlying relational database.
    The attributes of these objects correspond to fields of the table.
    A table consists of columns (fields) and rows (entries). It has a name and different attributes, such as delivery class and maintenance authorization.
    A field has a unique name and attributes; for example it can be a key field.
    A table has one or more key fields, called the primary key.
    The values of these key fields uniquely identify a table entry.
    You must specify a reference table for fields containing a currency (data type CURR) or quantity (data type QUAN). It must contain a field (reference field) with the format for currency keys (data type CUKY) or the format for units (data type UNIT). The field is only assigned to the reference field at program runtime.
    The basic objects for defining data in the ABAP Dictionary are tables, data elements and domains. The domain is used for the technical definition of a table field (for example field type and length) and the data element is used for the semantic definition (for example short description).
    A domain describes the value range of a field. It is defined by its data type and length. The value range can be limited by specifying fixed values.
    A data element describes the meaning of a domain in a certain business context. It contains primarily the field help (F1 documentation) and the field labels in the screen.
    A field is not an independent object. It is table-dependent and can only be maintained within a table.
    You can enter the data type and number of places directly for a field. No data element is required in this case. Instead the data type and number of places is defined by specifying a direct type.
    The data type attributes of a data element can also be defined by specifying a built-in type, where the data type and number of places is entered directly.
    <b>Two Level Domain Example</b>
    A domain defines a field technically and therefore it may
    be used at different business levels.
    A data element describes the meaning of a domain in a certain business context.
    A domain, however, is used for the technical definition of a table field (for example field type and length).
    Therefore, although a take-off airport (data element S_FROMAIRP) would have a different business meaning from an airport where a plane lands (data element S_TOAIRP), they could still have the same domain(here S_AIRPID) because technically we could assign the same number of characters whether the airport is a take-off or a landing airport.
    <b>Definitions of Table in Database</b>
    In SAP R/3 tables are defined as
    A) Transparent tables: All of the fields of a dictionary table correspond to a field in the real database table.
    B) Pooled tables: Different tables which are not linked to each other with a common key are combined into a TABLE POOL. Several logical tables thus exist as a single real database table.
    C) Cluster tables: Several tables linked by a common key may sometimes be combined by the data dictionary and made to exist on the database schema as a single table.
    SAP is evolving R/3 tables in transparent tables.
    <b>Elaboration on each of the definitions</b>
    A transparent table is automatically created on the database when it is activated in the ABAP Dictionary. At this time the database-independent description of the table in the ABAP Dictionary is translated into the language of the database system used.
    The database table has the same name as the table in the ABAP Dictionary. The fields also have the same name in both the database and the ABAP Dictionary. The data types in the ABAP Dictionary are converted to the corresponding data types of the database system.
    The order of the fields in the ABAP Dictionary can differ from the order of the fields on the database. This permits you to insert new fields without having to convert the table. When a new field is added, the adjustment is made by changing the database catalog (ALTER TABLE). The new field is added to the database table, whatever the position of the new field in the ABAP Dictionary.
    Tables can also reside on the database as Pooled tables or cluster tables
    Pooled Tables: Different tables which are not linked to each other with a common key can be combined into a Table Pool. The tables contained within this pool are called Pooled Tables. A table pool is stored in the database a simple table. The table's data sets contain, in separate fields, the actual key for the data set to be stored, the name of the pooled table and the contents of the data set to be stored.
    Using this schema, several logical tables are combined into a single real database table. Although the data structure of each set is lost during the write to the table pool, it is restored during the read by the ABAP/4 Data Dictionary. The ABAP/4 Data Dictionary utilizes its meta-data to accomplish this.
    Since information must be prepared (defined) within the ABAP/4 Data Dictionary when it is read or written to (or accessed), this process itself defines these as not transparent tables
    Cluster Tables: Occasionally, several tables may be linked by a common key. The ABAP/4 Data Dictionary can also combine these tables into a single table. Each data set of the real table within the database contains a key and in a single data field, several data sets of the subsequent table for this key.
    As mentioned above, these table types require special data handling, therefore they are not transparent tables.
    <b>Technical Settings in Dictionary</b>
    The data class logically defines the physical area of the database (for ORACLE the table space) in which your table should be created. If you choose the data class correctly, the table will automatically be created in the appropriate area on the database when it is activated in the ABAP Dictionary.
    The most important data classes are master data, transaction data, organizational data and system data.
    Master data is data that is rarely modified. An example of master data is the data of an address file, for example the name, address and telephone number.
    Transaction data is data that is frequently modified. An example is the material stock of a warehouse, which can change after each purchase order.
    Organizational data is data that is defined during customizing when the system is installed and that is rarely modified thereafter. The country keys are an example.
    System data is data that the R/3 System itself needs. The program sources are an example.
    Further data classes, called customer data classes (USER, USER1), are provided for customers. These should be used for customer developments. Special storage areas must be allocated in the database.
    The size category describes the expected storage requirements for the table on the database.
    An initial extent is reserved when a table is created on the database. The size of the initial extent is identical for all size categories. If the table needs more space for data at a later time, extents are added. These additional extents have a fixed size that is determined by the size category specified in the ABAP Dictionary.
    You can choose a size category from 0 to 4. A fixed extent size, which depends on the database system used, is assigned to each category.
    Correctly assigning a size category therefore ensures that you do not create a large number of small extents. It also prevents storage space from being wasted when creating extents that are too large.
    Modifications to the entries of a table can be recorded and stored using logging.
    To activate logging, the corresponding field must be selected in the technical settings. Logging, however, only will take place if the R/3 System was started with a profile containing parameter 'rec/client'. Only selecting the flag in the ABAP Dictionary is not sufficient to trigger logging.
    Parameter 'rec/client' can have the following settings:
    rec/client = ALL All clients should be logged.
    rec/client = 000[...] Only the specified clients should be logged.
    rec/client = OFF Logging is not enabled on this system.
    The data modifications are logged independently of the update. The logs can be displayed with the Transaction Table History (SCU3).
    Logging creates a 'bottleneck' in the system:
    Additional write access for each modification to tables being logged.
    This can result in lock situations although the users are accessing different application tables!
    <b>Create transparent table</b>
    Go to transaction SE11. Enter name of table you want to create (beginning with Y or Z) and click on create pushbutton
    Enter the delivery class and the table maintenance criteria
    The delivery class controls the transport of table data when installing or upgrading, in a client copy and when transporting between customer systems .
    The display/maintenance indicator specifies whether it is possible to display/maintain a table/view using the maintenance tools Data Browser (transaction SE16) and table view maintenance (transactions SM30 and SM31).
    Enter the name of the table field and the data element. The
    System automatically populates the technical details for
    existing data elements.
    So far as possible it is advisable to use existing data elements which befit the business requirements.
    However, we may create data elements if need be. The same is shown in the next slide.
    To create a data element simply double click on it.
    Alternately create a data element by simply choosing the
    data type radio button on SE11 initial screen.
    <b>Create data element</b>
    The system prompts you to create a new data element.
    Choose the Yes pushbutton.
    Under the data type tab enter the domain name which
    determines the technical characteristics of the field.
    Further characteristics tab: Allows you to specify a search help assigned to the data element.
    It also allows you to specify a parameter id which helps you populate a field from SAP memory.
    Field label: Can be assigned as prefixed text to a screen field referring to the ABAP Dictionary. The text is displayed on the screen in the logon language of the user (if the text was translated into this language).
    <b>Create domain</b>
    If the domain does not exist in the data dictionary the
    system prompts you to create one.
    Give the technical characteristics under the definition
    tab. Value range allows you value restriction at domain
    level.
    Value range tab:
    As explained in the section Consistency through input checks one can restrict the possible values for a field at domain level itself by either entering fixed values or by specifying a value table under the tab Value range.
    <b>Currency/Quantity fields in a table</b>
    A currency or a quantity field must be assigned a reference field from a reference table containing applicable qty unit or currency unit.
    Field of the reference table, containing the applicable quantity unit or currency
    A field containing currency amounts (data type CURR) must be assigned a reference field including the currency key (data type CUKY).
    A field containing quantity specifications (data type QUAN) must be assigned a reference field including the associated quantity unit (data type UNIT).
    <b>Create transparent table continue</b>
    Maintain the technical settings of the table by clicking on the tab

  • Stored Procedure that creates a trigger on new tables

    I am trying to create a stored procedure that creates a trigger on new tables whenever the table is created.  The procedure should receive the new project table's name, and then create a dml trigger on that procedure.  When the procedure
    is run, I get an error "Incorrect syntax near keyword 'TRIGGER.'"  This is how my Stored Procedure looks in SQL Management Studio.  Any suggestions?
    USE [RIDB_DynamicDesign]
    GO
    /****** Object: StoredProcedure [dbo].[sp_CreateTriggerMarkLatest] Script Date: 11/08/2014 16:43:20 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[sp_CreateTriggerMarkLatest] @ProjectTable nvarchar(128), @ItExists int OUTPUT
    AS
    DECLARE @SQL nvarchar(4000)
    DECLARE @MarkLatest nvarchar(30)
    DECLARE @LatTrue bit
    DECLARE @LatFalse bit
    SET @LatTrue = 'True'
    SET @LatFalse = 'False'
    SET @SQL = 'CREATE TRIGGER tr_MarkLatest ON ' + @ProjectTable + ' AFTER INSERT
    AS
    UPDATE ' + @ProjectTable + ' SET Latest = @LatFalse
    UPDATE ' + @ProjectTable + ' SET Latest = @LatTrue WHERE
    ID IN (SELECT ID FROM ' + @ProjectTable + ' p WHERE
    NOT EXISTS (SELECT 1 FROM ' + @ProjectTable + ' WHERE
    Name = p.Name AND Vers = p.Vers
    AND Date > p.Date))'
    EXEC sp_executesql @SQL, N'@ProjectTable nvarchar(128), @LatTrue bit, @LatFalse bit',
    @ProjectTable, @LatTrue, @LatFalse
    Gina

    First you have to debug the dynamic SQL string with a PRINT statement. I see some problems:
    CREATE PROCEDURE [dbo].[uspCreateTriggerMarkLatest] @ProjectTable nvarchar(128), @ItExists int OUTPUT
    AS BEGIN
    DECLARE @SQL nvarchar(4000)
    DECLARE @MarkLatest nvarchar(30)
    DECLARE @LatTrue bit
    DECLARE @LatFalse bit
    SET @LatTrue = 'True'
    SET @LatFalse = 'False'
    SET @SQL = 'CREATE TRIGGER tr_MarkLatest ON ' + @ProjectTable + ' AFTER INSERT
    AS
    UPDATE ' + @ProjectTable + ' SET Latest = @LatFalse
    UPDATE ' + @ProjectTable + ' SET Latest = @LatTrue WHERE
    ID IN (SELECT ID FROM ' + @ProjectTable + ' p WHERE
    NOT EXISTS (SELECT 1 FROM ' + @ProjectTable + ' WHERE
    Name = p.Name AND Vers = p.Vers
    AND Date > p.Date))'
    PRINT @SQL;
    -- EXEC sp_executesql @SQL, N'@ProjectTable nvarchar(128), @LatTrue bit, @LatFalse bit', @ProjectTable, @LatTrue, @LatFalse
    END
    GO
    DECLARE @ItExists int, @ProjectTable nvarchar(128) = N'TestTrigger';
    EXEC [dbo].[uspCreateTriggerMarkLatest] @ProjectTable, @ItExists OUTPUT
    CREATE TRIGGER tr_MarkLatest ON TestTrigger AFTER INSERT
    AS
    UPDATE TestTrigger SET Latest = @LatFalse
    UPDATE TestTrigger SET Latest = @LatTrue WHERE
    ID IN (SELECT ID FROM TestTrigger p WHERE
    NOT EXISTS (SELECT 1 FROM TestTrigger WHERE
    Name = p.Name AND Vers = p.Vers
    AND Date > p.Date))
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • Stored Procedure for Accounts Receivable

    Hi. First off, apologies in advance if I have put this question into the wrong topic. Secondly, I first saw SAP 3 weeks ago when I stared my new job and have had no training so please bear with me if some of what I ask doesn't make much sense.
    OK, the issue is this.  In SAP B1, there is a built in Report called "Customer Receivables Aging" which allows you to see Customer Receivable Accounts by age (e.g 0-30, 31-60, 61-90, 90+) and so on.  The problem with the built in report is that it doesn't show all the fields I want - it only shows the Customer Name, balance, and then the aging balances.  I want to be able to see things like the customer's contact details, etc. I know this makes no sense because the whole point of the report is to be able to drill down into the different rows, but this report needs to be issued in printed form, hence the need for the extra fields.
    Since I can't seen any way from within SAP to change the fields returned by this report, I thought I'd have a stab at writing my own SQL to select out the same data along with the extra fields I wanted.  That's when the problems began...try as I might, I cannot get my figures to tally with the SAP Report.
    They are almost correct, but not quite. I am sure that I am missing a selection or some other element of the logic that B1 uses to create the built in report.
    If you want, I can post the SQL I'm using....I'm not an SQL guru by any means, but I do know my way around it; the biggest problem I have is that I cannot find any documentation as to the 4 letter tables that SAP uses and their relationships except on the most basic level (e.g ORIN is Open Return Invoice [maybe])
    Then I thought maybe it might be possible to edit that report section in B1 using the SDK.  That would be a better solution as I would not have to 'reinvent the wheel', I can just SELECT an extra field or three to include in the report.
    So my question is
    ->Does anyone have a stored procedure for SQL Server that can replicate correctly the SAP B1 "Customer Receivable Aging", even just the process SAP uses to gather this data would be good.
    OR
    is it possible to edit this report in SAP to put in the extra fields I want.
    Or, am I totally barking up the wrong tree? Thanks in advance, I know this is a long post.

    Hi Stephen,
    There should be a print layout attached to the on-screen report. This can be altered to show the additional fields you want without resorting to SDK or SQL development.
    When you have the Customer Receivables Ageing report open on screen, choose Tools-Print Layout Designer or click on the Print Layout Designer icon on the toolbar. When prompted, choose the layout you wish to edit and you'll be taken to the layout design. In the layout, you can add additional fields and should be able to add most business partner fields. As the report is set to portrait by default, I recommend changing it to landscape so you have lots more space to add the extra fields you want. This report writer is fairly intuitive, if a little basic.
    You will need to save this new report design, set it to be the default layout and then when you select to print the Customer Receivables Ageing report (ie Print Preview or Print) you will see the new report.
    Hope this helps,
    Owen

  • Stored procedure for arhive

    I created a stored procedure for send data from a source bd to the bd destination with a link between BD
    But it will not work
    CREATE OR REPLACE PROCEDURE archivage ( source IN VARCHAR2, destination IN VARCHAR2)
    BEGIN
    / * - Prepare a cursor to select from the bd_source: * /
    source_cursor: = dbms_sql.open_cursor;
    DBMS_SQL.PARSE (source_cursor,
    'SELECT table_name FROM dba_tables' | | source,DBMS_SQL.NATIVE);
    LOOP i in source_cursor
    /* Or i use this !!!!
    SELECT object_name FROM dba_objects WHERE owner = 'SCOTT' AND object_type = 'TABLE'*/
    DBMS_SQL.DEFINE_COLUMN (source_cursor, i);
    end loop
    ignorer: DBMS_SQL.EXECUTE = (source_cursor);
    / * - Prepare a cursor to insert into the destination db: * /
    destination_cursor: = DBMS_SQL.OPEN_CURSOR;
    DBMS_SQL.PARSE (destination_cursor,
    'INSERT INTO' | | destination | | DBMS_SQL.NATIVE);
    / * - Fetch a row from the source table and insert it into the destination table: * /
    loop
    if DBMS_SQL.FETCH_ROWS (source_cursor)> 0 ALORS
    - Obtenir des valeurs de colonne de la ligne
    DBMS_SQL.COLUMN_VALUE (source_cursor,i);
    DBMS_SQL.BIND_VARIABLE (destination_cursor,i);
    ignorer: DBMS_SQL.EXECUTE = (destination_cursor);
    ELSE
    EXIT;
    End If;
    END LOOP;
    /*-Close cursor */
    COMMIT;
    DBMS_SQL.CLOSE_CURSOR (source_cursor);
    DBMS_SQL.CLOSE_CURSOR (destination_cursor);
    EXCEPTION
    WHEN OTHERS, THEN
    if
    DBMS_SQL.IS_OPEN (source_cursor)then
    DBMS_SQL.CLOSE_CURSOR (source_cursor);
    End If;
    if DBMS_SQL.IS_OPEN (destination_cursor) then
    DBMS_SQL.CLOSE_CURSOR (destination_cursor);
    End If;
    RAISE;
    END;

    find 10 differences ... :(
    CREATE OR REPLACE PROCEDURE archivage (source        IN VARCHAR2,
                                           destination   IN VARCHAR2)
    IS
       source_cursor        INTEGER;
       destination_cursor   INTEGER;
       ignorer              INTEGER;
    BEGIN
       /* - Prepare a cursor to select from the bd_source: */
       source_cursor := DBMS_SQL.open_cursor;
       DBMS_SQL.
        PARSE (source_cursor,
               'SELECT table_name FROM dba_tables' || source,
               DBMS_SQL.NATIVE);
       FOR i IN source_cursor
       LOOP
          /* Or i use this !!!!
          SELECT object_name FROM dba_objects WHERE owner = 'SCOTT' AND object_type = 'TABLE'*/
          DBMS_SQL.DEFINE_COLUMN (source_cursor, i);
       END LOOP;
       ignorer := DBMS_SQL.EXECUTE (source_cursor);
       /* - Prepare a cursor to insert into the destination db: */
       destination_cursor := DBMS_SQL.OPEN_CURSOR;
       DBMS_SQL.
        PARSE (destination_cursor,
               'INSERT INTO ' || destination,
               DBMS_SQL.NATIVE);
       /* - Fetch a row from the source table and insert it into the destination table: */
       LOOP
          IF DBMS_SQL.FETCH_ROWS (source_cursor) > 0
          THEN
             --ALORS
             -- Obtenir des valeurs de colonne de la ligne
             DBMS_SQL.COLUMN_VALUE (source_cursor, i);
             DBMS_SQL.BIND_VARIABLE (destination_cursor, i);
             ignorer := DBMS_SQL.EXECUTE (destination_cursor);
          ELSE
             EXIT;
          END IF;
       END LOOP;
       /*-Close cursor */
       COMMIT;
       DBMS_SQL.CLOSE_CURSOR (source_cursor);
       DBMS_SQL.CLOSE_CURSOR (destination_cursor);
    EXCEPTION
       WHEN OTHERS
       THEN
          IF DBMS_SQL.IS_OPEN (source_cursor)
          THEN
             DBMS_SQL.CLOSE_CURSOR (source_cursor);
          END IF;
          IF DBMS_SQL.IS_OPEN (destination_cursor)
          THEN
             DBMS_SQL.CLOSE_CURSOR (destination_cursor);
          END IF;
          RAISE;
    END;
    /

  • Stored procedure for disabling all foreign key constraints ?

    hi all,
    I need a stored procedure for disabling / enable all constraints in that database schema.
    Create or replace procedure enable_disable_proc(status varchar2(3),schema_name varchar2(20))
    ---> where 'status' parameter condition should be ( YES for enable) (NO for disable)
    ---> 'schema_name' is a parameter where ,only this schema should be affected with this procedure..
    Thanks in Advance..

    Hi,
    Try this code
    /* Formatted on 2009/07/16 08:15 (Formatter Plus v4.8.8) */
    CREATE PROCEDURE enab_disab_proc (
       enforce          IN   VARCHAR2,
       current_schema   IN   VARCHAR2
    IS
       v_alter_table_sql   VARCHAR2 (2000);
    BEGIN
       FOR rec_con IN (SELECT table_name, constraint_name
                         FROM user_constraints
                        WHERE owner = current_schema)
       LOOP
          IF (enforce = 'NO')
          THEN
             v_alter_table_sql :=
                   ' alter table '
                || current_schema
                || '.'
                || rec_con.table_name
                || ' disable constraint '
                || rec_con.constraint_name;
          ELSE
             v_alter_table_sql :=
                   ' alter table '
                || current_schema
                || '.'
                || rec_con.table_name
                || ' enable constraint '
                || rec_con.constraint_name;
          END IF;
          EXECUTE IMMEDIATE v_alter_table_sql;
       END LOOP;
    END;Edited by: Salim Chelabi on 2009-07-16 05:15

  • Stored procedure accessing system table

    I am using a stored procedure to access tables in other schemas. I pass the schema and table name as parameters to the stored procedure. I use these two variables to create a cursor of column names from all_tab_columns table. When I access all_tab_columns from SQL Plus, the right result is returned. When the procedure executes the same select statement in the same schema and using the same search criteria, the table I am looking for can not be found.
    Example:
    select count(column_name) from all_tab_columns where owner = 'MYADM' and table_name = 'MYTABLE';
    This will return the correct number of columns when executed in SQL Plus.
    cursor mycursor is
    select count(column_name) from all_tab_columns where owner = p_owner and table_name = p_table;
    This cursor, when used in my stored procedure, finds nothing when p_owner is set to MYADM and p_table is set to MYTABLE.
    I've tried granting all permissions to the calling schema with no positive results. I am aware that the calling schema is not required to have the necessary privileges when a procedure accesses data in other schemas. So I don't understand what the problem is. I greatly appreciate anyone's help.
    Cyrus

    Hi,
    try this, probaly this'll give you the desired output :
    Procedure Column_cnt
    ( p_owner IN varchar2,
    p_table IN varchar2 ) IS
    cursor c1 is
    select count(column_name) col_cnt from all_tab_columns where owner = upper(p_owner)
    and table_name = upper(p_table);
    BEGIN
    for i in c1 loop
    dbms_output.put_line(i.col_cnt);
    end loop;
    END;
    Now from SQLPLUS type :
    exec column_cnt('OWNER','TABLE_NAME')
    Note: parameters are in Varchar2, so they should be within quotes.
    But do you really want a cursor to store a single row, single column value, cursors are for fetching multiple rows/columns that means for a result set.
    if you want to get only count(column_name) then you could re-write the procedure like this way :
    Procedure Column_cnt
    ( p_owner IN varchar2,
    p_table IN varchar2 ) IS
    col_cnt number;
    BEGIN
    select count(column_name) into col_cnt from all_tab_columns where owner = upper(p_owner)and table_name = upper(p_table);
    dbms_output.put_line(i.col_cnt);
    END;
    Thanks
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by cyrus eslami ([email protected]):
    I am compiling and invoking the procedure in a schema that has the correct privileges granted to it.
    -Cyrus<HR></BLOCKQUOTE>
    null

  • Stored Procedure uses Temp Tables

    C#, asp.net app.
    I have a stored procudure that outputs data to temp tables. The data in these tables is only there for the life of that connection. The stored procedure does NOT return data.
    Options I see so far:
    1) If I open a connection and execute the stored procudure, how can I get crystal to use the SAME connection object?
    2) Can I get crystal to call the stored procedure for me first (but remember, it doesn't use the sp as the actual data source). Would I still be able to supply parameters to the SP?
    3) I guess I could do everything myself, even load all the data out of the temp tables into local datasets. And then supply the datasets to the tables. I tried this and I called SetDataSource on all my tables but then it looks like it still tried to go to the server again as I got a login screen.

    Hello Happy,
    No, Crystal does not have any access to those temp tables. They are locked by the owner who made the call and we have no API available in .NET that you can ride on to get access. Unless you can figure out a way at runtime to give full permission to the temp table then CR can use it. You just need to set the datasource to the temp table name at runtime. You will need to create the table so a report can be designed off it first but once done as long as the structure doesn't change the report will continue to work.
    Other options are as you have tried using data sets. Another option is to export that data into a database so CR has access to it rather than using temp tables. Once the report is done you can use MS API's to delete all rows of data.
    Thank you
    Don

  • Stored Procedure For Web Service in Visual Composer 7.1

    Hello,
    I want to use stored procedure for Webservice in Visual Composer 7.1
    I can find this Web service but not supported. ( ex) prcreleased_test - Not supported )
    Log.
    Message: Error in connection - Can' t execute Web service.
    Date: 2008-07-01
    Time: 16:41:43:906
    Category: com.sap.tc.webdynpro.progmodel.generation.DelegatingComponent
    Location: com.sap.tc.webdynpro.progmodel.generation.DelegatingComponent.processExecution: 
    Application: sap.com/test~kmshim_wf_impl
    Thread: HTTP Worker [1]
    Data Source: j2ee\cluster\server0\log\defaultTrace_00.trc
    Correlator ID: 240496500000034715
    Argument Objects: 
    Arguments: 
    DSR Component: n.a.
    DSR Transaction: cb4b3560473711dd9fb4001e4f3b8fcb
    Log2
    Message: Stopped further execution since the interpreter is unusable
    Date: 2008-07-01
    Time: 16:41:43:906
    Category: com.sap.tc.webdynpro.progmodel.generation.DelegatingComponent
    Location: com.sap.tc.webdynpro.progmodel.generation.DelegatingComponent.XGLInterpreter
    Application: sap.com/test~kmshim_wf_impl
    Thread: HTTP Worker [1]
    Data Source: j2ee\cluster\server0\log\defaultTrace_00.trc
    Correlator ID: 240496500000034715
    Argument Objects: 
    Arguments: 
    DSR Component: n.a.
    DSR Transaction: cb4b3560473711dd9fb4001e4f3b8fcb '
    Help me^^ plz..

    Hi Tanna.
    Thanks for your reply^^
    I create webservice that access my stored procedure.
    But not supported.
    http://dmp.humaxdigital.com/HumaxCmdwService/Service1.asmx?wsdl
    There are two service. (Hello World - Test, prcrelease_test - Stored Procedure )
    'Hello World' is supported but prcrelease_test is not supported. I can't drag to storyboard.
    Our company's DB is MSSQL2005.
    please help me^^

  • Stored Procedure for Crystal Reports

    Hi All,
    I developed this test stored procedure to see wheather we could a stored procedure for crystal reports. It compiled without any problem, but when I run it, it gives me error message. Here is the stored Procedure..
    CREATE OR REPLACE PROCEDURE WOLD1SIM.TEST_PROCEDURE(
    TEST_CURSOR IN OUT TEST_PACKAGE.TEST_TYPE,
    TEST_PARAMETER IN TEST_TABLE.ID%TYPE)
    AS
    BEGIN
    OPEN TEST_CURSOR FOR
    SELECT *
    FROM TEST_TABLE
    WHERE TEST_TABLE.ID = TEST_PARAMETER;
    END TEST_PROCEDURE;
    And
    This is the error message..
    ERROR at line 2:
    ORA-06550: line 2, column 1:
    PLS-00201: identifier 'TEST_PROC' must be declared
    ORA-06550: line 2, column 1:
    PL/SQL: Statement ignored
    I have created the package sucessfully.
    I was wondering If any one of you can advice me where I am making the mistake.
    Thank you

    CREATE OR REPLACE PROCEDURE WOLD1SIM.TEST_PROCEDURE(TEST_CURSOR IN OUT TEST_PACKAGE.TEST_TYPE,
                                                         TEST_PARAMETER IN TEST_TABLE.ID%TYPE)
    ...you have 2 parameters in your procedure WOLD1SIM.TEST_PROCEDURE(). you should also use two parameters when you execute the procedure.

  • Stored Procedure for restrict to close documents

    Hi,
    I want to create a Stored Procedure for restrict to close sales orders for some users, because in Standard Authorizations you have one option to restrict to close, but I need that some users can close quotations and also this users can´t close sales orders. I have this query :
    F @object_type='17' AND (@transaction_type='a' or @transaction_type='U' )
    BEGIN
    IF EXISTS (
    SELECT T0.DOCENTRY FROM adoc T0 WHERE T0.[ObjType] = '17'
    AND T0.[UserSign] = '1' AND    T0.[DocStatus] = 'C'   AND
    T0.DOCENTRY= @list_of_cols_val_tab_del )
    BEGIN
    SELECT @Error = 1, @error_message = 'You are not permitted to close Sales Orders'
    END
    END
    But It doesn´t work. I need help!!!
    Thanks

    Hi Jose,
    You have to correct your transaction type parameters.  When you perform close or cancel operations on document; the trasnsaction notification receives parameters u201CCu201D for Cancel and u201CLu201D for Close. So instead of checking add u201CAu201D or update u201CUu201D;  you have to modify your transaction type filters for cancel u201CCu201D or close u201CLu201D.  It will go like belowu2026
    IF @object_type='17' AND (@transaction_type='C' or @transaction_type='L')
    Please try above and let me know the results.
    Thanks & Regards,
    Nitin
    Manager, SAP Business One
    Greytrix
    It's time to think outside the box.
    Email: sap at greytrix.com | Web: www.greytrix.com
    u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026
    Development Partners for SAP B1

  • Stored Procedure for Batch Number Format and Block Duplicate Batch Number

    Hi Experts !
    I am new one in forum asking question.. I want Stored procedure for Batch Number Format. I want fix one Batch number format in Stored Procedure.
    Example :
    My Batch number format Like  BATCH00001 - It should be first five digit is text format and next five is Numeric.
    IF create Goods receipt PO or Goods receipt stage I create batch number like BATCH 00001 or any other number means don't add that document and also duplicated batch number also does not allowed. please give me the solutions. I am sorry for my bad english .

    Dear Nagarajan K.
                         Thanks for your replay ..
    IF @transaction_type IN ('A','U') AND (@object_type = '106' )
    BEGIN
    set @item = LEFT( @list_of_cols_val_tab_del, CHARINDEX(CHAR(9),  @list_of_cols_val_tab_del,1) - 1)
    set @batch = substring(@list_of_cols_val_tab_del, len(@item)+1, (CHARINDEX(CHAR(9),  @list_of_cols_val_tab_del,len(@item)+2)) - (len(@item)+1))
    --set @base =( select basetype from ibt1 where batchnum = ltrim(rtrim(replace(@batch,char(9),''))))
    set @count = (select count(*) from oibt quantity > 0 and where  batchnum = ltrim(rtrim(replace(@batch,char(9),''))))
    if @count > 1
    begin
    set @error = 1
    set @error_message = 'Please enter different Batch Code for batch ''' + @batch + ''' for item ' + @item 
    select @error, @error_message
    END
    END
                  I used above Stored Procedure. here we can use one batch number for different item but  i want to block one batch we should use one item and one time only after than we never use that batch number for same item and another item.
             After that I want format for Batch, we should follow unique Batch number for all items.

  • Stored procedure for getting host name, host instance and status of that host is it running or stopped.

    Hello all,
    yesterday I got one task in that I have to stored procedure for getting host name, host instance and status of that host is it running or stopped.
    any body knows where exactly, In which table this details are there in BizTalk databases.
    thanks

    Status of the host instance is not stored in the SQL database for you to query the status using stored procedure. You have to either use Powershell or WMI to get the status.
    In SQL, following table contains the details about the host like Name, LoginName, IsDisables etc but status of the host instance is not stored in the database.
    SELECT * FROM BizTalkMgmtDb..adm_HostInstance
    Powershell to get the status:
    http://axonolympus.nl/?page_id=186&post_id=969&cat_id=6&lang=en
    WMI to get the status:
    https://msdn.microsoft.com/en-us/library/aa561820.aspx?f=255&MSPPError=-2147217396
    https://msdn.microsoft.com/en-us/library/aa578621.aspx
    Regards,
    M.R.Ashwin Prabhu
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

Maybe you are looking for