Backup of stored procedure

Hi All,
How to take the back up of a stored proceudure along with the privileges associated with it?
DB version:11.1.0.7
OS:AIX 6.1

Example:
SQL> create procedure nix as begin null; end;
  2  /
Procedure created.
SQL> grant execute on nix to fred;
Grant succeeded.
$ expdp schemas=scott include=procedure:"IN('NIX')" directory=DPDIR
Export: Release 11.2.0.1.0 - Production on Fri Apr 20 14:45:12 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
Username: / as sysdba
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
FLASHBACK automatically enabled to preserve database integrity.
Starting "SYS"."SYS_EXPORT_SCHEMA_01":  /******** AS SYSDBA schemas=scott include=procedure:IN('NIX') directory=DPDIR
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 0 KB
Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE
Processing object type SCHEMA_EXPORT/PROCEDURE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE
Master table "SYS"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
Dump file set for SYS.SYS_EXPORT_SCHEMA_01 is:
  /home/oracle/expdat.dmp
Job "SYS"."SYS_EXPORT_SCHEMA_01" successfully completed at 14:45:30Keep in mind that you cannot do a recovery with impdp, just a restore as is. Any change on the procedure in the meantime is lost, therefore.
Alternatively you may take a RMAN backup of the whole Database. That will include everything in a recoverable form.
Kind regards
Uwe Hesse
"Don't believe it, test it!"
http://uhesse.com
Edited by: Uwe Hesse on 20.04.2012 14:51 added of the whole Database for clarification

Similar Messages

  • Backup all stored procedures ?

    Please tell me how to backup just stored procedures which I have in my database ?
    Thanx.
    Martin Stufi
    null

    Hi
    Look at this SQL*Plus script:
    SET PAGESIZE 0
    SET FEEDBACK OFF
    SET LINESIZE 2000
    SET TRIMSPOOL ON
    SET VERIFY OFF
    SET TERMOUT OFF
    SPOOL &1
    SELECT text FROM
    (SELECT name, type, line, text FROM user_source
    UNION
    SELECT DISTINCT name, type, 0,
    'CREATE OR REPLACE ' FROM user_source
    UNION
    SELECT DISTINCT name, type, 1000000000, '/' FROM user_source)
    ORDER BY name, type, line;
    SPOOL OFF
    EXIT
    It is for current user but if you change user_source with all_source and log as system you will spool all sources.
    Regards
    null

  • Backup Stored Procedure SAP BPC MS

    Hi All,
    I am looking for a way to emulate the back-up procedure that gets initiated by the back-up in server manager. I would imagine that it is a stored procedure/+COM component that gets fed both the application set name and the folder path. If i had this i could schedule backups easily with a batch job.
    Any help would be appreciated.
    Regards,
    AvdB

    Hi,
    You don't need to use Xceedzip.dll.
    Backup with server manager means:
    Backup of SQL Server database
    Zip (with winrar or winzip) of folder "nameofappset" from FileDB folder
    Zip (with winrar or winzip) of folder "nameofappset" from Webfolders
    After that these files has to be put into a folder with follow structure:
    "appset name"
        - SQL (folder) and inside a file: "appsetname".bak (sql backup)
        - FileDB (folder) and inside a file "appsetname.zip" (zip of folder from filedb)
        - Webfolder (folder) and inside a file "appsetname.zip" (zip of folder from webfolder
    This can be used after that to be restored with server manager.
    I hope this will help you to create your automate backup.
    Regards
    Sorin Radulescu

  • How do I modify a report to show new fields in a stored procedure?

    The server uses Crystal Reports Embedded Server 2008 SP3 (running on Windows Server 2008 R2 / IIS 7.5), and I am using Crystal Reports Developer 2008 SP3 on my PC.
    Hello,
    I am a MSSQL database administrator with little experience with Crystal Reports.  At my job, we have a need to add a couple of fields to a report.  The report comes with an enterprise procurement web-based application and displays the details of a given purchase order.  They want me to add the supplieru2019s address below the supplieru2019s name on the report.  I was hoping there might be a fairly straight-forward, not overly complicated answer to my question.
    The report works with a stored procedure (OrderForm1) which creates a temp table called #ReportParameters.  It then executes another stored procedure (GetReportParameters), in which it uses 'sp_xml_preparedocument' and eventually 'sp_xml_removedocument'.  It then executes a stored procedure called  (OrderForm1Main) which contains the select statement that brings in the bulk of the fields and joining the pertinent tables.  I made a backup copy of OrderForm1Main and modified the original, to include the supplier address fields.
    Don't know if I'm on the right track, but hereu2019s what I tried so far:
    When I open the OrderForm1.rpt in Crystal Designer, I have found that I can go to Database > Set Datasource Location, create a connection (OLE DB (ADO)) to the database, highlight the name of the stored procedure under u2018Current Data Sourceu2019, then find the same stored procedure in the database in the section u2018Replace withu2019:
    http://i.imgur.com/KXBuf.png
    When I clicked the u2018Updateu2019 button, a u2018Enter Valuesu2019 for parameters window pops up:
    http://i.imgur.com/5uQ9V.png
    Iu2019m confused as to what to do at this part.  Whether I click u2018OKu2019 or u2018Cancelu2019, it then adds my database connection with stored procedure to the list in the u2018Current Data Sourceu2019 section:
    http://i.imgur.com/aD4KH.png
    After completing this data source change, in the Field Explorer under Database Fields > OrderForm1, it then includes the new fields I added to the stored procedure.  However, when dragging the new supplier address fields to the report layout, saving the report in this state, and trying to run it in the web application, the report window displays the message u2018Missing parameter valuesu2019 instead of the report:
    http://i.imgur.com/gz8S3.png
    In Field Explorer > Database Fields > Parameters, Iu2019m seeing a list of parameters that arenu2019t the exact ones in the stored procedure, which leads me to believe, they are somehow defined in the report itself.  Also, under u2018Parameter Fieldsu2019 in the Fields Explorer there is the @fParameters listing with a question mark icon, that appeared since the data source change:
    http://i.imgur.com/llkrk.png
    There does not seem to be an equivalent set of parameters in the database, as there were defined in the report.  I imagine that the actual parameter values come from the data held in the currently displayed purchase order (from which you can push a button 'Print PO' that will display the report in question).  I have read that when you change a data source in Crystal, you have to complete the task of resetting, or adding back in the parameters.  That would be easy if they were in the database somewhere.  Whenever I attempt to look at the properties of the u2018ReportInformationu2019 in u2018Set Datasource Locationu2019, or simply try Database > 'Verify Database' to refresh the datasource, an u2018ADO.NET (XML) windows pops up with a file path in it, something to the effect of:
    MyLoanerLaptop\ebo bk\orderform1.xml:
    http://i.imgur.com/SEVOE.png
    I did a search on the entire server for the file OrderForm1.XML and could not find it anywhere.  So Iu2019m thinking that the software companyu2019s development team used that file originally, to create the report (did they use a dataset to do this, or is the temporary XML file created during the process actually the schema here?).  I think Iu2019m basically trying to change the data source in the report, to an updated version of the original stored procedure referenced, while still somehow leaving the parameters list in the report alone and have them still work?
    Any and all help would be greatly appreciated.  I realize that this type of work most likely is routine stuff that can be learned by taking the time to do so.  My team is only interested in allowing me a certain amount of time and resources to delve into Crystal and we do not have a Crystal dev team.  So, hopefully you understand my dilemma here.
    Thank you,
    Mike
    Edited by: Mike_DBA on Jan 23, 2012 8:03 PM
    Edited by: Mike_DBA on Jan 23, 2012 8:05 PM
    Edited by: Mike_DBA on Jan 23, 2012 8:11 PM (2:12 pm EST)
    Edited by: Mike_DBA on Jan 23, 2012 8:13 PM
    Edited by: Mike_DBA on Jan 23, 2012 8:18 PM
    Edited by: Mike_DBA on Jan 23, 2012 8:30 PM
    Edited by: Mike_DBA on Jan 23, 2012 10:58 PM

    Hi Mike,
    CRSE is an OEM Product and for use with a custom application they have written. Unfortunately we don't their reports or how they are connecting, it would appear they were originally built off a SQL and then set to a Dataset in the app or they could be adding the data source at runtime. Lots of variations and without access to the source code to see what they are doing not much we can help you with.
    You need to contact the OEM Partner for help in resolving this and find out what you can and need to do to update your SP and work with their canned reports,
    Thank you
    Don

  • How to call a sql stored procedure in java...... HELP

    Hi I am making an application for taking backup in sql automatically so i have created a dts package which is called by a stored procedure. Now the problem is that how to call that stored procedure in a Java program so that after running my java program i get my database backup.
    Please please solve my problem.
    thanks in advance.
    If possible please send the code.
    Message was edited by:
    Andy_Davis
    Message was edited by:
    Andy_Davis

    Hi... I am trying to create a dts package which is called by a stored procedure... How can i do this? IF possible can you please send me the code as well..
    Thanks a ton...
    Susan_Davis

  • JDBC - CallableStatement - Error in Accessing Stored Procedure of MS SQL

    Dear Friends,
    The following is the code to access a stored procedure of MS SQL Server 7.0 sp4,
              try
                   CallableStatement cstmt;
                   ResultSet rst;
                   cstmt = connection.prepareCall("{call backupdb[?,?]}");
                   cstmt.setString("db_name","SBIREMITLIVE");
                   cstmt.setString("path", "c:\testing.bak");
                   cstmt.executeQuery();
                   System.out.println("Stored Procedure called successfully");
              catch(SQLException se)
                   System.out.println(se.toString());
    when i execute this i am getting the error as " MS ODBC-MS SQL Server Syntax error or Access Violation "
    What's the problem exactly ? anybody came across this issue..if so...kindly help me....
    Here is my MS SQL Server stored procedure.....for reference
    create procedure backupdb(@db_name varchar(40), @path varchar(100)) as
    Backup database @db_name to disk = @path
    Regards,
    V.Prasanna

    Dear DigitalDreamer,
    Yes, as per your suggestion, it's working fine...thanks a lot...
    here is the code...
                   CallableStatement cstmt;
                   ResultSet rst;
                   cstmt = connection.prepareCall(" exec backupdb ?,? ");
                   cstmt.setString(1,"SBIREMITLIVE");
                   cstmt.setString(2, "c:\\testing.bak");
                   cstmt.execute();
    Regards,
    V.Prasanna

  • Reconfigure in stored procedure

    Hi,
    I'm trying let my users reconfigure my server via a script, but get this error when trying to run as the end user:
    Msg 15247, Level 16, State 1, Procedure sp_configure, Line 94
    User does not have permission to perform this action.
    Msg 5812, Level 14, State 1, Procedure MBMasterAllowConfigure, Line 18
    You do not have permission to run the RECONFIGURE statement.
    Msg 15123, Level 16, State 1, Procedure sp_configure, Line 51
    The configuration option 'xp_cmdshell' does not exist, or it may be an advanced option.
    Msg 5812, Level 14, State 1, Procedure MBMasterAllowConfigure, Line 21
    You do not have permission to run the RECONFIGURE statement.
    I have created a sqluser is master DB (sa_MBserverRole) for only this purpose. My procedure in master looks like this:
    ALTER PROCEDURE [dbo].[MBMasterAllowConfigure]
    WITH EXECUTE AS 'sa_MBserverRole'
    AS
    BEGIN
    SET NOCOUNT ON;
    EXEC sp_configure 'show advanced options', 1
    RECONFIGURE
    EXEC sp_configure 'xp_cmdshell', 1
    RECONFIGURE
    END
    When logging in as the sa_MBserverRole user running:
    use master
    select suser_sname()
    SELECT
    FROM
    fn_my_permissions(NULL,
    'SERVER');
    Giving the result:
    sa_MBserverRole
    server  CONNECT SQL
    server  ALTER SETTINGS
    server  VIEW ANY DATABASE
    Seems as it doesn't matter who I'm logged in as, since the procedure cannot run the reconfigure command anyhow.
    I tried to read Erlands excellent article at http://www.sommarskog.se/grantperm.html#EXECUTE_AS but maybe it's too complicated for me. 
    Could someone help me?
    Best regards /Magnus
    Magnus Burk

    Hi,
    I have now succeeded to read and use your code/article. Thanks a lot!
    I ended up with a trigger calling an SP instead of function, as you recommended Erland.
    I used this complete code:
    --STEP 1
    -- If they exists, remove files C:\temp\cert\saMBCert.cer and C:\temp\cert\saMBCert.pvk
    --STEP 2
    -- This steps create all necessary users, cert, singings to make this work
    /******************* P R I M A R Y D B ******************/
    use Control_Test
    DROP SIGNATURE FROM MB_CheckOtherDBDemo BY CERTIFICATE sa_MBCert
    DROP USER sa_MB
    DROP CERTIFICATE sa_MBCert
    DROP PROCEDURE [dbo].[MB_CheckOtherDBDemo]
    CREATE CERTIFICATE sa_MBCert
    ENCRYPTION BY PASSWORD = 'My pwd 2014' WITH SUBJECT = 'cross DB cert',
    START_DATE = '05/07/2014', EXPIRY_DATE = '10/31/2025';
    CREATE USER sa_MB FROM CERTIFICATE sa_MBCert
    GO
    CREATE PROCEDURE [dbo].[MB_CheckOtherDBDemo]
    AS
    BEGIN
    declare @sqlstring nvarchar(500)
    set @sqlstring = N'select no from controldk_test.dbo.clientx'
    exec sp_executesql @sqlstring
    END
    GO
    GRANT SELECT ON clientx TO sa_MB
    GRANT EXECUTE ON MB_CheckOtherDBDemo TO Lindgren
    GRANT EXECUTE ON MB_CheckOtherDBDemo TO sa_MB
    ADD SIGNATURE TO MB_CheckOtherDBDemo BY CERTIFICATE sa_MBCert
    WITH PASSWORD = 'My pwd 2014'
    BACKUP CERTIFICATE sa_MBCert TO FILE = 'C:\Temp\cert\saMBCert.cer'
    WITH PRIVATE KEY (FILE = 'C:\Temp\cert\saMBCert.pvk' ,
    ENCRYPTION BY PASSWORD = 'My pwd 2014',
    DECRYPTION BY PASSWORD = 'My pwd 2014')
    /******************* O T H E R D B ******************/
    USE ControlDK_Test
    DROP USER sa_MB
    DROP CERTIFICATE sa_MBCert
    CREATE CERTIFICATE sa_MBCert FROM FILE = 'C:\temp\cert\saMBCert.cer'
    WITH PRIVATE KEY (FILE = 'C:\temp\cert\saMBCert.pvk',
    DECRYPTION BY PASSWORD = 'My pwd 2014',
    ENCRYPTION BY PASSWORD = 'My pwd 2014')
    CREATE USER sa_MB FROM CERTIFICATE sa_MBCert
    GRANT SELECT ON clientx TO sa_MB
    GRANT SELECT ON objectx TO sa_MB
    --STEP 3
    -- This step is when changing the stored procedure
    USE Control_Test
    GO
    ALTER PROCEDURE [dbo].[MB_CheckOtherDBDemo]
    @objtype int, -- -1=cid, 1-8=object 1-8
    @objval varchar(10)
    AS
    BEGIN
    declare @sqlcrit varchar(100)
    if @objtype not in (-1,1,2) return 0
    if @objtype=-1 set @sqlcrit='clientx where no='+@objval
    if @objtype in (1,2) set @sqlcrit='objectx where no='+cast(@objtype as char(1))+' and object='+@objval
    declare @otherdb varchar(20)
    if (select db_Name()) = 'Control' set @otherdb='ControlDK'
    if (select db_Name()) = 'ControlDK' set @otherdb='Control'
    if (select db_Name()) = 'ControlDK_Test' set @otherdb='Control_Test'
    if (select db_Name()) = 'Control_Test' set @otherdb='ControlDK_Test'
    declare @count int
    DECLARE @ParamDefinition nvarchar(500)
    SET @ParamDefinition = N'@countOUT int OUTPUT'
    declare @sqlstring nvarchar(500)
    set @sqlstring = N'select @countOUT = count(*) from '+@otherdb+'.dbo.'+@sqlcrit
    exec sp_executesql @sqlstring, @ParamDefinition, @countOUT=@count OUTPUT
    return @count
    END
    GO
    ADD SIGNATURE TO MB_CheckOtherDBDemo BY CERTIFICATE sa_MBCert
    WITH PASSWORD = 'My pwd 2014'
    Everything seems to work as it should, and I am very happy.
    My first question was about RECONFIGURE and xp_cmdshell. I am still using this (with a job every minute), and might change it in the future when time arises ( probably never:-)). Erland: What do you mean with clear the plan cache?
    Thanks again, and have a nice weekend
    /Magnus
    Magnus Burk

  • Adding a stored procedure to the master database?

    I have a SQL server instance being used as our data warehousing environment. The instance consists of several databases that I am snapshotting as part of our high availability strategy for data. I've created a stored procedure that takes the source database
    as an argument and that will create a new snapshot when a new one needs to be created and will also automatically remove the old snapshot. It also updates some synonym tables that point to the new snapshot but that might not be an important detail.
    I would like to have the stored procedure stored some place global to all of the databases that I am routinely snapshotting, but that would mean putting it in the master database. Although having it there makes things significantly better in terms of usability,
    it seems like there's something wrong with putting any stored procedures in the master database. Am I wrong? Is it OK to put stored procedures there in situations like this?

    Yes Database snapshot. We're using it to make our data more available so that when we're refreshing the underlying database we can still access the previous version of the data. Otherwise our reports and applications won't have access to the data or will
    get partial data sets. We don't intend to use it for DR or as a backup.
    ok. if it is for temporary purpose, it will work..
    you can create one master procedure and do that - master database. but you need to make sure you point your applications/reports to the snapshot database and not actual database
    Hope it Helps!!

  • Stored procedure to update the new table by using back up table

    Hi all,
    oracle version -10g
    iam planning to do one time legacy conversion during the migration of one of the tables.
    for that i took the back up of table , now i need to transfer all of the data from the backup table to the new table with some changes..
    so please suggest me how to write the stored procedure?
    back up table name: test t
    new table: test n
    new table will have extra one row .. in that i need to put the logic
    so am planning to write a procedure like below
    create or replace procedure test as
    begin
    insert into TEST T ( u
              v
              w
              X
              y
              z) VALUES
    SET T.U = O.U
    T.V = O.V
    T.W = DECODE(O.W, AD     '01',
                   00     '01')
    T.X = O.X
    T.Y = IF O.W = 'AD' AND O.Y = 'YES' THAN PUT 'AD'
         IF O.W = '00' AND O.Y = 'YES' THAN PUT 'PD'
    IF O.W NOT IN ('AD','00') AND O.Y = 'YES' THEN PUT 'E'
    O.Y= 'NO' THEN PUT 'D'.
         '

    10g is not an Oracle version number. Please run the following:
    SELECT * FROM v$version;What about your situation indicates a requirement for a stored procedure? I wouldn't write one based on what you have posted. It seems, again from what little you posted, that all you need is:
    INSERT INTO <new_table>
    SELECT ... FROM <temp_table>;

  • Running Unix script from stored procedure

    At present, I run a unix script to export my data for backup using telnet. I would like my users to run the commands on their own without my help. My users do not know telnet (they have no IT knowledge). So, I plan to create a form using Developer/2000 and let them run the procedure thru a stored procedure.But, my problem is how can a stored procedure call a unix script?

    Hi,
    solution, used by me.
    Create a stored procedure that produces a text file with utl_file. The content of the file is the script you want to execute on your Unix box.
    On your Unix Box write a shell script that scans the utl_file_dir for Files. If a file is in, chmod 744 to grnt execute rights to it and execute it.
    I have a example if you want.
    Start the script with crontab or let it loop with a sleep inside.
    HTH
    Detlev

  • PL\SQL Stored Procedure failing.

    Hi,
    I have a collection of stored PL\SQL procedures in an Oracle 8i database. I call these stored procedures from Java code through OracleCallableStatement.
    I am experiencing a very strange problem. The system will run fine for a number of hours/days, during which time there will be many hundreds of successful calls to the stored procedures through the JDBC.
    Then, seemingly at random a call will fail. The error originates in the stored procedure and is reported as TABLE OR VIEW DOES NOT EXIST. I must stress here that a procedure that has run successfully many times before, will suddenly fail with this error.
    To my knowledge the stored procedures and schema have not been altered at all. Recompiling the PL\SQL procedure solves the problem.
    Could someone please help me to understand this strange behaviour.
    Thanks in advance,
    Max
    Oracle 8.1.7
    Java 1.3.1
    Classes12.zip

    Hi Max,
    If the error you are receiving is "TABLE OR VIEW DOES NOT EXIST", then you are indeed trying to access a non-existent table. Either the table has been "dropped" or you are using the wrong name to access it. Is the table a temporary table? Are you dynamically generating the name of the table in your java (or PL/SQL) code? When the error occurs, are you verifying whether the table does exist (or not)? Are there any background processes running (like backups, or statistics gathering) that may interfere with your stored procedures? Are these stored procedures in (PL/SQL) packages (that rely on "global" variables that suddenly have their values changed)?
    Solving the problem is easy. Finding the cause of the problem is hard. The error message can sometimes be misleading.
    Good Luck,
    Avi.

  • PowerShell SQL script to replace text in Triggers, Stored Procedure, can't get match

    I think my issue is with matching text and regular expression, any help would be appreciated.
    $server = "BOCADBD2";    
    # The SQL Server instance name
    $database = "SYSDB"; # The database name
    $matchText = "(raiserror\s@errno\s@errmsg)";
    # Definition text to search .Be aware this accepts a regular expression
    $replaceText =  "raiserror (@errmsg,16,1)";
    # Text to replace $matchText
    $alter = $false; # Set to true if you want the script to alter database objects
    $backupFolder = "v:\RaiseErrorTest\";
    # Change script folders. Need a \ (back slash) on the end
    $changeFolder = "v:\RaiseErrorTest\";
    # One file per object, backup & change folders
    $Hold = $matchText;
    # Load the SQL Management Objects assembly (Pipe out-null supresses output)
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | out-null
    # Create our SMO objects
    $srv = New-Object "Microsoft.SqlServer.Management.SMO.Server" $server;
    $db = New-Object ("Microsoft.SqlServer.Management.SMO.Database");
    # Get the database
    $db = $srv.Databases[$database];
    # For each stored procedure in the database
    foreach($proc in $db.StoredProcedures)
    # For each matching stored prcoedure
    if($proc.TextBody -match $matchText )
    Write-Host $matchText;
    Write-Host "Processing proc: " $proc.Name;
    # Backup of the original proc definition
    $proc.Script() | Out-File ($backupFolder + "procs\" + ([string]$srv.name -replace("\\", "_")) + "_" + [string]$db.Name + "_" + [string]$proc.name
    + "_backup.sql");
    # New procedure definition sql
    $proc.Script() -replace($matchtext, $replaceText) | Out-File ($changeFolder + "procs\" + ([string]$srv.name -replace("\\", "_")) + "_" + [string]$db.Name + "_"
    + [string]$proc.name + ".sql");
    # If set to true this will change the procedure definition on the server!
    if($alter)
    $proc.TextBody = $proc.TextBody -replace($matchtext, $replaceText);
    $proc.Alter();
    Write-Host "Altered " $proc.Name;

    I think $matchText is incorrect so I never get a match and was hopping for any suggestions.
    $replaceText  may be incorrect also, have looked for many hours on internet with no luck.
    How can we know if it is correct.  We cannot see the target text. Try it with an example of the test you are looking for.
    Your match only matches: "raiserror @errno @errmsg"
    And no other string.
    ¯\_(ツ)_/¯

  • Privilege for creating a View from a Stored Procedure

    Hi,
                         I need to create a view from a procedure. I could do it from an anonymous block whereas I am unable to do that from a Stored Procedure. Should I need a specific privilege for performing this operation? If so what would be the reason behind it? Will that privilege be given in production databases?
    Code to replicate:
    CREATE TABLE t11 AS SELECT * FROM DUAL;
    CREATE OR REPLACE PROCEDURE p_etl_test_view
    AS
    BEGIN
       EXECUTE IMMEDIATE 'CREATE OR REPLACE VIEW v_t11 AS SELECT * FROM t11';
    END;
    PROCEDURE P_ETL_TEST_VIEW compiled
    Elapsed: 00:00:00.131
    BEGIN
       EXECUTE IMMEDIATE 'CREATE OR REPLACE VIEW v_t11 AS SELECT * FROM t11';
    END;
    anonymous block completed
    Elapsed: 00:00:00.069
    BEGIN
       p_etl_test_view;
    END;
    Error starting at line 13 in command:
    BEGIN
       p_etl_test_view;
    END;
    Error report:
    ORA-01031: insufficient privileges
    ORA-06512: at "OCCSS_ENTMT_HK_DEV_01.P_ETL_TEST_VIEW", line 4
    ORA-06512: at line 2
    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.
    Elapsed: 00:00:00.100
    The privileges I am having:
    SELECT   *
        FROM dba_sys_privs
       WHERE grantee = 'OCCSS_ENTMT_HK_DEV_01'
          OR grantee IN (SELECT granted_role
                           FROM dba_role_privs
                          where grantee = 'OCCSS_ENTMT_HK_DEV_01')
    ORDER BY 1;
    GRANTEE
    PRIVILEGE
    ADMIN_OPTION
    EXP_FULL_DATABASE
    ADMINISTER RESOURCE MANAGER
    NO
    EXP_FULL_DATABASE
    ADMINISTER SQL MANAGEMENT OBJECT
    NO
    EXP_FULL_DATABASE
    BACKUP ANY TABLE
    NO
    EXP_FULL_DATABASE
    CREATE SESSION
    NO
    EXP_FULL_DATABASE
    CREATE TABLE
    NO
    EXP_FULL_DATABASE
    EXECUTE ANY PROCEDURE
    NO
    EXP_FULL_DATABASE
    EXECUTE ANY TYPE
    NO
    EXP_FULL_DATABASE
    READ ANY FILE GROUP
    NO
    EXP_FULL_DATABASE
    RESUMABLE
    NO
    EXP_FULL_DATABASE
    SELECT ANY SEQUENCE
    NO
    EXP_FULL_DATABASE
    SELECT ANY TABLE
    NO
    OCCSS_ENTMT_HK_DEV_01
    CREATE DATABASE LINK
    NO
    OCCSS_ENTMT_HK_DEV_01
    CREATE TABLE
    NO
    OCCSS_ENTMT_HK_DEV_01
    DEBUG CONNECT SESSION
    NO
    OCCSS_ENTMT_HK_DEV_01
    SELECT ANY DICTIONARY
    NO
    SCB_SCHEMA_ROLE
    ALTER SESSION
    NO
    SCB_SCHEMA_ROLE
    CREATE CLUSTER
    NO
    SCB_SCHEMA_ROLE
    CREATE DIMENSION
    NO
    SCB_SCHEMA_ROLE
    CREATE INDEXTYPE
    NO
    SCB_SCHEMA_ROLE
    CREATE JOB
    NO
    SCB_SCHEMA_ROLE
    CREATE MATERIALIZED VIEW
    NO
    SCB_SCHEMA_ROLE
    CREATE OPERATOR
    NO
    SCB_SCHEMA_ROLE
    CREATE PROCEDURE
    NO
    SCB_SCHEMA_ROLE
    CREATE SEQUENCE
    NO
    SCB_SCHEMA_ROLE
    CREATE SESSION
    NO
    SCB_SCHEMA_ROLE
    CREATE SYNONYM
    NO
    SCB_SCHEMA_ROLE
    CREATE TABLE
    NO
    SCB_SCHEMA_ROLE
    CREATE TRIGGER
    NO
    SCB_SCHEMA_ROLE
    CREATE TYPE
    NO
    SCB_SCHEMA_ROLE
    CREATE VIEW
    NO

    BoopathyVasagam wrote:
    Thank you for your answer. So should I issue the below statement? (Since I dont have dba privs i couldn't test this)
    GRANT CREATE VIEW to P_ETL_TEST_VIEW;
    I doubt that above will prevent the error from being thrown.
    prior to running anonymous block again; just do as below
    SET ROLE NONE;
    doing so should result in same error being thrown when invoking
    BEGIN 
       p_etl_test_view; 
    END; 

  • Get variable values from a stored procedure

    I am using SQL 2008R2 and I want to replace a view inside a stored procedure with a new stored procedure to return multiple variable values. Currently I am using the code below to get values for 4 different variables.  I would rather get the 4 variables
    from a stored procedure (which returns all of these 4 values and more) but not sure how to do so.  Below is the code for getting the 4 variable values in my current sp.
    DECLARE @TotalCarb real;
    DECLARE @TotalPro real;
    DECLARE @TotalFat real;
    DECLARE @TotalLiquid real;
    SELECT @TotalCarb = ISNULL(TotCarb,0),
    @TotalPro = ISNULL(TotPro,0),
    @TotalFat = ISNULL(TotFat,0),
    @TotalLiquid = ISNULL(TotLiq,0)
    FROM dbo.vw_ActualFoodTotals
    WHERE (MealID = @MealID);

    You can replace the view with inline table valued user-defined function:
    http://www.sqlusa.com/bestpractices/training/scripts/userdefinedfunction/
    See example: SQL create  INLINE table-valued function like a parametrized view
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Pointbase : How can I create a stored procedure with Pointbase database?

    Hello,
    Excuse me for my english, I'm not anglophone. I try to create a stored procedure.
    This is my file SampleExternalMethods.java :
      import java.sql.*;    //import com.pointbase.jdbc.jdbcInOutDoubleWrapper;          public class SampleExternalMethods    {      // A connection object to allow database callback      static Connection conn = null;      static Statement l_stmt;      static Statement m_stmt;      static CallableStatement m_callStmt = null;      static ResultSet l_rs = null;          public static void main(String[] args)      {        try        {          String url = "jdbc:pointbase:server://localhost/pointbaseDB";          String username = "PBPUBLIC";          String password = "PBPUBLIC";          conn = DriverManager.getConnection(url, username, password);          doCreateProcedure();          doInvokeProcedure();        } catch (SQLException e) {          e.printStackTrace();        } finally {          if (m_stmt != null) {            try {              m_stmt.close();            } catch (Exception e) {              e.printStackTrace();            }          }          if (m_callStmt != null) {            try {              m_callStmt.close();            } catch (Exception e) {              e.printStackTrace();            }          }          if (conn != null) {            try {              conn.close();            } catch (Exception e) {              e.printStackTrace();            }          }        }      }                  public static void getCountry(String Iso_Code)      {        try        {          // Query the database for the country iso code          l_stmt = conn.createStatement();          l_rs = l_stmt.executeQuery( "SELECT * FROM countries"          + " WHERE country_iso_code ='" + Iso_Code + "'");          //Affichage du résultat de la requête          l_rs.next();          System.out.print(l_rs.getString(1) + " - ");          System.out.print(l_rs.getString(2) + " - ");          System.out.println(l_rs.getString(3));          // Close the result set          l_rs.close();        } catch (SQLException e) {          e.printStackTrace();        } finally {          if (l_rs != null) {            try {              l_rs.close();            } catch (Exception e) {              e.printStackTrace();            }          }          if (l_stmt != null) {            try {              l_stmt.close();            } catch (Exception e) {              e.printStackTrace();            }          }        }      }            public static void doCreateProcedure() throws SQLException {        // SQL statement to create a stored procedure        String SQL_CREATE_PROC = "CREATE PROCEDURE getCountry(IN P1 VARCHAR(30))"        + " LANGUAGE JAVA"        + " SPECIFIC getCountry"        + " NO SQL"        + " EXTERNAL NAME \"SampleExternalMethods::getCountry\""        + " PARAMETER STYLE SQL";        // Create a SQL statement        m_stmt = conn.createStatement();        // Execute the SQL        m_stmt.executeUpdate(SQL_CREATE_PROC);        // Close the statement        //m_stmt.close();      }          public static void doInvokeProcedure() throws SQLException {        // Create SQL to invoke stored procedures        String SQL_USE_PROC = "{ call getCountry(?) }";        // Create a callable statement with three binding parameters        m_callStmt = conn.prepareCall(SQL_USE_PROC);        m_callStmt.setString(1, "CA");        m_callStmt.executeQuery();        // Close the callable statement        //m_callStmt.close();      }    } 
    Afterwards, I have read this note in a Pointbase document:
    To invoke the dateConvert external Java method from a stored function, you must use the
    CREATE FUNCTION statement. The dateConvert external Java method is called from the
    class, SampleExternalMethods.
    In order for the database to access this external Java method, the class SampleExternalMethods
    must be included in the database CLASSPATH. For PointBase Embedded - Server Option, it
    must be in the Server CLASSPATH, but not in the Client CLASSPATH.
    If PointBase Server is run with the Java Security Manager, in the java policy file grant
    ’com.pointbase.sp.spPermission’ to the class that implements the external Java method.
    An "spPermission" consists of a class name with no action. The class name is a name of a class
    that could be used in creating a Stored Procedure in PointBase. The naming convention follows
    the hierarchical property naming convention and that is supported by
    "java.security.BasicPermission". An asterisk may appear by itself, or if immediately preceded
    by ".", may appear at the end of the name, to signify a wildcard match. The name cannot
    contain any white spaces.
    I'm not sure, but I suppose that I must include the class SampleExternalMethods in a .jar file.
    The database CLASSPATH could be : C:\Sun\AppServer\pointbase\lib\
    These my files in this database CLASSPATH:
    pbclient.jar
    pbembedded.jar
    pbtools.jar
    pbupgrade.jar
    I have tryed to include the class SampleExternalMethods in pbclient.jar and pbembedded.jar with this command:
    jar -uf pbembedded.jar SampleExternalMethods
    Afterwards I do that,
    1) Start Pointbase
    2) Configuration of classpath
    set classpath=C:\Sun\AppServer\pointbase\lib\pbclient.jar
    set classpath=%classpath%;D:\J2EE\Ch07Code\Ch07_06
    I precise that my file SampleExternalMethods is into D:\J2EE\Ch07Code\Ch07_06\Ch07.
    Then, I run the program:
    D:\J2EE\Ch07Code\Ch07_06>java -Djdbc.drivers=com.pointbase.jdbc.jdbcUniversalDriver Ch07.SampleExternalMethods
    But I have an error message:
    Exception in thread "main" java.lang.NoClassDefFoundError: Ch07.SampleExternalMethods (wrong name: SampleExternalMethods)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.DefineClass(ClassLoader.java:539)
    The problem, I suppose, comes from that the class SampleExternalMethods
    must be included in the database CLASSPATH, but there is a pbserver.jar with pointbase normally, but I didn't find it. That's why I use pbembedded.jar or pbclient.jar in order to include the class SampleExternalMethods. May be I must start from C:\Sun\AppServer\pointbase\lib\ instead of D:\J2EE\Ch07Code\Ch07_06\Ch07?
    Please, can somebody helps me?
    Thank you in advance.
    cagou!

    jschell wrote:
    And I doubt you can recurse like that for embedded java. You must have a class that does the functionality and another class that creates the proc.
    >And I doubt you can recurse like that for embedded java. You must have a class that does the functionality and another class that creates the proc.
    >
    And I doubt you can recurse like that for embedded java. You must have a class that does the functionality and another class that creates the proc.
    Thank you for your response, I have done two classes:
    SampleExternalMethods.java:
    package Ch07;
    import java.sql.*;*
    *public class SampleExternalMethods*
    *public static void getCountry(String Iso_Code)*
    *// A connection object to allow database callback*
    *Connection l_conn = null;*
    *Statement l_stmt = null;*
    *ResultSet l_rs = null;*
    *try*
    *String url = "jdbc:pointbase:server://localhost/pointbaseDB";*
    *String username = "PBPUBLIC";*
    *String password = "PBPUBLIC";*
    *l_conn = DriverManager.getConnection(url, username, password);*
    *// Query the database for the country iso code*
    *l_stmt = l_conn.createStatement();*
    *l_rs = l_stmt.executeQuery( "SELECT* FROM PBPUBLIC.COUNTRIES"
    +" WHERE country_iso_code ='"+ Iso_Code +"'");+
    +//Affichage du r&eacute;sultat de la requ&ecirc;te+
    +l_rs.next();+
    +System.out.print(l_rs.getString(1)+ " - ");
    System.out.print(l_rs.getString(2) +" - ");+
    +System.out.println(l_rs.getString(3));+
    +// Close the result set+
    +l_rs.close();+
    +} catch (SQLException e) {+
    +e.printStackTrace();+
    +} finally {+
    +if (l_rs != null) {+
    +try {+
    +l_rs.close();+
    +} catch (Exception e) {+
    +e.printStackTrace();+
    +}+
    +}+
    +if (l_stmt != null) {+
    +try {+
    +l_stmt.close();+
    +} catch (Exception e) {+
    +e.printStackTrace();+
    +}+
    +}+
    +if (l_conn != null) {+
    +try {+
    +l_conn.close();+
    +} catch (Exception e) {+
    +e.printStackTrace();+
    +}+
    +}+
    +}+
    +}+
    +}+
    CreateMethods.java:
    +package Ch07;+
    +import java.sql.*;+
    +public class CreateMethods+
    +{+
    +// A connection object to allow database callback+
    +static Connection m_conn = null;+
    +static Statement m_stmt;+
    +static CallableStatement m_callStmt = null;+
    +public static void main(String[] args)+
    +{+
    +try+
    +{+
    +String url = "jdbc:pointbase:server://localhost/pointbaseDB";+
    +String username = "PBPUBLIC";+
    +String password = "PBPUBLIC";+
    +m_conn = DriverManager.getConnection(url, username, password);+
    +doCreateProcedure();+
    +doInvokeProcedure();+
    +} catch (SQLException e) {+
    +e.printStackTrace();+
    +} finally {+
    +if (m_stmt != null) {+
    +try {+
    +m_stmt.close();+
    +} catch (Exception e) {+
    +e.printStackTrace();+
    +}+
    +}+
    +if (m_callStmt != null) {+
    +try {+
    +m_callStmt.close();+
    +} catch (Exception e) {+
    +e.printStackTrace();+
    +}+
    +}+
    +if (m_conn != null) {+
    +try {+
    +m_conn.close();+
    +} catch (Exception e) {+
    +e.printStackTrace();+
    +}+
    +}+
    +}+
    +}+
    +public static void doCreateProcedure() throws SQLException {+
    +// SQL statement to create a stored procedure+
    +String SQL_CREATE_PROC = "CREATE PROCEDURE PBPUBLIC.getCountry(IN P1 VARCHAR(30))"+
    " LANGUAGE JAVA"
    +" SPECIFIC getCountry"+
    " NO SQL"
    +" EXTERNAL NAME \"SampleExternalMethods::getCountry\""+
    " PARAMETER STYLE SQL";
    // Create a SQL statement
    m_stmt = m_conn.createStatement();
    // Execute the SQL
    m_stmt.executeUpdate(SQL_CREATE_PROC);
    // Close the statement
    //m_stmt.close();
    public static void doInvokeProcedure() throws SQLException {
    // Create SQL to invoke stored procedures
    String SQL_USE_PROC = "{ call getCountry(?) }";
    // Create a callable statement with three binding parameters
    m_callStmt = m_conn.prepareCall(SQL_USE_PROC);
    m_callStmt.setString(2, "CA");
    m_callStmt.executeQuery();
    // Close the callable statement
    //m_callStmt.close();
    }But I have the same error message that previously.
    I have read this note and I suppose that the problem is linked:
    If PointBase Server is run with the Java Security Manager, in the java policy file grant
    *’com.pointbase.sp.spPermission’ to the class that implements the external Java method.*
    An "spPermission" consists of a class name with no action. The class name is a name of a class
    that could be used in creating a Stored Procedure in PointBase. The naming convention follows
    the hierarchical property naming convention and that is supported by
    *"java.security.BasicPermission". An asterisk may appear by itself, or if immediately preceded*
    by ".", may appear at the end of the name, to signify a wildcard match. The name cannot
    contain any white spaces.
    Can you explain me what I must to do in order to solve this problem of spPermission.
    Thanks.

Maybe you are looking for

  • Need to replace a file in the application server

    Hello Experts, Through ABAP coding, I need to replace a file which is available in the application server from one path to another. I should not use OPEN DATASET, CLOSE DATASET, DELETE DATASET and all as they deal with the data. I need to replace the

  • Message Class(MIRO)

    Hello Experts, DownPayment has been made to vendor, usually while processing in MIRO we will get an message which says Fixed assets downpayment exist,but for this particular vendor the message is not displaying. Thanks in Advance

  • Advice on freeing iMac disk space

    Machine Model: iMac CPU Type: PowerPC G4 (3.3) Number Of CPUs: 1 CPU Speed: 1 GHz L2 Cache (per CPU): 256 KB Memory: 512 MB Bus Speed: 167 MHz Boot ROM Version: 4.7.8f1 I want to upgrade Panther to Leopard but don't have the 9 GB free disk space requ

  • How do I stop my movie from playing?

    I have used previous versions of Adobe Flash and now have Professional CS5.5, and I am coming to you with an embarrasingly, ridiculously stupid question that is absolutely stumping me. My movie cannot stop playing, no matter how many stop(); I've emb

  • MySQL Database Index Page

    I'm looking for a way to create an index of my MySQL database tables. The basic concept is to have a list of the table names on the left hand side of the page. Clicking on a name will bring up the database contents (repeated to display each record) o