Manipulating strings using SQL - a interesting problem
HelloI came across this problem, but have not been able to find a solution yet.
If an input string, the output must be a string with all the double quotes ("") replaced by two quotation marks (""). In addition, if a double quotation mark is preceded by a number (s) then the output must be a string where the number is enclosed in quotation marks.
Should be a SQL solution only (no calls to functions allowed). Preferably without using CASE or DECODING.
What are the different ways to do this?
1 abc'd is expected to produce abc' "d as output.
2 ab 'c' d is expected to produce ab "" c"" d as output
3 abc "d12" is expected to produce abc "" d"12" as output
4 ab12 "c34" should produce ab '12' c '34' output
That's what I've done so far, but it does not work for the fourth case above. I know that there must be a more elegant and correct solution.
SELECT REGEXP_REPLACE(REPLACE('&test_string', '"', '""'),
'[0-9]{1,}""',
'"' || REGEXP_SUBSTR(REPLACE('&test_string', '"', '""'),
'[0-9]{1,}"'))
FROM DUAL
PS: I'll keep the post updated with my attempts.Kind regards
Ousseni
>
Would you like to if the entry is
a '12' 3 "4B".a"""12" "3"4B ".
And that's exactly what you get with my solution (see the last line):
{code}
with mydata as
(
Select "abc" test_string of all the double union
Select "ab"c"d" test_string of all the double union
Select 'abc 'd12' ' test_string of all the double union
Select "ab12"c34"" test_string of all the double union
Select ' a '12' 3 "4 b ' double test_string"
)
SELECT REGEXP_REPLACE (REPLACE (test_string, ' "'," "" ""),)
"([0-9]_{1,})" "", '"\1" ') output
OF mydata;
OUTPUT
-----------------
ABC"d «»
AB "" c"" d
ABC '"d" 12 ".
AB c '12' "34".
a"""12" "3"4B ".
Regards.
Al
Tags: Database
Similar Questions
-
Manipulating strings using regular expressions
Hello guys,.
I stuck in a situation in which I want to extract specific data from a column of the table.
Here are the values for a particular column in which I want to ignore the values as well as support in the support and who are as .pdf, .doc.
TRIS (dibenzylideneacetone) dipalladium (0) 451CDHA.pdf
AM57001A (ASRM549CDH). DOC
Identity sulfate AM23021A (project)
PG-1183. E.2 (0.25 mg CTF)
AS149656A (DEV APPL AERO WHT PROVENTIL HFA)
Report on the stability (ISR) annex.2 semi-solid form (internal information)
TSE(batch#USLF000332)-242CDH, Lancaster synthesis.pdf
Additive TR3018520A 1 (REF 3018520)
AM10311A Particle size airjet by sieving (constant sieving) (project)
ASE00099B additive (REF E000099) mesh 90
Palladium AM37101_312-99 (Z11c) by DCP.doc
PS21001A_1H - NMR.doc (PN 332-00)
AM68311A (Q - a CP 33021.02) attachment
Attachment AM68202-1 has (BioReliance No. 02.102006)
I want below output to above the values for the column
Trisdipalladium451CDHA
AM57001A
Identity AM23021A sulfate
PG-1183. E.2
...
..
.
Thanks in advance
Like this?
SQL> with t 2 as 3 ( 4 select 'Tris(dibenzylideneacetone)dipalladium (0) 451CDHA.pdf' str from dual 5 union all 6 select 'AM57001A(ASRM549CDH).DOC' str from dual 7 union all 8 select 'AM23021A Identity of sulfate (draft)' str from dual 9 union all 10 select 'PG-1183.E.2 (0.25 mg FCT)' str from dual 11 union all 12 select 'AS149656A (DEV AERO APPL HFA WHT PROVENTIL)' str from dual 13 union all 14 select 'Stability report (RSR) Annex2 semi-solid form (internal information)' str from dual 15 union all 16 select 'TSE(Batch#USLF000332)-242CDH, Lancaster synthesis.pdf' str from dual 17 union all 18 select 'TR3018520A Addendum 1 (PN 3018520)' str from dual 19 union all 20 select 'AM10311A Particle size air-jet sieving (constant sieving) (draft)' str from dual 21 union all 22 select 'ASE00099B Addendum (PN E000099) 90 mesh' str from dual 23 union all 24 select 'AM37101_312-99 (Z11c) Palladium by DCP.doc' str from dual 25 union all 26 select 'PS21001A_1H-NMR.doc (PN 332-00)' str from dual 27 union all 28 select 'AM68311A (Q-One CP 33021.02) Attachment' str from dual 29 union all 30 select 'AM68202-1A (BioReliance no. 02.102006) Attachment' str from dual 31 ) 32 select str 33 , regexp_replace(str, '(\([^)]+\))|(\..{3})') str_new 34 from t; STR STR_NEW---------------------------------------------------------------------- --------------------------------------Tris(dibenzylideneacetone)dipalladium (0) 451CDHA.pdf Trisdipalladium 451CDHAAM57001A(ASRM549CDH).DOC AM57001AAM23021A Identity of sulfate (draft) AM23021A Identity of sulfatePG-1183.E.2 (0.25 mg FCT) PG-1183AS149656A (DEV AERO APPL HFA WHT PROVENTIL) AS149656AStability report (RSR) Annex2 semi-solid form (internal information) Stability report Annex2 semi-solid formTSE(Batch#USLF000332)-242CDH, Lancaster synthesis.pdf TSE-242CDH, Lancaster synthesisTR3018520A Addendum 1 (PN 3018520) TR3018520A Addendum 1AM10311A Particle size air-jet sieving (constant sieving) (draft) AM10311A Particle size air-jet sievingASE00099B Addendum (PN E000099) 90 mesh ASE00099B Addendum 90 meshAM37101_312-99 (Z11c) Palladium by DCP.doc AM37101_312-99 Palladium by DCPPS21001A_1H-NMR.doc (PN 332-00) PS21001A_1H-NMRAM68311A (Q-One CP 33021.02) Attachment AM68311A AttachmentAM68202-1A (BioReliance no. 02.102006) Attachment AM68202-1A Attachment 14 rows selected.
-
Problem with migration SQL Server Oracle 11.2 2012 DB using SQL Developer Migration workbench
Hello
I have a problem when migrating SQL Server Oracle 11.2 2012 using SQL Developer Migration workbench, hope that someone had the same problem before and can give same advide...
I use SQL Developer Version 4.0.1.14 and Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0. and last jtds - 1.3.
I created the schema migration_repo, privileges, connected to the third part of Db (SQL Server) and begin a trial with assistant. In the first step of the model to Capture, I get the message from the:
"Company Capture Capture failed. Refer to the table MIGRLOG in the repository for more details ".
But MIGRLOG is empty.
Here is my log:
<? XML version = "1.0" encoding = "windows-1252" standalone = 'no '? >
< Log >
account <>
< date > 2014-03-16T 20: 49:17 < / date >
oracle.dbtools.migration.workbench.core.MigrationLogResourceBundle < recorder > < / recorder >
< level > SEVERE < / level >
oracle.dbtools.migration.workbench.core.logging.MigrationLogUtil < class > < / class >
< message > Capture
Capture Enterprise
Capture failure. Refer to the MIGRLOG table in the repository for more details < / message >
oracle.dbtools.migration.workbench.core.ui.FullMigrateTask.doOnlineEnterpriseCapture(FullMigrateTask.java:758) < param > < / param >
oracle.dbtools.migration.workbench.core.ui.FullMigrateTask.doCapture(FullMigrateTask.java:601) < param > < / param >
oracle.dbtools.migration.workbench.core.ui.FullMigrateTask.doMaskBasedActions(FullMigrateTask.java:400) < param > < / param >
oracle.dbtools.migration.workbench.core.ui.FullMigrateTask.doWork(FullMigrateTask.java:314) < param > < / param >
oracle.dbtools.migration.workbench.core.ui.FullMigrateTask.doWork(FullMigrateTask.java:147) < param > < / param >
oracle.dbtools.raptor.backgroundTask.RaptorTask.call(RaptorTask.java:193) < param > < / param >
java.util.concurrent.FutureTask.run(FutureTask.java:262) < param > < / param >
oracle.dbtools.raptor.backgroundTask.RaptorTaskManager$ (RaptorTaskManager.java:554) < param > RaptorFutureTask.run < / param >
java.util.concurrent.Executors$ (Executors.java:471) < param > RunnableAdapter.call < / param >
java.util.concurrent.FutureTask.run(FutureTask.java:262) < param > < / param >
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) < param > < / param >
java.util.concurrent.ThreadPoolExecutor$ Worker.run (ThreadPoolExecutor.java:615) < param > < / param >
java.lang.Thread.run(Thread.java:744) < param > < / param >
oracle.dbtools.migration.workbench.core.logging.LogInfo@68e69a < param > < / param >
< exception >
< message > oracle.dbtools.migration.workbench.core.ui.FullMigrateTask$ FullMigrateTaskException: Capture
Capture Enterprise
Capture failure. Refer to the MIGRLOG table in the repository for more details < / message >
< frame >
oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >
< line > 758 < / line >
< / framework >
< frame >
oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >
< line > 601 < / line >
< / framework >
< frame >
oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >
line 400 > of < < / line >
< / framework >
< frame >
oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >
< line > 314 < / line >
< / framework >
< frame >
oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >
< line > 147 < / line >
< / framework >
< frame >
oracle.dbtools.raptor.backgroundTask.RaptorTask < class > < / class >
< line > 193 < / line >
< / framework >
< frame >
java.util.concurrent.FutureTask < class > < / class >
< line > 262 < / line >
< / framework >
< frame >
oracle.dbtools.raptor.backgroundTask.RaptorTaskManager$ RaptorFutureTask < class > < / class >
< line > 554 < / line >
< / framework >
< frame >
java.util.concurrent.Executors$ RunnableAdapter < class > < / class >
< line > 471 < / line >
< / framework >
< frame >
java.util.concurrent.FutureTask < class > < / class >
< line > 262 < / line >
< / framework >
< frame >
java.util.concurrent.ThreadPoolExecutor < class > < / class >
< line > 1145 < / line >
< / framework >
< frame >
java.util.concurrent.ThreadPoolExecutor$ Worker < class > < / class >
< line > 615 < / line >
< / framework >
< frame >
java.lang.Thread < class > < / class >
< line > 744 < / line >
< / framework >
< / exception >
< / recording >
account <>
< date > 2014-03-16T 20: 49:17 < / date >
oracle.dbtools.migration.workbench.core.MigrationLogResourceBundle < recorder > < / recorder >
WARNING < level > < / level >
oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >
<>error message: ORA-06550: line 1, column 14:
PLS-00201: identifier ' SS2K5ALLPLATFORM. STAGECAPTURE' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
: FAILED: Database Migration: FAILURE < / message >
oracle.dbtools.migration.workbench.core.logging.LogInfo@1e2c9b99 < param > < / param >
< / recording >
I try with model db (DB empty, just a single table), but the error is same. However, if I try to copy the acronym tabele from SQL Server to Oracle it works fine...
I guess it's something with the configuration, but beacause I am new in Oracle still have no idea...
Any help would be much appreciated
I thank in advance
Stefan
Hello Stefan,
did you create the repository Migration of your database to Oracle (Tools-> Migration-> repository management)?
The SS2K5ALLPLATFORM package is usually created when you add the migration of the Oracle database repository and it contains the function StageCapture.
So please make sure that you have created a repository of migration in an Oracle database and associate it with the first step of your migration.
-Klaus
-
interesting SQL and plsql problem.
The web application has a function to generate reports based on what the user selects, which includes this as the fields to display in the report, what order to display those selected fields, etc.
Now, one of the field called suffix field is need removed the drop-down lists SELECT and ORDER BY. Please advise on how to solve the problem when the suffix record is removed from the database, and how we can increase the index [#] of these later OrderByField?
reportId reportField reportValue
====================
1 orderByField fname [0]
1 orderByField [1] MI
1 lname orderBytField [2]
1 orderByField [3] suffix
lname orderBytField 2 [0]
suffix of orderByField 2 [1]
2 orderByField fname [2]
2 orderByField [3] MI
In the example above, delete suffix will not affect reportId 1, but for reportId 2, if we remove the suffix, how do we record like the following?
lname orderBytField 2 [0]
2 orderByField fname [1]
2 orderByField [2] MI
I am open to any suggestion, using sql and plsql. The database is 9i.
THX.Hello
You're wright, you need to replace in the order by clause:
with d as( select 1 as reportId, 'orderByField[0]' as reportField, 'fname ' as reportValue from dual union all select 1 as reportId, 'orderByField[1]' as reportField, 'MI ' as reportValue from dual union all select 1 as reportId, 'orderByField[2]'as reportField, 'lname ' as reportValue from dual union all select 1 as reportId, 'orderByField[3]' as reportField, 'suffix' as reportValue from dual union all select 2 as reportId, 'orderByField[1]' as reportField, 'suffix' as reportValue from dual union all select 2 as reportId, 'orderByField[2]' as reportField, 'fname2' as reportValue from dual union all select 2 as reportId, 'orderByField[0]'as reportField, 'lname0' as reportValue from dual union all select 2 as reportId, 'orderByField[6]'as reportField, 'lname6' as reportValue from dual union all select 2 as reportId, 'orderByField[12]'as reportField, 'lname12' as reportValue from dual union all select 2 as reportId, 'orderByField[4]'as reportField, 'lname4' as reportValue from dual union all select 2 as reportId, 'orderByField[5]'as reportField, 'lname5' as reportValue from dual union all select 2 as reportId, 'orderByField[8]'as reportField, 'lname8' as reportValue from dual union all select 2 as reportId, 'orderByField[10]'as reportField, 'lname10' as reportValue from dual union all select 2 as reportId, 'orderByField[11]'as reportField, 'lname11' as reportValue from dual union all select 2 as reportId, 'orderByField[9]'as reportField, 'lname9' as reportValue from dual union all select 2 as reportId, 'orderByField[7]'as reportField, 'lname7' as reportValue from dual union all select 2 as reportId, 'orderByField[3]' as reportField, 'MI ' as reportValue from dual) SELECT a.reportId, 'reportField[' || to_char(DECODE(ROWNUM-min_sno,0,1,rownum+1-min_sno)-1)|| ']' as newReportField, reportValue FROM (SELECT * FROM d where d.reportValue != 'suffix' ORDER BY reportId, to_number(substr(reportField, instr(reportField, '[')+1, instr(reportField,']')-instr(reportField, '[')-1)) ) a, ( SELECT reportId,MIN(rownum) min_sno FROM ( SELECT * FROM d where d.reportValue != 'suffix' ORDER BY reportId, to_number(substr(reportField, instr(reportField, '[')+1, instr(reportField,']')-instr(reportField, '[')-1)) ) GROUP BY reportId ) b WHERE a.reportId = b.reportId;
Kind regards
Published by: Walter Fernández on January 6, 2009 16:51 - sorry I forgot the version of your database in the first post, I replaced the regular expression...
-
Data capture, etc. using SQL Developer mysql Orac conversion problems
Hello
I have been using Sql Developer to try to convert my mysql database to oracle, I managed to set up the connections and the repository very well. However, when I right click on my database connection and click on the capture of the capture window appears but nothing happens. What I am doing wrong?
Thank you
AaronThis error usually indicates a corrupt repository of migration or a user privilege is missing.
Also the migration of SQL Developer 2 and 1 repository is not compatible - so I would say to create a single repository user for each new version.
It is a repository of sample for SQL Developer 2.x user:CREATE USER migration IDENTIFIED BY migration DEFAULT TABLESPACE users TEMPORARY TABLESPACE temp;
GRANT CONNECT, RESOURCE, CREATE VIEW, CREATE A PUBLIC SYNONYM TO
Migration WITH the ADMIN OPTION.GRANT ALTER ANY ROLE, ALTER ANY SEQUENCE, ALTER ANY TABLE, ALTER TABLESPACE, ALTER ANY TRIGGER, COMMENT ANY TABLE, CREATE ANY SEQUENCE, CREATE ANY TABLE, CREATE ANY TRIGGER, CREATE ROLE, CREATE TABLESPACE, CREATE USER, DROP ANY SEQUENCE, DROP ANY TABLE, DROP ANY TRIGGER, DROP TABLESPACE, DROP USER, DROP ANY ROLE, GRANT ANY ROLE, INSERT ANY TABLE, SELECT ANY TABLE UPDATE no matter WHAT TABLE OF migration;
-
interesting problem with sending e-mail
Hello world
I faced a very interesting problem. In the code below, I want to send a variable (w_data) with the html, but the recipient do not e-mail, but when I remove the part (w_data) "BOLD" and write a string like "Gauthier", the recipient takes this e-mail. What is the problem, why I can't send a varchar2?
DECLARE
v_from VARCHAR2 (80): = "[email protected]";
v_recipient VARCHAR2 (80): = "[email protected]";
v_subject VARCHAR2 (80): = "test subject";
v_mail_host VARCHAR2 (30): = "mail.ere.com.tr";
v_mail_conn UTL_SMTP.connection;
CRLF VARCHAR2 (2): = CHR (13) | CHR (10);
CURSOR cur_
IS
Select disconnect_cause in the rawticket_voip;
w_data VARCHAR2 (31000);
BEGIN
v_mail_conn: = UTL_SMTP.open_connection (v_mail_host, 25);
UTL_SMTP. HELO (v_mail_conn, v_mail_host);
UTL_SMTP.mail (v_mail_conn, v_from);
UTL_SMTP. RCPT (v_mail_conn, v_recipient);
w_data: = ' < html >
< table border = "1" >
< tr bgcolor = 'Light Blue' > ';
FOR C IN CUR_ LOOP
W_DATA: = W_DATA | "< td >" | C.DISCONNECT_CAUSE | "< table >";
END LOOP;
w_data: = w_data | ' < /tr >
< /table >
< / html > ';
UTL_SMTP. DATA
(v_mail_conn,
' Date: '
|| To_char (SYSDATE, ' Dy, hh24:mi:ss DD month YYYY ")
|| CRLF
|| "To:
|| v_from
|| CRLF
|| "Subject:"
|| v_subject
|| CRLF
|| « À : »
|| v_recipient
|| CRLF
|| "MIME-Version: 1.0 '"
|| CRLF
|| ' Content-Type: text/html; "charset ="us-ascii"
|| CRLF
|| w_data
|| CRLF
);
UTL_SMTP. Quit (v_mail_conn);
EXCEPTION
WHEN UTL_SMTP.transient_error OR UTL_SMTP.permanent_error
THEN
raise_application_error (-20000, "cannot send an email: ' |") SQLERRM);
END;
/Suggest that rather try next approach instead - the start_data() and close_data() calls.
SQL> declare 2 type TStrings is table of varchar2(1000); 3 4 smtpSender varchar2(100) := '[email protected]; 5 smtpRecipient varchar2(100) := '[email protected]; 6 mailSubject varchar2(100) := 'Sample Mail'; 7 smtpConn UTL_SMTP.connection; 8 9 cursor cur is 10 select 11 '
' 14 from user_objects 15 order by 16 object_id; 17 18 mailBody TStrings; 19 20 BEGIN 21 smtpConn := UTL_SMTP.open_connection( 'mail.telkom.co.za', 25); 22 23 UTL_SMTP.helo( smtpConn, 'myserver.somedomain.com' ); -- // this needs to be your Oracle server hostname or IP! 24 UTL_SMTP.mail( smtpConn, smtpSender ); 25 UTL_SMTP.rcpt( smtpConn, smtpRecipient ); 26 27 -- can be done using an implicit cursor instead 28 open cur; 29 fetch cur bulk collect into mailBody; 30 close cur; 31 32 -- start sending mail body using the data command 33 UTL_SMTP.open_data( smtpConn ); 34 35 -- write header 36 UTL_SMTP.write_data( smtpConn, 'MIME-Version: 1.0'||utl_tcp.CRLF ); 37 UTL_SMTP.write_data( smtpConn, 'Content-Type: text/html'||utl_tcp.CRLF ); 38 UTL_SMTP.write_data( smtpConn, 'From: '||smtpSender||utl_tcp.CRLF ); 39 UTL_SMTP.write_data( smtpConn, 'To: '||smtpRecipient||utl_tcp.CRLF ); 40 UTL_SMTP.write_data( smtpConn, 'Subject: '||mailSubject||utl_tcp.CRLF ); 41 42 -- empty line between header and rest of mail body 43 UTL_SMTP.write_data( smtpConn, utl_tcp.CRLF ); 44 45 -- now write the HTML 46 UTL_SMTP.write_data( smtpConn, ''||object_type||' '|| 12 object_id||' '||object_name|| 13 ' '||utl_tcp.CRLF ); 47 for i in 1..mailBody.Count 48 loop 49 UTL_SMTP.write_data( smtpConn, mailBody(i)||utl_tcp.CRLF ); 50 end loop; 51 UTL_SMTP.write_data( smtpConn, '
'||utl_tcp.CRLF ); 52 53 -- close the data command 54 UTL_SMTP.close_data( smtpConn ); 55 56 UTL_SMTP.quit( smtpConn ); 57 end; 58 / PL/SQL procedure successfully completed. SQL> -
Question to load data using sql loader in staging table, and then in the main tables!
Hello
I'm trying to load data into our main database table using SQL LOADER. data will be provided in separate pipes csv files.
I have develop a shell script to load the data and it works fine except one thing.
Here are the details of a data to re-create the problem.
Staging of the structure of the table in which data will be filled using sql loader
create table stg_cmts_data (cmts_token varchar2 (30), CMTS_IP varchar2 (20));
create table stg_link_data (dhcp_token varchar2 (30), cmts_to_add varchar2 (200));
create table stg_dhcp_data (dhcp_token varchar2 (30), DHCP_IP varchar2 (20));
DATA in the csv file-
for stg_cmts_data-
cmts_map_03092015_1.csv
WNLB-CMTS-01-1. 10.15.0.1
WNLB-CMTS-02-2 | 10.15.16.1
WNLB-CMTS-03-3. 10.15.48.1
WNLB-CMTS-04-4. 10.15.80.1
WNLB-CMTS-05-5. 10.15.96.1
for stg_dhcp_data-
dhcp_map_03092015_1.csv
DHCP-1-1-1. 10.25.23.10, 25.26.14.01
DHCP-1-1-2. 56.25.111.25, 100.25.2.01
DHCP-1-1-3. 25.255.3.01, 89.20.147.258
DHCP-1-1-4. 10.25.26.36, 200.32.58.69
DHCP-1-1-5 | 80.25.47.369, 60.258.14.10
for stg_link_data
cmts_dhcp_link_map_0309151623_1.csv
DHCP-1-1-1. WNLB-CMTS-01-1,WNLB-CMTS-02-2
DHCP-1-1-2. WNLB-CMTS-03-3,WNLB-CMTS-04-4,WNLB-CMTS-05-5
DHCP-1-1-3. WNLB-CMTS-01-1
DHCP-1-1-4. WNLB-CMTS-05-8,WNLB-CMTS-05-6,WNLB-CMTS-05-0,WNLB-CMTS-03-3
DHCP-1-1-5 | WNLB-CMTS-02-2,WNLB-CMTS-04-4,WNLB-CMTS-05-7
WNLB-DHCP-1-13 | WNLB-CMTS-02-2
Now, after loading these data in the staging of table I have to fill the main database table
create table subntwk (subntwk_nm varchar2 (20), subntwk_ip varchar2 (30));
create table link (link_nm varchar2 (50));
SQL scripts that I created to load data is like.
coil load_cmts.log
Set serveroutput on
DECLARE
CURSOR c_stg_cmts IS SELECT *.
OF stg_cmts_data;
TYPE t_stg_cmts IS TABLE OF stg_cmts_data % ROWTYPE INDEX BY pls_integer;
l_stg_cmts t_stg_cmts;
l_cmts_cnt NUMBER;
l_cnt NUMBER;
NUMBER of l_cnt_1;
BEGIN
OPEN c_stg_cmts.
Get the c_stg_cmts COLLECT in BULK IN l_stg_cmts;
BECAUSE me IN l_stg_cmts. FIRST... l_stg_cmts. LAST
LOOP
SELECT COUNT (1)
IN l_cmts_cnt
OF subntwk
WHERE subntwk_nm = l_stg_cmts (i) .cmts_token;
IF l_cmts_cnt < 1 THEN
INSERT
IN SUBNTWK
(
subntwk_nm
)
VALUES
(
l_stg_cmts (i) .cmts_token
);
DBMS_OUTPUT. Put_line ("token has been added: ' |") l_stg_cmts (i) .cmts_token);
ON THE OTHER
DBMS_OUTPUT. Put_line ("token is already present'");
END IF;
WHEN l_stg_cmts EXIT. COUNT = 0;
END LOOP;
commit;
EXCEPTION
WHILE OTHERS THEN
Dbms_output.put_line ('ERROR' |) SQLERRM);
END;
/
output
for dhcp
coil load_dhcp.log
Set serveroutput on
DECLARE
CURSOR c_stg_dhcp IS SELECT *.
OF stg_dhcp_data;
TYPE t_stg_dhcp IS TABLE OF stg_dhcp_data % ROWTYPE INDEX BY pls_integer;
l_stg_dhcp t_stg_dhcp;
l_dhcp_cnt NUMBER;
l_cnt NUMBER;
NUMBER of l_cnt_1;
BEGIN
OPEN c_stg_dhcp.
Get the c_stg_dhcp COLLECT in BULK IN l_stg_dhcp;
BECAUSE me IN l_stg_dhcp. FIRST... l_stg_dhcp. LAST
LOOP
SELECT COUNT (1)
IN l_dhcp_cnt
OF subntwk
WHERE subntwk_nm = l_stg_dhcp (i) .dhcp_token;
IF l_dhcp_cnt < 1 THEN
INSERT
IN SUBNTWK
(
subntwk_nm
)
VALUES
(
l_stg_dhcp (i) .dhcp_token
);
DBMS_OUTPUT. Put_line ("token has been added: ' |") l_stg_dhcp (i) .dhcp_token);
ON THE OTHER
DBMS_OUTPUT. Put_line ("token is already present'");
END IF;
WHEN l_stg_dhcp EXIT. COUNT = 0;
END LOOP;
commit;
EXCEPTION
WHILE OTHERS THEN
Dbms_output.put_line ('ERROR' |) SQLERRM);
END;
/
output
for link -.
coil load_link.log
Set serveroutput on
DECLARE
l_cmts_1 VARCHAR2 (4000 CHAR);
l_cmts_add VARCHAR2 (200 CHAR);
l_dhcp_cnt NUMBER;
l_cmts_cnt NUMBER;
l_link_cnt NUMBER;
l_add_link_nm VARCHAR2 (200 CHAR);
BEGIN
FOR (IN) r
SELECT dhcp_token, cmts_to_add | ',' cmts_add
OF stg_link_data
)
LOOP
l_cmts_1: = r.cmts_add;
l_cmts_add: = TRIM (SUBSTR (l_cmts_1, 1, INSTR (l_cmts_1, ',') - 1));
SELECT COUNT (1)
IN l_dhcp_cnt
OF subntwk
WHERE subntwk_nm = r.dhcp_token;
IF l_dhcp_cnt = 0 THEN
DBMS_OUTPUT. Put_line ("device not found: ' |") r.dhcp_token);
ON THE OTHER
While l_cmts_add IS NOT NULL
LOOP
l_add_link_nm: = r.dhcp_token |' _TO_' | l_cmts_add;
SELECT COUNT (1)
IN l_cmts_cnt
OF subntwk
WHERE subntwk_nm = TRIM (l_cmts_add);
SELECT COUNT (1)
IN l_link_cnt
LINK
WHERE link_nm = l_add_link_nm;
IF l_cmts_cnt > 0 AND l_link_cnt = 0 THEN
INSERT INTO link (link_nm)
VALUES (l_add_link_nm);
DBMS_OUTPUT. Put_line (l_add_link_nm |) » '||' Has been added. ") ;
ELSIF l_link_cnt > 0 THEN
DBMS_OUTPUT. Put_line (' link is already present: ' | l_add_link_nm);
ELSIF l_cmts_cnt = 0 then
DBMS_OUTPUT. Put_line (' no. CMTS FOUND for device to create the link: ' | l_cmts_add);
END IF;
l_cmts_1: = TRIM (SUBSTR (l_cmts_1, INSTR (l_cmts_1, ',') + 1));
l_cmts_add: = TRIM (SUBSTR (l_cmts_1, 1, INSTR (l_cmts_1, ',') - 1));
END LOOP;
END IF;
END LOOP;
COMMIT;
EXCEPTION
WHILE OTHERS THEN
Dbms_output.put_line ('ERROR' |) SQLERRM);
END;
/
output
control files -
DOWNLOAD THE DATA
INFILE 'cmts_data.csv '.
ADD
IN THE STG_CMTS_DATA TABLE
When (cmts_token! = ") AND (cmts_token! = 'NULL') AND (cmts_token! = 'null')
and (cmts_ip! = ") AND (cmts_ip! = 'NULL') AND (cmts_ip! = 'null')
FIELDS TERMINATED BY ' |' SURROUNDED OF POSSIBLY "" "
TRAILING NULLCOLS
('RTRIM (LTRIM (:cmts_token))' cmts_token,
cmts_ip ' RTRIM (LTRIM(:cmts_ip)) ")". "
for dhcp.
DOWNLOAD THE DATA
INFILE 'dhcp_data.csv '.
ADD
IN THE STG_DHCP_DATA TABLE
When (dhcp_token! = ") AND (dhcp_token! = 'NULL') AND (dhcp_token! = 'null')
and (dhcp_ip! = ") AND (dhcp_ip! = 'NULL') AND (dhcp_ip! = 'null')
FIELDS TERMINATED BY ' |' SURROUNDED OF POSSIBLY "" "
TRAILING NULLCOLS
('RTRIM (LTRIM (:dhcp_token))' dhcp_token,
dhcp_ip ' RTRIM (LTRIM(:dhcp_ip)) ")". "
for link -.
DOWNLOAD THE DATA
INFILE 'link_data.csv '.
ADD
IN THE STG_LINK_DATA TABLE
When (dhcp_token! = ") AND (dhcp_token! = 'NULL') AND (dhcp_token! = 'null')
and (cmts_to_add! = ") AND (cmts_to_add! = 'NULL') AND (cmts_to_add! = 'null')
FIELDS TERMINATED BY ' |' SURROUNDED OF POSSIBLY "" "
TRAILING NULLCOLS
('RTRIM (LTRIM (:dhcp_token))' dhcp_token,
cmts_to_add TANK (4000) RTRIM (LTRIM(:cmts_to_add)) ")" ""
SHELL SCRIPT-
If [!-d / log]
then
Mkdir log
FI
If [!-d / finished]
then
mkdir makes
FI
If [!-d / bad]
then
bad mkdir
FI
nohup time sqlldr username/password@SID CONTROL = load_cmts_data.ctl LOG = log/ldr_cmts_data.log = log/ldr_cmts_data.bad DISCARD log/ldr_cmts_data.reject ERRORS = BAD = 100000 LIVE = TRUE PARALLEL = TRUE &
nohup time username/password@SID @load_cmts.sql
nohup time sqlldr username/password@SID CONTROL = load_dhcp_data.ctl LOG = log/ldr_dhcp_data.log = log/ldr_dhcp_data.bad DISCARD log/ldr_dhcp_data.reject ERRORS = BAD = 100000 LIVE = TRUE PARALLEL = TRUE &
time nohup sqlplus username/password@SID @load_dhcp.sql
nohup time sqlldr username/password@SID CONTROL = load_link_data.ctl LOG = log/ldr_link_data.log = log/ldr_link_data.bad DISCARD log/ldr_link_data.reject ERRORS = BAD = 100000 LIVE = TRUE PARALLEL = TRUE &
time nohup sqlplus username/password@SID @load_link.sql
MV *.log. / log
If the problem I encounter is here for loading data in the link table that I check if DHCP is present in the subntwk table, then continue to another mistake of the newspaper. If CMTS then left create link to another error in the newspaper.
Now that we can here multiple CMTS are associated with unique DHCP.
So here in the table links to create the link, but for the last iteration of the loop, where I get separated by commas separate CMTS table stg_link_data it gives me log as not found CMTS.
for example
DHCP-1-1-1. WNLB-CMTS-01-1,WNLB-CMTS-02-2
Here, I guess to link the dhcp-1-1-1 with balancing-CMTS-01-1 and wnlb-CMTS-02-2
Theses all the data present in the subntwk table, but still it gives me journal wnlb-CMTS-02-2 could not be FOUND, but we have already loaded into the subntwk table.
same thing is happening with all the CMTS table stg_link_data who are in the last (I think here you got what I'm trying to explain).
But when I run the SQL scripts in the SQL Developer separately then it inserts all valid links in the table of links.
Here, she should create 9 lines in the table of links, whereas now he creates only 5 rows.
I use COMMIT in my script also but it only does not help me.
Run these scripts in your machine let me know if you also get the same behavior I get.
and please give me a solution I tried many thing from yesterday, but it's always the same.
It is the table of link log
link is already present: dhcp-1-1-1_TO_wnlb-cmts-01-1 NOT FOUND CMTS for device to create the link: wnlb-CMTS-02-2
link is already present: dhcp-1-1-2_TO_wnlb-cmts-03-3 link is already present: dhcp-1-1-2_TO_wnlb-cmts-04-4 NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-5
NOT FOUND CMTS for device to create the link: wnlb-CMTS-01-1
NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-8 NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-6 NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-0 NOT FOUND CMTS for device to create the link: wnlb-CMTS-03-3
link is already present: dhcp-1-1-5_TO_wnlb-cmts-02-2 link is already present: dhcp-1-1-5_TO_wnlb-cmts-04-4 NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-7
Device not found: wnlb-dhcp-1-13 IF NEED MORE INFORMATION PLEASE LET ME KNOW
Thank you
I felt later in the night that during the loading in the staging table using UNIX machine he created the new line for each line. That is why the last CMTS is not found, for this I use the UNIX 2 BACK conversion and it starts to work perfectly.
It was the dos2unix error!
Thank you all for your interest and I may learn new things, as I have almost 10 months of experience in (PLSQL, SQL)
-
Is it possible to use SQL queries to search for names of entries which are contained in an URL parameter?
The situation is the following:
In the #1 database, I have several entries (A, B, C, D, etc.). I want to know if I can use WHERE and LIKE clause to filter the entries that appear in a URL parameter.
The normal code: WHERE nom_entree AS % whateverTheURLparameterIs % displays only entries that have the URL containsparameter. I need the code to display the entries contained in the URL parameter.
P.S. does not have the code WHERE the whateverTheURLparameterIs AS argument entryName % .
Consider using the full text for this research. You could probably achieve what you want to use the like with a predicate subquery, but a full text search will be faster. You can also control the respect of the case.
> PS another problem that I am having with what corresponds to the URL
> settings, because they include all of the
> article ("Hi. My name is... (''), tend to be very long.
No need to include the item in the query string. The article is stored in the table. Just pass the id of the item in the query string.
-
Cannot run PL/SQL using SQL * more
Hello
I am very new in the SQL environment. I want to run the following PL/SQL code, which should allow me to send an e-mail, using sql * more:
DECLARE
l_mailhost VARCHAR2 (64): = "qiudubcorrel001.qa.local";
l_from VARCHAR2 (64): = "[email protected]";
l_to VARCHAR2 (64): = "[email protected]";
l_mail_conn UTL_SMTP.connection;
BEGIN
l_mail_conn: = UTL_SMTP.open_connection (('10.253.14.240'), 25);
UTL_SMTP. HELO (l_mail_conn, '10.253.14.240');
UTL_SMTP.mail (l_mail_conn, l_from);
UTL_SMTP. RCPT (l_mail_conn, l_to);
UTL_SMTP. Data (l_mail_conn, 'single string message.' |) Chr (13));
UTL_SMTP. Quit (l_mail_conn);
END;
When I type the code above in sql * Plus, it does nothing but waiting just as if the code is incomplete and he expects something more! Could someone tell me what is the problem here?
Thank you
KamalHello
Try to put a / on a new line after END;
Concerning
Peter -
Hello
This is my first time on this forum so bear with my ignorance! I'll expose the background of my setup and then explain the error.
We have a small business with a server running SBS2011 and PC running Windows 8 and 8.1 connected to the server in a domain environment.
We use a CRM product called Emu Tall that uses SQL Server 2008 R2 on the server for the database and the PC run a local application that connects to this database.
On a daily basis, but completely randomly and sometimes several times a day, a user will try and open the application on a PC and get the following error message.
Could not load file or assembly 'Microsoft.SqlServer.SqlEnum, Version = 10.0.0.0, Culture = neutral, PublicKeyToken = 89845dcd8080cc91' or one of its dependencies. The system cannot find the specified file.
At first, I thought it must be a matter of waiting time as it seemed to happen every morning, but I've proved since that it occurs at any time of the day and is apparently unrelated to amount of users or idle time or something like that.
Here's another oddity that hopefully sheds some light on it. If I go to the server and open the CRM application on the server, it works very well since it is only the PC that have the connection problem. In addition, as soon as I connected to the server of any PC can connect immediately (until it happens again later in the day). I don't need to stay connected to the server, connect one time and close the session and he "fixed" it for a few hours for all PC users.
I contacted the CRM vendor, and they are completely confused and have no idea what to do.
We are trolling along at the moment with me opening a session on the server for launch launch whenever a user receives the error message but it is far from satisfactory.
A final observation is that it does not always. It used to work fine. The problem began just two months ago and seems to coincide with the increase in our user from 5 to 12 users license even if the CRM provider swear that it is nothing to do with the license. They may agree; I don't know enough to argue the point.
Any help will be appreciated! I'm sure it will be a simple solution and someone there will know why and the answer immediately but is elusive at this time.
This issue is beyond the scope of this site and must be placed on Technet or MSDN
-
SQL toolkit connection problems on ICB
Hi all.
I wrote this post because I'm not able to find a solution for the problem of the Telegraph...
I have developed a program that uses SQL Toolkit, the CVI 9. I have access to a MS Access 97 database, using an ODBC (DSN = MyProgram) connection.
The program works well, on windows 7 and windows XP (windows xp is the operating system of the end user).
However, when I install the program on the pc to the end user (windows xp) and then create the DSN user on ODBC connections, I got an error during execution of the program. We mean the error is not possible to connect to the database (its the ODBC connection).
As I said, on the other machine, different, with windows xp, it works!
I'm a little lost. Do I need a special component installed to SQL Toolkit fine work?
The PC with XP where the application works, has the same applications installed as the end user's PC.
I tried to install on the end user the LabWindows CVI SQL Toolkit with pc, and I checked that when connecting to the DSN will be tried, I get "unknown error."
Help will be very appreciate!
Run it on pc without Sql toolkit, you must copy the cvidb32.dll into your your windows system32 folder.
-
Hello
Error occurs when you use SQL Server 2012 assessment vs window detail of the object in window 7. I use the window of the object but the detail of the objects window arrives and immediately SQL Server stops with the error below and then opens again. I didn't find any help with this specific error is but suspect there is a problem between SLQ Server 2012 et.NET Framework 4. Unfortunately, I do not know what it takes in this regard.
Thanks, Deb
Event ID: 1000
Task category: (100)
Level: error
Keywords: Classic
User: n/a
Computer: Deb - HP
Description:
Name of the failing application: Ssms.exe, version: 2011.110.3000.0, time stamp: 0x5081c1cd
Name of the failed module: KERNELBASE.dll, version: 6.1.7601.18015, time stamp: 0x50b83c8a
Exception code: 0xe0434352
Offset: 0x0000c41f
ID of the process failed: 0x13a8
Start time of application vulnerabilities: 0x01ce609a6d3db991
The failing application path: C:\tempSQLWOW\110\Tools\Binn\ManagementStudio\Ssms.exe
Path of the failing module: C:\Windows\syswow64\KERNELBASE.dll
Report ID: 1fb1cbfb-cc8e-11e2-b436-abd2bebb3f17Hi Claude,.
The question you posted would be better suited in the TechNet Forums. I would recommend posting your query in the link below.
http://social.technet.Microsoft.com/forums/en-us/category/SQLServer
Good day!
Answer please if you face concerns.
-
Building xml in oracle without unnecessary tags using sql
I wanted to build XML in oracle using sql, I found a way to construction using sql functions after a little research, I am completely unaware of any XML. My query is
SELECT XMLELEMENT("orderwave",
XMLAGG(XMLELEMENT("order_header",
-- XMLATTRIBUTES(t2.l_name AS "order_number"),
XMLFOREST(
nvl(t2.l_name,' ') as "order_number",
(
SELECT XMLAGG(XMLELEMENT("order_line",
XMLFOREST( nvl(t1.l_name,' ') AS "label_type",
nvl(t1.l_num,0) AS "lpn",
nvl(t1.l_num,0) AS "sku"
)
)
)
FROM test_table t1
WHERE UPPER(t1.record_type)='D'
) AS sap
)
)
)
) AS HEADER
FROM test_table t2
WHERE UPPER(t2.record_type) ='H';My problem is for using xmlforest, I had to use alias name 'sap' in my query to work and to get xml output. If i am using that, I am getting an unwanted tag 'SAP' around my data which I have to later cut it, which is unacceptable. Is there a way I can get rid of this extra 'SAP' tag without having to cut. The output data is
<orderwave>
<order_header>
<order_number>order1</order_number>
<SAP>
<order_line>
<label_type>test1</label_type>
<lpn>1</lpn>
<sku>1</sku>
</order_line>
<order_line>
<label_type>test2</label_type>
<lpn>2</lpn>
<sku>2</sku>
</order_line>
<order_line>
<label_type />
<lpn>0</lpn>
<sku>0</sku>
</order_line>
</SAP>
</order_header>
<order_header>
<order_number>order2</order_number>
<SAP>
<order_line>
<label_type>test1</label_type>
<lpn>1</lpn>
<sku>1</sku>
</order_line>
<order_line>
<label_type>test2</label_type>
<lpn>2</lpn>
<sku>2</sku>
</order_line>
<order_line>
<label_type />
<lpn>0</lpn>
<sku>0</sku>
</order_line>
</SAP>
</order_header>
</orderwave>Any help is really appreciated and thanks in advance.
-- sample data with test_table as ( select 'H' record_type, 'order1' l_name, 0 l_num from dual union all select 'H' record_type, 'order2' l_name, 0 l_num from dual union all select 'D' record_type, 'test1' l_name, 1 l_num from dual union all select 'D' record_type, 'test2' l_name, 2 l_num from dual ) -- end of sample data select xmlelement ( "order_wave" , xmlagg ( xmlelement ( "order_header" , xmlelement("order_number", t1.l_name) , xmlagg ( xmlelement ( "order_line" , xmlelement("label_type", t2.l_name) , xmlelement("lpn", t2.l_num) , xmlelement("sku", t2.l_num) ) ) ) ) ) xml_data from test_table t1 cross join test_table t2 where t1.record_type = 'H' and t2.record_type = 'D' group by t1.l_name; -- output /*
order1 test1 1 1 test2 2 2 order2 test1 1 1 test2 2 2 -
MySQL->; table using SQL Developer Oracle
Greetings,
Currently, I am a (student) temporary employee who is responsible for the migration of the MySQL database of a company to their new (gr 11, 2) Oracle database.
So far, I use SQL Developer, because I learned a few minor techniques with this application.
I have tried different methods for the migration, including those of the Oracle (Migration of MySQL) page
I however got no positive results with most of the methods.
-J' have established a connection to the MySQL database Oracle database aswell, within SQL Developer
Now, so far, I've copied manually (right click on the table, copy to Oracle) 90% of the tables from the MySQL to Oracle database successfully.
However, these tables contain only about 5% of the data. The problem is in the 2 tables that actually have a decent amount of records.
FOR INFO:
File 1: 75MB file .csv, ~150.000 records (individual records contain all select queries, where the size)
File 02:50 MB of files .csv, ~2.200.000 records
My previous attempts to use the same copy for Oracle option to right click on one of the two largest tables resulted in the following error:
The table of queries down. Message: java.io.IOException: IO error: socket read timed out
My first action to prevent this error has been to add a second file data to the current storage space, giving it 200M maxsize.
Okay it's coming, my real questions!
This could be a possible solution to avoid the error mentioned earlier to return?
What other issues are possible in case of failure?
Uses an external table to a faster and more effective method?
(The reason for which I have not yet tried external tables is because I had no SYS (TEM) privileges, so anything that requires privileges, I first have to discuss with my superior).
Any help is appreciated! Although my next answer is maybe not earlier that come Monday 17.
Welcome, Brent
Hello
I just discovered there is a csv Import Wizard in sqldeveloper also - don't know if you tried?
tables in the destination database (oracle) - right-click and choose Import data - this will bring you in a Wizard of csv.
However, I think that due to the volumes of data it may have similar problems.
sqlldr is probably your best choice - it's pretty simple once you find a decent example - it seems to cover the basics of ok - Oracle SQL Stuff (for example): SQL-Loader: the tutorial step by step - example 1 (CSV file)
See you soon,.
Rich
-
Replacement of alpha-numeric characters using SQL only
Hello
I have a field with the following distribution of the alpha-numeric
C84 CW66, GED54,
How can I change the following format for
Cw 66, 54, C 84 GOL
only by using SQL commands and not to the help of PL/SQL procedures or function?
Thank you.Hello
Welcome to the forum!
REGEXP_REPLACE ( str -- or maybe INITCAP (str) , '([[:alpha:]])([[:digit:]])' , '\1''\2' )
Returns a copy of the str string, with a single quote added after each letter (upper or lower case) which was initially followed immediately by a number.
If you want to change the case at the same time, use INITCAP (str) as 1st REGEXP_REPLACE argument.I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using. REGEXP_REPLACE works in Oracle 10.1 or more.
See the FAQ forum {message identifier: = 9360002}
Maybe you are looking for
-
Palm pre more (Verizon) does not connect to the Exchange Server
I've been on the phone for 3 days (bought the Verizon Pre the day it came out) and couldn't connect to my companys mail server. I had a Palm Treo 755 for years and have always got my email to that. After days of talk with representatives of the Palm,
-
HP 700-149: care needed for modules DIMM Ram
Hello I need to replace my RAM on my HP 700-149 due 800 000 errors found after the use of Mem86 +. I checked the user guide and it SODIMM modules specifications: (http://support.hp.com/ca-en/product/HP-ENVY-700-Desktop-PC-series/5395582/model/5425811
-
Installation of new Wd Hardrive window problem
HelloI have a hp pavilion dv4 system 2101 UT. My internal 320 GB hard drive has been corrupted, and I just bought 500GB new black hardrive wd internal. the problem is that when I install the window, I am facing problem. Just tell me that is there any
-
I have a Lifecam cinema how to you turn off the autofocus?
I downloaded the latest version of the software for windows 7 64 bit that came on the CD when I bought it last night. Appears not to be more up to date which is available on the microsoft Web site. Research on other sites say most people go in the pr
-
Control USB microphone volume control
Hi all. It's me again. I have a USB microphone connected to my XP machine. I can't find a way to adjust the input volume. When I'm not looking for?