মঙ্গলবার, ১১ আগস্ট, ২০২০

File Transfer Using Oracle

 DBMS_FILE_TRANSFER.COPY_FILE(
   source_directory_object       IN  VARCHAR2,
   source_file_name              IN  VARCHAR2,
   destination_directory_object  IN  VARCHAR2,
   destination_file_name         IN  VARCHAR2);


BEGIN
DBMS_FILE_TRANSFER.COPY_FILE('DMPDIR',"expdp_28-07-Tue_23.00_PM.zip", 'DMPDIR',
                                   "expdp_28-07-Tue_23.00_PM2.zip");
END;

create or replace directory DMPDIR AS 'G:\';

create or replace directory DMPDIR2 AS 'G:\NEW';


BEGIN
  DBMS_FILE_TRANSFER.COPY_FILE(
   source_directory_object      => 'DMPDIR',
   source_file_name             => 'IMPORT.LOG',
   destination_directory_object => 'DMPDIR',
   destination_file_name        => 'IMPORT2.LOG');
END;
/


begin
UTL_FILE.FCOPY ('DMPDIR', 'expdp_28-07-Tue_23.00_PM.zip', 'DMPDIR', 'expdp_28-07-Tue_23.00_PM2.zip');
end;
/

সোমবার, ২০ জুলাই, ২০২০

Physical file existence check

DECLARE
  l_file_exists BOOLEAN;
  l_file_len    NUMBER;
  l_blocksize   BINARY_INTEGER;
BEGIN
  utl_file.fgetattr(
    location    => 'UTL_DIR',
    filename    => 'MM.TXT',
    fexists     => l_file_exists,
    file_length => l_file_len,
    block_size  => l_blocksize);
  IF l_file_exists THEN
    dbms_output.put_line('File found, size=' || l_file_len);
  ELSE
    dbms_output.put_line('File not found.');
  END IF;
END;

বৃহস্পতিবার, ৪ জুন, ২০২০

Getting data from oracle database to android device

 if (Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }
    try {
        Class.forName("oracle.jdbc.driver.OracleDriver");

        String url="jdbc:oracle:thin:@192.168.0.102:1521:orcl";
        String username="hr";
        String password="hr";
        Connection con=DriverManager.getConnection(url, username, password);
        Statement stmt=con.createStatement();

        ResultSet rs = stmt.executeQuery("select first_name from employees");
        StringBuilder stringBuffer = new StringBuilder();
        while (rs.next()) {
            stringBuffer.append(rs.getString(1) + "\n");
        }
        editText.setText(stringBuffer.toString());


        con.close();
} catch (SQLException e) {
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }

শনিবার, ৪ এপ্রিল, ২০২০

AUDIT TABLE

Audit_trail



ALTER SYSTE SET AUDIT_TRAIL=DB,EXTENDED SCOPE=SPFILE

SHU IMMEDIATE
STARTUP

AUDIT ALL BY HR BY ACCESS;
AUDIT SELECT TABLE , UPDATE TABLE, INSERT TABLE, DELETE TABLE BY HR BY ACCESS;
AUDIT EXECUTE PROCEDURE BY HR BY ACCESS

VIEW AUDIT TRAIL

SELECT VIEW NAME
FROM DBA_VIEWS
WHERE VIEW_NAME LIKE 'DBA%AUDIT%'


BASE TABLE

DESC AUD$

SELECT USERNAME,EXTENDED_TIMESTAMP,OWNER,OBJ_NAME,ACTION_NAME FROM DBA_AUDIT_TRAIL
WHERE OWNER='HR'

সোমবার, ৩০ মার্চ, ২০২০

SQL Tuning Advisor

DECLARE
  l_sql_tune_task_id  VARCHAR2(100);
BEGIN
  l_sql_tune_task_id := DBMS_SQLTUNE.create_tuning_task (
                          sql_id      => '3rfdxk7fxh9b9',
                          scope       => DBMS_SQLTUNE.scope_comprehensive,
                          time_limit  => 60,
                          task_name   => '3rfdxk7fxh9b9_tuning_task11',
                          description => 'Tuning task1 for statement 87s8z2zzpsg88');
  DBMS_OUTPUT.put_line('l_sql_tune_task_id: ' || l_sql_tune_task_id);
END;
/


XEC DBMS_SQLTUNE.execute_tuning_task(task_name => '3rfdxk7fxh9b9_tuning_task11');



set long 65536
set longchunksize 65536
set linesize 100
select dbms_sqltune.report_tuning_task('3rfdxk7fxh9b9_tuning_task11') from dual;



execute dbms_sqltune.drop_tuning_task('3rfdxk7fxh9b9_tuning_task11');

বুধবার, ১৮ মার্চ, ২০২০

EXP AND EXPDP

@echo off
REM
SET dirname="%date:~-7,2%-%date:~-10,2%-%date:~-4%"
mkdir \\192.168.1.99\Delowar-IT\EXP_BACKUP\%dirname%                     

set oracle_sid=ala
setlocal
for /f "tokens=1-4 delims=/ " %%a in ('date /t') do set DATE=%%c-%%b-%%a
for /f "tokens=1-3 delims=: " %%a in ('time /t') do (
set hours=%%a
set minutes=%%b
set ampm=%%c
)
if {%ampm%}=={AM} if {%hours%}=={12} set hours=00
if {%ampm%}=={PM} (
for /f "delims=0 tokens=*" %%a in ("%hours%") do set hours=%%a
set /a hours+= 12
)

E:\database2\product\11.2.0\dbhome_1\BIN\exp labserp/drockfantasi29@dba file=\\192.168.1.99\Delowar-IT\EXP_BACKUP\\%dirname%\lan_%date%_%hours%.%minutes%_%ampm%.dmp  log=\\192.168.1.99\Delowar-IT\EXP_BACKUP\\%dirname%\lan_%date%_%hours%.%minutes%_%ampm%.log statistics=none



@echo off
REM
SET dirname="%date:~-7,2%-%date:~-10,2%-%date:~-4%"
--mkdir \\192.168.1.99\Delowar-IT\EXP_BACKUP\%dirname%                     

set oracle_sid=ala
setlocal
for /f "tokens=1-4 delims=/ " %%a in ('date /t') do set DATE=%%c-%%b-%%a
for /f "tokens=1-3 delims=: " %%a in ('time /t') do (
set hours=%%a
set minutes=%%b
set ampm=%%c
)
if {%ampm%}=={AM} if {%hours%}=={12} set hours=00
if {%ampm%}=={PM} (
for /f "delims=0 tokens=*" %%a in ("%hours%") do set hours=%%a
set /a hours+= 12
)

E:\database2\product\11.2.0\dbhome_1\BIN\expdp labstest/labstest@bidba directory=expdp_dir dumpfile=expdp_%date%_%hours%.%minutes%_%ampm%.dmp logfile=expdp_%date%_%hours%.%minutes%_%ampm%.log network_link=source

বৃহস্পতিবার, ২ জানুয়ারী, ২০২০

Basic C Programming


#include<stdio.h>

int main()
{

    int i,n,min=0,secmin,loc=1,seclocation;

    printf("Give the number :");
    scanf("%d",&n);
    int num[n];
    for(i=1;i<=n;i++)
    {
    scanf("%d",&num[n]);
    }
    min=num[0];
    for(i=1;i<=n;i++)
    {
        if(num[i]<min)
        {
          secmin=min;
          seclocation=loc;
          min=num[i];
          loc=i+1;
        }


    }
    printf("That is %d,%d\n",seclocation,secmin);


}
 



#include<stdio.h>

int main()
{
    printf("Studytonight - Best place to learn");

    double a, b, c;

    printf("Enter 3 numbers:\n");
    scanf("%lf%lf%lf", &a, &b, &c);  //lf is a format specifier to take double as input

    if(a >= b && a >= c)
    {
        if(b >= c)
        {
            printf("\n\n%.2lf is the 2nd largest number\n", b);
        }
        else
        {
            printf("\n\n%.2lf is the 2nd largest number\n", c);
        }
    }
    else if(b >= a && b >= c)
    {
        if(a >= c)
        {
            printf("\n\n%.2lf is the 2nd largest number\n",a);
        }
        else
        {
            printf("\n\n%.2lf is the 2nd largest number\n",c);
        }
    }

    else if(a >= b)
    {
        printf("\n\n%.2lf is the 2nd largest number\n", a);
    }else
    {
        printf("\n\n%.2lf is the 2nd largest number\n", b);
    }

    printf("\n\n\t\t\tCoding is Fun !\n\n\n");
    return 0;
}




#include<stdio.h>>


int main()
{
int i=0,d,n;
printf("Give The number You want to sum :\n");
scanf("%d",&n);
for (i=0;i<=n;i++)
{
d=d+i;
printf("\nNext Number are :%d",i);

}

printf("\nTotal of all are :%d",d);
}

===========================

#include <stdio.h>
void main()
{
int i,n,sum=0;
float avg;
printf("Input the 10 numbers : \n");
for (i=1;i<=10;i++)
{
printf("Number-%d :",i);

scanf("%d",&n);
sum +=n;
}
avg=sum/10.0;
printf("The sum of 10 no is : %d\nThe Average is : %f\n",sum,avg);

}

=========================

#include <stdio.h>
void main()
{
int i,ctr;
printf("Input number of terms : ");
scanf("%d", &ctr);
for(i=1;i<=ctr;i++)
{
printf("Number is : %d and cube of the %d is :%d \n",i,i, (i*i*i));
}
}

=======================

#include <stdio.h>
void main()
{
   int i,n,sum=0;

   printf("Input number of terms : ");
   scanf("%d",&n);
   printf("\nThe odd numbers are :");
   for(i=1;i<=n;i++)
   {
     printf("%d ",2*i-1);
     sum+=2*i-1;
   }
   printf("\nThe Sum of odd Natural Number upto %d terms : %d \n",n,sum);
}
===================================


#include <stdio.h>

void main()
{
   int i,n,sum=0;

   printf("Input number of terms : ");
   scanf("%d",&n);
   printf("\nThe even numbers are :");
   for(i=1;i<=n;i++)
   {
     printf("%d ",2*i);
     sum+=2*i;
   }
   printf("\nThe Sum of even Natural Number upto %d terms : %d \n",n,sum);
}

====================================

#include<stdio.h>>


int main()
{
 int i=0,d=1,n;
 char t;
 printf("Give The number You want to sum :\n");
 scanf("%d",&n);
for (i=0;i<=n;i++)
{
    d=d+4*i;
    printf("%d",d);
t=t*(-1);
if (i<n)
      {
          printf("+");

      }
}
}
===============================


#include<stdio.h>>


int main()
{
 int num[5],i,n,sum=0;
 char t;
 printf("Give The number You want to sum :");
 scanf("%d",&n);

 for (i=0;i<n;i++)
{
scanf("%d",&num[i]);
}
for (i=0;i<n;i++)
{
sum=sum+num[i];

}
printf("Number are :%d",sum);
}
=================================

#include<stdio.h>>

int main()
{
 int num[5],i,n;
 char t;
 printf("Give The number You want to sum :");
 scanf("%d",&n);

 for (i=0;i<n;i++)
{
scanf("%d",&num[i]);
}
  int  max=num[0];
for (i=0;i<n;i++)
{

    if (max<num[i])
max=num[i];

}
printf("Number are :%d",max);
}

=============================

#include <stdio.h>

void main()
{
  int n,i;
  long sum=0;
  long int t=1;
  printf("Input the number of terms : ");
  scanf("%d",&n);
  for(i=1;i<=n;i++)
  {
     printf("%ld  ",t);
      if (i<n)
      {
          printf("+ ");

      }
     sum=sum+t;
     t=(t*10)+1;
  }
  printf("\nThe Sum is : %ld\n",sum);
}

=============================


#include<stdio.h>>


int main()
{
 int i=0,d=1,n;
 char t;
 printf("Give The number You want to sum :\n");
 scanf("%d",&n);
for (i=1;i<=n;i++)
{

    printf("\n%d",d);
d=d+4;

}
}

==============================


#include<stdio.h>>


int main()
{
 int i=0,d=1,n;
 char t;
 printf("Give The number You want to sum :\n");
 scanf("%d",&n);
for (i=1;i<=n;i++)
{
d=i;
    printf("%d",d);
t=t*(-1);
if (i<n)
{
    printf("%c",t);
}

}
}