How to drop a function that is a part of a module? - db2

I'm using the DB2 10.1 fixpack 1 Enterprise Edition on Linux.
I would like to drop function
I checked if the function exists with:
select * from syscat.functions where funcschema = 'TEST' and funcname = 'REC1'
and have got the output:
ROUTINESCHEMA ROUTINEMODULENAME ROUTINENAME ROUTINETYPE OWNER OWNERTYPE SPECIFICNAME ROUTINEID ROUTINEMODULEID RETURN_TYPESCHEMA RETURN_TYPEMODULE RETURN_TYPENAME ORIGIN FUNCTIONTYPE PARM_COUNT LANGUAGE DIALECT SOURCESCHEMA SOURCESPECIFIC PUBLISHED DETERMINISTIC EXTERNAL_ACTION NULLCALL CAST_FUNCTION ASSIGN_FUNCTION SCRATCHPAD SCRATCHPAD_LENGTH FINALCALL PARALLEL PARAMETER_STYLE FENCED SQL_DATA_ACCESS DBINFO PROGRAMTYPE COMMIT_ON_RETURN AUTONOMOUS RESULT_SETS SPEC_REG FEDERATED THREADSAFE VALID MODULEROUTINEIMPLEMENTED METHODIMPLEMENTED METHODEFFECT TYPE_PRESERVING WITH_FUNC_ACCESS OVERRIDDEN_METHODID SUBJECT_TYPESCHEMA SUBJECT_TYPENAME CLASS JAR_ID JARSCHEMA JAR_SIGNATURE CREATE_TIME ALTER_TIME FUNC_PATH QUALIFIER IOS_PER_INVOC INSTS_PER_INVOC IOS_PER_ARGBYTE INSTS_PER_ARGBYTE PERCENT_ARGBYTES INITIAL_IOS INITIAL_INSTS CARDINALITY SELECTIVITY RESULT_COLS IMPLEMENTATION LIB_ID TEXT_BODY_OFFSET TEXT NEWSAVEPOINTLEVEL DEBUG_MODE TRACE_LEVEL DIAGNOSTIC_LEVEL CHECKOUT_USERID PRECOMPILE_OPTIONS COMPILE_OPTIONS EXECUTION_CONTROL CODEPAGE COLLATIONSCHEMA COLLATIONNAME COLLATIONSCHEMA_ORDERBY COLLATIONNAME_ORDERBY ENCODING_SCHEME LAST_REGEN_TIME INHERITLOCKREQUEST DEFINER SECURE REMARKS
------------- ----------------- ----------- ----------- ----- --------- ------------------ ----------- --------------- ----------------- ----------------- --------------- ------ ------------ ---------- -------- ---------- ------------ -------------- --------- ------------- --------------- -------- ------------- --------------- ---------- ----------------- --------- -------- --------------- ------ --------------- ------ ----------- ---------------- ---------- ----------- -------- --------- ---------- ----- ------------------------ ----------------- ------------ --------------- ---------------- ------------------- ------------------ ---------------- ----- ------ --------- ------------- -------------------------- -------------------------- --------- --------- ------------------------ ------------------------ ------------------------ ------------------------ ---------------- ------------------------ ------------------------ -------------------- ------------------------ ----------- -------------- ----------- ---------------- ---- ----------------- ---------- ----------- ---------------- --------------- ------------------ --------------- ----------------- -------- --------------- ------------- ----------------------- --------------------- --------------- -------------------------- ------------------ ------- ------ -------
TEST IZPISI REC1 F XXXXX U SQL151024081854400 74258 19 TEST IZPISI REC1 S S 1 - - Y Y Y 0 S 0 Y - - - - - - - 2015-10-24-08.18.54.372090 2015-10-24-08.18.54.372090 - TEST -1,00000000000000E+000 -1,00000000000000E+000 -1,00000000000000E+000 -1,00000000000000E+000 -1 -1,00000000000000E+000 -1,00000000000000E+000 -1 -1,00000000000000E+000 1 - - -1 - 0 0 - - - 912 SYSIBM UNIQUE SYSIBM UNIQUE 2015-10-24-08.18.54.372090 XXXXX Y -
I tried to drop a function with:
drop function TEST.REC1
And I got the error:
SQL0204N "TEST.REC1" is an undefined name. SQLSTATE=42704
How to drop this function?

Try
ALTER MODULE IZPISI DROP FUNCTION TEST.REC1
https://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.5.0/com.ibm.db2.luw.sql.ref.doc/doc/r0054778.html

Related

PostgreSQL set_config and set behave differently

select current_setting('my.session_id');
current_setting
-----------------
14
(1 row)
select set_config ( 'my.session_id', 15::text , true) ;
set_config
------------
15
(1 row)
select current_setting('my.session_id');
current_setting
-----------------
14
(1 row)
set my.session_id = 15;
SET
select current_setting('my.session_id');
current_setting
-----------------
15
(1 row)
As seen above, SET is working, but set_config is behaving slightly differently. Probably I am missing something.
set my.session_id = 14;
select current_setting('my.session_id');
current_setting
-----------------
14
(1 row)
select set_config ( 'my.session_id', 15::text , false) ;
set_config
------------
15
(1 row)
select current_setting('my.session_id');
current_setting
-----------------
15
(1 row)
as per manual:
Sets the parameter setting_name to new_value, and returns that value. If is_local is true, the new value will only apply during the
current transaction. If you want the new value to apply for the rest of the current session, use false instead.

How to make a postgres query run faster?

I have following tables with Table1 with rows: >25million rows
Table1:
chrom strand ref_base alt_base pos gene_ensembl_identifier seq_window_9mers mutated_base seq_window_mut_9mers
----- ------ -------- -------- -------- ----------------------- ----------------- ------------ --------------------
3 1 C T 40457498 ENSG00000168032 ACGCTCTACACACACAG A ACGCTCTAAACACACAG
Table2
seq_window_mut_9mers start substring
-------------------- ----- ---------
ACGCTCTAAACACACAG 1 ACGCTCTAA
ACGCTCTAAACACACAG 2 CGCTCTAAA
ACGCTCTAAACACACAG 3 GCTCTAAAC
ACGCTCTAAACACACAG 4 CTCTAAACA
ACGCTCTAAACACACAG 5 TCTAAACAC
ACGCTCTAAACACACAG 6 CTAAACACA
ACGCTCTAAACACACAG 7 TAAACACAC
ACGCTCTAAACACACAG 8 AAACACACA
ACGCTCTAAACACACAG 9 AACACACAG
I would like to perform a join to have the following table on column seq_window_mut_9mers.
final_table
chrom strand ref_base alt_base pos gene_ensembl_identifier seq_window_mut_9mers substring
----- ------ -------- -------- -------- ----------------------- ----------------- ------------ --------------------
3 1 C T 40457498 ENSG00000168032 ACGCTCTAAACACACAG ACGCTCTAA
3 1 C T 40457498 ENSG00000168032 ACGCTCTAAACACACAG CGCTCTAAA
3 1 C T 40457498 ENSG00000168032 ACGCTCTAAACACACAG GCTCTAAAC
3 1 C T 40457498 ENSG00000168032 ACGCTCTAAACACACAG CTCTAAACA
3 1 C T 40457498 ENSG00000168032 ACGCTCTAAACACACAG TCTAAACAC
3 1 C T 40457498 ENSG00000168032 ACGCTCTAAACACACAG CTAAACACA
3 1 C T 40457498 ENSG00000168032 ACGCTCTAAACACACAG TAAACACAC
3 1 C T 40457498 ENSG00000168032 ACGCTCTAAACACACAG AAACACACA
3 1 C T 40457498 ENSG00000168032 ACGCTCTAAACACACAG AACACACAG
I am running following postgres query through dbvisualizer. At the moment, the query is running very slow (still waiting for the output.. >10 mins).
SELECT
chrom, strand, ref_base, alt_base, pos, gene_ensembl_identifier, mut.seq_window_mut_9mers substring
FROM table1
LEFT JOIN table2 ON mer9.seq_window_mut_9mers = table1.seq_window_mut_9mers;
How can I make it run faster? Any suggestions will be really helful.
Thanks
It looks like you don't really need to join with table2. You can generate it on the fly with substring function, like this:
select
table1.*,
offsets.start,
substring(seq_window_mut_9mers from offsets.start for 9) as substring
from
table1,
(select generate_series(1,9) as start) as offsets;
It will be much faster that a join.

Oracle 12c performance issue

I have some performance issue when querying on dictionary views. When using RULE hint the query is very fast. What can be the problem ? I have optimizer_mode=RULE in init.ora. Oracle 12.1.0.2.0 with p26635880_121020_Linux-x86-64.zip patch applied
SQL> SET TIMING ON;
SQL>
SQL> select /*+ RULE */
2 *
3 from
4 v$locked_object lo,
5 all_objects ao,
6 v$lock ll
7 where
8 lo.object_id = ao.object_id
9 and lo.xidsqn = ll.id2
10 and ao.data_object_id = dbms_rowid.rowid_object('AAAgW6AACAAM7UiAAA');
XIDUSN XIDSLOT XIDSQN OBJECT_ID SESSION_ID ORACLE_USERNAME OS_USER_NAME PROCESS LOCKED_MODE CON_ID OWNER OBJECT_NAME SUBOBJECT_NAME OBJECT_ID DATA_OBJECT_ID OBJECT_TYPE CREATED LAST_DDL_TIME TIMESTAMP STATUS TEMPORARY GENERATED SECONDARY NAMESPACE EDITION_NAME SHARING EDITIONABLE ORACLE_MAINTAINED ADDR KADDR SID TYPE ID1 ID2 LMODE REQUEST CTIME BLOCK CON_ID
---------- ---------- ---------- ---------- ---------- ------------------------------ ------------------------------ ------------------------ ----------- ---------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- ---------- -------------- ----------------------- ----------- ------------- ------------------- ------- --------- --------- --------- ---------- -------------------------------------------------------------------------------- ------------- ----------- ----------------- ---------------- ---------------- ---------- ---- ---------- ---------- ---------- ---------- ---------- ---------- ----------
Executed in 0,766 seconds
SQL>
SQL> select
2 *
3 from
4 v$locked_object lo,
5 all_objects ao,
6 v$lock ll
7 where
8 lo.object_id = ao.object_id
9 and lo.xidsqn = ll.id2
10 and ao.data_object_id = dbms_rowid.rowid_object('AAAgW6AACAAM7UiAAA');
XIDUSN XIDSLOT XIDSQN OBJECT_ID SESSION_ID ORACLE_USERNAME OS_USER_NAME PROCESS LOCKED_MODE CON_ID OWNER OBJECT_NAME SUBOBJECT_NAME OBJECT_ID DATA_OBJECT_ID OBJECT_TYPE CREATED LAST_DDL_TIME TIMESTAMP STATUS TEMPORARY GENERATED SECONDARY NAMESPACE EDITION_NAME SHARING EDITIONABLE ORACLE_MAINTAINED ADDR KADDR SID TYPE ID1 ID2 LMODE REQUEST CTIME BLOCK CON_ID
---------- ---------- ---------- ---------- ---------- ------------------------------ ------------------------------ ------------------------ ----------- ---------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- ---------- -------------- ----------------------- ----------- ------------- ------------------- ------- --------- --------- --------- ---------- -------------------------------------------------------------------------------- ------------- ----------- ----------------- ---------------- ---------------- ---------- ---- ---------- ---------- ---------- ---------- ---------- ---------- ----------
Executed in 83,39 seconds
SQL>
optimizer_adaptive_plans TRUE
optimizer_adaptive_statistics FALSE
db_file_multiblock_read_count 128
optimizer_features_enable 12.1.0.2
optimizer_mode RULE
optimizer_index_cost_adj 100
pga_aggregate_target 13474201600
workarea_size_policy AUTO
optimizer_dynamic_sampling 0
_optimizer_aggr_groupby_elim FALSE
optimizer_adaptive_reporting_only TRUE
optimizer_adaptive_features TRUE
_optimizer_reduce_groupby_key FALSE
13 rows selected
Executed in 0,156 seconds
SQL>

Extracting each line from a text after a certain character and extract the result to a table using postgres

I have a text looking like this:
>Sequenz: Test 1
MTEITAAMVKELRESTGAGMMDCKNALSETNGDFDKAVQLLREKGLGKAAKKADRLAAEG
>Sequenz 2 1234 Organism: Treponema
MTEITAAMVKELRESTGAGMMDCKNALSETNGDFDKAVQLLREKGLGKAAKKADRLAAEG
>Sequenz 3
MTEITAAMVKELRESTGAGMMDCKNALSETNGDFDKAVQLLREKGLGKAAKKADRLAAEG
There is not necessarily a blank line between the text chunks and it might be a various number of lines of 'MTEITAAMVKELRESTGAGM'. The only thing, which is known for sure is a > before each line.
I want resulting in a table like this:
HEADER
----------
Sequenz: Test 1
----------
Sequenz 2 1234 Organism: Treponema
----------
Sequenz 3
I tried:
SELECT regexp_matches(regexp_split_to_table( 'text from above', '\n>'),'([A-Z,a-z,0-9]+\s)');
resulting in
HEADER
----------
Sequenz
----------
Sequenz
----------
Sequenz
and
Select regexp_split_to_table('text from bove', '[\\\n>+(.)\\\n]+')
resulting in
HEADER
----------
----------
Sequenz: Test 1
----------
MTEITAAMVKELRESTGAGMMDCKNALSETNGDFDKAVQLLREKGLGKAAKKADRLAAEG
----------
----------
Sequenz 2 1234 Organism: Treponema
----------
MTEITAAMVKELRESTGAGMMDCKNALSETNGDFDKAVQLLREKGLGKAAKKADRLAAEG
----------
----------
Sequenz 3
----------
MTEITAAMVKELRESTGAGMMDCKNALSETNGDFDKAVQLLREKGLGKAAKKADRLAAEG
Try this:
SELECT split_part(regexp_split_to_table(trim(leading '>' from '>Sequenz: Test 1
MTEITAAMVKELRESTGAGMMDCKNALSETNGDFDKAVQLLREKGLGKAAKKADRLAAEG
>Sequenz 2 1234 Organism: Treponema
MTEITAAMVKELRESTGAGMMDCKNALSETNGDFDKAVQLLREKGLGKAAKKADRLAAEG
>Sequenz 3
MTEITAAMVKELRESTGAGMMDCKNALSETNGDFDKAVQLLREKGLGKAAKKADRLAAEG'), E'>'),E'\n', 1) AS res
Remove trim() function if you want to keep first empty row.
Demo: http://rextester.com/LQXY98290

Connecting oracle through Batch

I am trying to connect to oracle and execute one query
I have created abc.BAT
#ECHO off
sqlplus -S scott/tiger#orcl
ECHO SPOOL text.out
select * from emp;
ECHO SPOOL OFF
But i am not able to get any output when i execute abc.bat ,Whats wrong in this?
I suspect that you want to separate the SQL*Plus commands from the BAT file.
For example, if you create a SQL*Plus script (abc.sql)
C:\Users\jcave>type abc.sql
spool text.out;
select * from emp;
spool off;
exit;
And then create a batch file that calls SQL*Plus and passes in the SQL*Plus script you just created (abc.bat)
C:\Users\jcave>type abc.bat
sqlplus scott/tiger #abc.sql
Then when you invoke the BAT file, you'll get the output you want
C:\Users\jcave>abc.bat
C:\Users\jcave>sqlplus scott/tiger #abc.sql
SQL*Plus: Release 11.2.0.1.0 Production on Tue Jan 24 14:37:17 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7369 SMITH CLERK 7902 17-DEC-80 801
20
7499 ALLEN SALESMAN 7698 20-FEB-81 1601 300
30
7521 WARD SALESMAN 7698 22-FEB-81 1251 500
30
EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7566 JONES MANAGER 7839 02-APR-81 2976
20
7654 MARTIN SALESMAN 7698 28-SEP-81 1251 1400
30
7698 BLAKE MANAGER 7839 01-MAY-81 2851
30
EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7782 CLARK MANAGER 7839 09-JUN-81 2451
10
7788 SCOTT ANALYST 7566 19-APR-87 3001
20
7839 KING PRESIDENT 17-NOV-81 5001
10
EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7844 TURNER SALESMAN 7698 08-SEP-81 1501 0
30
7876 ADAMS CLERK 7788 23-MAY-87 1101
20
7900 JAMES CLERK 7698 03-DEC-81 951
30
EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7902 FORD ANALYST 7566 03-DEC-81 3001
20
7934 MILLER CLERK 7782 23-JAN-82 1301
10
14 rows selected.
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
C:\Users\jcave>type text.out
EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7369 SMITH CLERK 7902 17-DEC-80 801
20
7499 ALLEN SALESMAN 7698 20-FEB-81 1601 300
30
7521 WARD SALESMAN 7698 22-FEB-81 1251 500
30
EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7566 JONES MANAGER 7839 02-APR-81 2976
20
7654 MARTIN SALESMAN 7698 28-SEP-81 1251 1400
30
7698 BLAKE MANAGER 7839 01-MAY-81 2851
30
EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7782 CLARK MANAGER 7839 09-JUN-81 2451
10
7788 SCOTT ANALYST 7566 19-APR-87 3001
20
7839 KING PRESIDENT 17-NOV-81 5001
10
EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7844 TURNER SALESMAN 7698 08-SEP-81 1501 0
30
7876 ADAMS CLERK 7788 23-MAY-87 1101
20
7900 JAMES CLERK 7698 03-DEC-81 951
30
EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7902 FORD ANALYST 7566 03-DEC-81 3001
20
7934 MILLER CLERK 7782 23-JAN-82 1301
10
14 rows selected.