giovedì 12 gennaio 2012

Year 2012

Another year :-) 2012.

See now my 2011 objectives :
  • Improve my English Level : So and so
  • Improve my Chess Level : So and so
  • Improve my incomes : Failed
  • Be a better Christian : So and so
  • Learn at least two new programming languages : Failed (Just Perl)

Very very bad results.

So here there is my new list, for 2012, equal to 2011 :
  • Improve my English Level
  • Improve my Chess Level
  • Improve my incomes
  • Be a better Christian
  • Learn at least two new programming languages
I hope that in January 2013 results are better ;-)

Stay tuned.

mercoledì 19 ottobre 2011

Script sql for sqlldr

Hi

This is a script sql to create a dat and a ctl file to load data on an oracle table from a user to another user.

I searched this on internet without success so i had wrote it.

Enjoy :

--
-- Created by Giovanni Palleschi - Ver. 1.0 - 10/10/2011
--
-- This script sql permits to create files dat and ctl for sqlldr oracle utility
-- Script accepts in input two parameters :
--
-- 1) Table Name
-- 2) Condition to extract
--
-- Ej. sqlplus pippo/pluto @gpgen_sqlloader.sql TABLE1 "1=1"
--
-- In this mode will be extracted all rows from table TABLE1.
-- Script will produce two files :
--
-- ./TABLE1.dat
-- ./TABLE1.ctl
--
--
set echo off
set termout off
set feedback off
SET serverout ON size unlimited
set linesize 8192
set pagesize 0
set verify off
set heading off

host echo ' Start Generacion sqlloader files for table &1 and condition &2'
host echo ' '
host echo ' '
host echo ' ......... Working ......... '
host echo ' '
host echo ' '

spool ./gen_dat.wrk

DECLARE

-- TO MODIFY

Separator VARCHAR2(1) := CHR(29);
DateFormat VARCHAR2(20) := 'YYYYMMDD HHMISS';

CURSOR UserTabColumns_cursor ( TableName IN VARCHAR2 )
IS
SELECT
COLUMN_ID,
COLUMN_NAME,
DATA_TYPE,
DATA_LENGTH
FROM USER_TAB_COLUMNS
WHERE TABLE_NAME = TableName ORDER BY COLUMN_ID;
recUserTabColumns UserTabColumns_cursor%ROWTYPE;

BEGIN

DBMS_OUTPUT.PUT_LINE('###QUERY###SET LINESIZE 8192');
DBMS_OUTPUT.PUT_LINE('###QUERY###SET PAGESIZE 0');
DBMS_OUTPUT.PUT_LINE('###QUERY###SET HEADING OFF');
DBMS_OUTPUT.PUT_LINE('###QUERY###SELECT ');

DBMS_OUTPUT.PUT_LINE('###CTRL###LOAD DATA');
DBMS_OUTPUT.PUT_LINE('###CTRL###INFILE ''./&1..dat''');
DBMS_OUTPUT.PUT_LINE('###CTRL###BADFILE ''./LOG/&1..bad''');
DBMS_OUTPUT.PUT_LINE('###CTRL###DISCARDFILE ''./LOG/&1..dsc''');
DBMS_OUTPUT.PUT_LINE('###CTRL###APPEND');
DBMS_OUTPUT.PUT_LINE('###CTRL###INTO TABLE &1');
DBMS_OUTPUT.PUT_LINE('###CTRL###FIELDS TERMINATED BY '''|| Separator || '''');
DBMS_OUTPUT.PUT_LINE('###CTRL###TRAILING NULLCOLS');
DBMS_OUTPUT.PUT_LINE('###CTRL###(');

OPEN UserTabColumns_cursor('&1');
LOOP
FETCH UserTabColumns_cursor INTO recUserTabColumns;
EXIT WHEN UserTabColumns_cursor%NOTFOUND;

IF recUserTabColumns.COLUMN_ID > 1 THEN
DBMS_OUTPUT.PUT_LINE('###QUERY###||''' || Separator || '''||');
DBMS_OUTPUT.PUT_LINE('###CTRL###,');
END IF;

IF recUserTabColumns.DATA_TYPE = 'DATE' THEN
DBMS_OUTPUT.PUT_LINE('###QUERY### to_char(' || recUserTabColumns.COLUMN_NAME || ',''' || DateFormat || ''')');
DBMS_OUTPUT.PUT_LINE('###CTRL###' || recUserTabColumns.COLUMN_NAME || ' DATE ' || '"' || DateFormat ||'"');
ELSIF recUserTabColumns.DATA_TYPE IN ('LONG RAW','LONG','RAW') THEN
DBMS_OUTPUT.PUT_LINE('###CTRL### ' || recUserTabColumns.COLUMN_NAME);
DBMS_OUTPUT.PUT_LINE('###QUERY### ''''');
ELSIF recUserTabColumns.DATA_TYPE in ('VARCHAR2','NVARCHAR2','NCHAR','CHAR') THEN
DBMS_OUTPUT.PUT_LINE('###QUERY### REPLACE(' || recUserTabColumns.COLUMN_NAME || ',CHR(10),'' '')');
DBMS_OUTPUT.PUT_LINE('###CTRL### ' || recUserTabColumns.COLUMN_NAME || ' CHAR(' || recUserTabColumns.DATA_LENGTH || ')');
ELSE
DBMS_OUTPUT.PUT_LINE('###QUERY### ' || recUserTabColumns.COLUMN_NAME);
DBMS_OUTPUT.PUT_LINE('###CTRL### ' || recUserTabColumns.COLUMN_NAME);
END IF;

END LOOP;
CLOSE UserTabColumns_cursor;
DBMS_OUTPUT.PUT_LINE('###QUERY###FROM &1 WHERE &2;');
DBMS_OUTPUT.PUT_LINE('###CTRL###)');

EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR(-20001,
'Oracle Error MSG: >' || SQLERRM(SQLCODE) || '<');
END;
/
spool off

host grep "###QUERY###" ./gen_dat.wrk > ./gen_dat.wrk2
host sed -e "s/###QUERY###//" -e "s/ *$//" ./gen_dat.wrk2 > ./gen_dat.sql
host grep "###CTRL###" ./gen_dat.wrk > ./gen_dat.wrk2
host sed -e "s/###CTRL###//" -e "s/ *$//" ./gen_dat.wrk2 > ./&1..ctl

spool ./gen_dat.wrk
@./gen_dat.sql
spool off

host sed -e "s/ *$//" ./gen_dat.wrk > ./&1..dat

--host rm -fr ./gen_dat.wrk
--host rm -fr ./gen_dat.wrk2
--host rm -fr ./gen_dat.sql

host echo ' '
host echo ' '
host echo ' End Generacion sqlloader files for table &1 and codition &2 '
host echo ' '
host echo ' sqlldr userid=user/password control=./&1..ctl log=./&1..log'
host echo ' '
host echo ' '
quit;

Stay tuned.

lunedì 18 luglio 2011

A good link for ksh shell scripting .....

Today i want share an interesting Ksh shell scripting link :


My problem is divide, in a shell script, file name from path.

Solutions was this :

file="/CLASS_09/CPP/INPUT/A8/pippo"
filename=${file##*/}
dirname=${file%/*}

echo $filename
echo $dirname

Stay tuned.



lunedì 10 gennaio 2011

New Year

This 2011 starts with changes and news :
  • Home's Change
  • New Argentinean's Projects
In this new year I would like to achieve the following objectives:
  • Improve my English Level
  • Improve my Chess Level
  • Improve my incomes
  • Be a better Christian
  • Learn at least two new programming languages
I hope to achieve at least half of these objectives.

Stay Tuned.




lunedì 22 novembre 2010

UPDATE TABLE A FROM TABLE B IN ORACLE

Hi all

A little big problem, i always forget in oracle how to do an update on a table from data on another table, so i fix it in my blog :

update table1
set field = (
select field
from table2
where table2.id = table1.id
);

Stay tuned.



mercoledì 17 novembre 2010

SP-552 oracle bind variable not declared

Hi all,

About this error we have lost many time. I hope this post can help someone.
My script sql is :


set verify off

set heading off

set linesize 400

spool RIL_388_OP_INS_AnagD4

COLUMN indGruppoiInG NEW_VALUE indGruppoiInG

SELECT max(substr(nome_elemento_associazione,4,4))+1 indGruppoiInG FROM SCTELEM_ASSOC WHERE TIPO_ASSOCIAZIONE = 'GRUPPI_IN' AND NOME_ELEMENTO_ASSOCIAZIONE LIK
E 'GIG%';

SELECT '@INFO AGGIUNTO GRUPPO IN ' || 'GIG' || lpad(to_char(&indGruppoiInG),4,'0') || ' IN CATEGORIA LA UNDELIVERED SERV >' || 'CATG0010' || '<' from dual; COLUMN indGruppoiInG NEW_VALUE indGruppoiInG SELECT max(substr(nome_elemento_associazione,4,4))+1 indGruppoiInG FROM SCTELEM_ASSOC WHERE TIPO_ASSOCIAZIONE = 'GRUPPI_IN' AND NOME_ELEMENTO_ASSOCIAZIONE LIK E 'GIG%'; SELECT '@INFO AGGIUNTO GRUPPO IN ' || 'GIG' || lpad(to_char(&indGruppoiInG),4,'0') || ' IN CATEGORIA LA UNDELIVERED SERV >' || 'CATG0010' || '<' from dual;


spool off


When we have executed this script alone it was OK. But when it was executed after another script, was showed this error :

SP-552 oracle bind variable "indGruppoiInG" not declared

After many controls we have discovered that a previously script seated "set define #", this command (see this link causes previously error.
Solution for this error was put at beginning my script sql, this command :

set define on

To avoid previously different define setting.

Stay tuned.

Best Free AI Video Mobile Apps

Hi all Today a simple ai post (generated by ChatGPT) about best AI Video mobile Apps : 🎬 The Best Free AI Video Mobile Apps You Should Try...