Thursday, September 29, 2011

Enable HttpPost in .net Web Service

Will need to add the following to your Web.config:



   <system.web>
   ...
      <webservices>
         <protocols>
            <clear/>
            <add name="HttpSoap">
            <add name="HttpSoap12">
            <add name="HttpPost">
            <add name="HttpGet">
            <add name="Documentation">
            <add name="HttpPostLocalhost">
         </protocols>
      </webservices>
   ...
   </system.web>


If you want to turn off one of the protocols, just comment out that add line. The "Documentation" protocol is the .net generated WSDL.

Wednesday, June 29, 2011

Example Function to Look up Top Level Org

CREATE OR REPLACE FUNCTION f_getTopOrg 
( orgID IN MYSCHEMA.t_organization.organizationid%TYPE ) 

RETURN MYSCHEMA.t_organization.organizationid%TYPE 

IS
    pOrgID MYSCHEMA.t_organization.organizationid%TYPE;
    cOrgID MYSCHEMA.t_organization.organizationid%TYPE;

BEGIN
    pOrgID := orgID;
    WHILE pOrgID IS NOT NULL
     LOOP
       cOrgID := pOrgID;
       SELECT A.parentorganizationid
         INTO pOrgID
         FROM MYSCHEMA.t_organization A
        WHERE A.organizationid = cOrgID;
     END LOOP;
    RETURN(cOrgID);
END;


Lock and Kill User Connections

ALTER USER APPLICATION_USER ACCOUNT LOCK;

  SELECT 'alter system kill session ''' || sid 
      || ',' || serial# || ''';     ' || sql_id death
    FROM v$session
   WHERE username = 'APPLICATION_USER';


Reset SYS, SYSTEM Password

Log into the server's console and connect as the system administrator, then reset the SYS and SYSTEM password.

Clear Transaction Logs

This is how to disable archiving: C:> sqlplus sys/@dbalias as sysdba SQL> shutdown immediate SQL> startup mount SQL> alter database noarchivelog; SQL> alter database open; SQL> archive log list SQL> alter system switch logfile; Run this about 10 times, delete all archived log files and then proceed. This is how to enable archiving: SQL> archive log list At this point the numbers should have incremented as many as the number of switches. SQL> shutdown immediate SQL> startup mount SQL> alter database archivelog; Database altered. SQL> alter database open; SQL> archive log list SQL> alter system switch logfile; Run this a couple of times and you should see new archived log files. SQL> archive log list At this point the numbers should have incremented as many as the number of switches. Exit SQLPlus and do an immediate full backup of the system.

Example backup batch file

set ORACLE_SID=MYPROJ exp system/******@myuser file=MYPROJ.dmp log=export.log full=y for /f "tokens=1-5 delims= " %%d in ("%date%") do set dayfldr=%%d xcopy MYPROJ.dmp "\\Projects\MYPROJ\Database\Daily_Exports\%dayfldr%\" /Z /R /V /Y

Drop all objects in schema

Normally, it is simplest to drop and add the user. This is the preferred method if you have system or sysdba access to the database. If you don't have system level access, and want to scrub your schema, the following sql will produce a series of drop statments, which can then be executed. Note: be sure you are connected as the schema owner, would be tragic to drop system tables.... spool dropall.sql select 'drop '||object_type||' '|| object_name|| DECODE(OBJECT_TYPE,'TABLE',' CASCADE CONSTRAINTS;',';') from user_objects spool off Then, can purge the recycle bin to really clean things up: purge recyclebin; This will produce a list of drop statements. Not all of them will execute - if you drop with cascade, dropping the PK_* indices will fail. But in the end, you will have a pretty clean schema. Confirm with: select * from user_objects