SQL function for comparing 2 strings
Hi allIs there a SQL function for comparing 2 strings?
There is no function of pre defined in Sql for the string comparison. You can create according to your requirement.
Concerning
Tags: Database
Similar Questions
-
PL/SQL function for the addition of "days."
I created a function that, at a date and a number, adds many days to the date. The problem is that there are parameters to include Saturday, Sunday or Monday as these days. Here is an example of the call
DAYSBETWEEN('01-Aug-11',5,0,0,0) will give 5 calendar days since August 1, 2011 (that you would not exclude Saturday, Sunday or Monday)
DAYSBETWEEN (August 1, 11 ', 5, 1,1,0) would give you 5 working days since August 1, 2011
DAYSBETWEEN('01-Aug-11',5,0,1,1) would give you 5 days of August 1, 2011 spring break Sunday and Monday.
My current role is:
This works for a small set of values for the date, but when there is a bigger set of dates, it takes hours to complete because of the time loop and multiple or statements.create or replace FUNCTION DAYSBETWEEN( DAYIN IN DATE , ADDNUM IN NUMBER , EXSAT IN NUMBER , EXSUN IN NUMBER , EXMON IN NUMBER ) RETURN DATE IS dtestart DATE; intcount NUMBER; holidays NUMBER; BEGIN dtestart := DAYIN; intcount :=1; WHILE intcount <= ADDNUM LOOP dtestart := dtestart + 1; IF NOT((EXSAT = 1 AND TO_CHAR(dtestart, 'd')= 7) OR (EXSUN=1 AND TO_CHAR(dtestart, 'd')= 1) OR (EXMON=1 AND TO_CHAR(dtestart, 'd')= 2)) THEN intcount := intcount + 1; END IF; END LOOP; RETURN dtestart; END DAYSBETWEEN;
Y at - it another game of logic, I could use to improve this query, using possibly not the while loop / or statements?Hi again:
This is the query, reformatted in the form of a function, exectuing the same thing I did in the above query:
SQL> CREATE OR REPLACE FUNCTION daysbetween 2 ( 3 dayin IN DATE , 4 addnum IN NUMBER , 5 exsat IN NUMBER , 6 exsun IN NUMBER , 7 exmon IN NUMBER ) 8 9 RETURN DATE 10 11 IS 12 13 dtestart DATE; 14 intcount NUMBER; 15 holidays NUMBER; 16 17 BEGIN 18 19 WITH all_dates AS 20 ( 21 SELECT LEVEL AS days_to_add 22 , dayin 23 , dayin + LEVEL AS new_dt 24 , addnum 25 , exsat 26 , exsun 27 , exmon 28 FROM dual 29 CONNECT BY LEVEL <= addnum * 2 30 ) 31 , exclusions AS 32 ( 33 SELECT ROW_NUMBER() OVER ( ORDER BY new_dt) ordering 34 , addnum 35 , new_dt 36 , TO_CHAR ( new_dt, 'DY' ) 37 FROM all_dates 38 WHERE 1=1 39 AND TO_CHAR ( new_dt, 'DY' ) != DECODE ( exsat, 1, 'SAT', 'XXX') 40 AND TO_CHAR ( new_dt, 'DY' ) != DECODE ( exsun, 1, 'SUN', 'XXX') 41 AND TO_CHAR ( new_dt, 'DY' ) != DECODE ( exmon, 1, 'MON', 'XXX') 42 ) 43 SELECT MAX( new_dt ) 44 INTO dtestart 45 FROM exclusions 46 WHERE ordering <= addnum; 47 48 RETURN dtestart; 49 50 END daysbetween; 51 / Function created. SQL> SELECT daysbetween ( DATE '2011-08-01', 150, 1, 0, 1) FROM DUAL; DAYSBETWE --------- 26-FEB-12 1 row selected.
The only variable not factored is holiday, but I saw that you were for them in your LOOP function either.
Due to the nature and variability holiday, it is better to have a table with the listed holidays, and those who could be elminated of charges together in the same 'exculsions' query where I used the TO_CHAR and DECODE to exclude the Fri, sat and Sun.
-
How to compare two strings in PL/SQL
Hi all
I need to compare two strings, they are equal or not in PL/SQL. Y at - it a function to compare the strings.Yes, the sign =.
You're after something like:
IF v_string1 = v_string2 THEN ... ELSE ... END IF;
?
Published by: Boneist on August 27, 2009 11:41
-
Chain replication using a sql function...
Hello
Is there a sql function that reproduces a string given so many times that appears in a parameter...?
For example: String-> test
Select < sql_function > ('test', 3) double
-> testtesttest
Note: I use Oracle10g v.2
Thank you
SIMWhat about a SQL?
satyaki> satyaki>select * from v$version; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod PL/SQL Release 10.2.0.3.0 - Production CORE 10.2.0.3.0 Production TNS for 32-bit Windows: Version 10.2.0.3.0 - Production NLSRTL Version 10.2.0.3.0 - Production Elapsed: 00:00:00.08 satyaki> satyaki> satyaki>select DBMS_XMLGEN.getxmltype ('SELECT '||chr(39)||'&str'||chr(39)||' cola FROM dual connect by rownum<='||&num).EXTRACT('//text()') res 2 from dual; Enter value for str: satyaki Enter value for num: 1 old 1: select DBMS_XMLGEN.getxmltype ('SELECT '||chr(39)||'&str'||chr(39)||' cola FROM dual connec new 1: select DBMS_XMLGEN.getxmltype ('SELECT '||chr(39)||'satyaki'||chr(39)||' cola FROM dual con RES ---------------------------------------------------------------------------------------------------- satyaki Elapsed: 00:00:00.07 satyaki>/ Enter value for str: satyaki Enter value for num: 2 old 1: select DBMS_XMLGEN.getxmltype ('SELECT '||chr(39)||'&str'||chr(39)||' cola FROM dual connec new 1: select DBMS_XMLGEN.getxmltype ('SELECT '||chr(39)||'satyaki'||chr(39)||' cola FROM dual con RES ---------------------------------------------------------------------------------------------------- satyakisatyaki Elapsed: 00:00:00.03 satyaki> satyaki>/ Enter value for str: satyaki Enter value for num: 3 old 1: select DBMS_XMLGEN.getxmltype ('SELECT '||chr(39)||'&str'||chr(39)||' cola FROM dual connec new 1: select DBMS_XMLGEN.getxmltype ('SELECT '||chr(39)||'satyaki'||chr(39)||' cola FROM dual con RES ---------------------------------------------------------------------------------------------------- satyakisatyakisatyaki Elapsed: 00:00:00.02 satyaki> satyaki>/ Enter value for str: satyaki Enter value for num: 5 old 1: select DBMS_XMLGEN.getxmltype ('SELECT '||chr(39)||'&str'||chr(39)||' cola FROM dual connec new 1: select DBMS_XMLGEN.getxmltype ('SELECT '||chr(39)||'satyaki'||chr(39)||' cola FROM dual con RES ---------------------------------------------------------------------------------------------------- satyakisatyakisatyakisatyakisatyaki Elapsed: 00:00:00.14
Kind regards.
LOULOU
Published by: Satyaki_De on September 27, 2008 14:10
-
No support for oracle sql functions
Hi all
Please can someone explain why the B-tree indexes are not capable of supporting SQL queries using the built-in functions of Oracle.
We have indexes of tree b on account_no column.
Select * from test_table where account_no = 11005208
the above query use the index on account_no
Select * from test_table where superior (account_no) = 11005208
But this query does not use the index on the account_no, going for the full table scan.
My question here is account_no is the numeric data type.
Then, there is no difference between the data in the columns account_no and upper (account_no) column data, so why he does not use index when using sql functions in an sql query?Hello
If you apply the upper function, Oracle implicitly converts its argument to a string, so your query is actually upper (to_char (account_no)).
There is none HAVE fully functional in the optimizer and you do not expect to know everything and do all the conclusions that a human being can do. Why should Oracle re - write this type of query analysis the data type of the columns and features when it seems more natural programmer write a correct query (without capital letters in this example) or, if necessary, create an index based on a function? -
How to get the query of the region "PL/SQL function body returns the query string"?
Hello
is it possible to get the query string from the region of type "PL/SQL function body returns the query string"?
I can get the definition of the region as a PL/SQL procedure, but I am interested in the returned query. I tried to write something like
< pre > v_return_query: = «...» » ;
: P49_QUERY: = v_return_query;
Return v_return_query; < / pre >
to save the return on hidden item P49_QUERY string, but it does not work. I get the error message: ERR-1002 cannot find the item for the "P49_QUERY" element ID in the application '4000 '.
Kind regards
PrzemekIf you need to make reference to a page element in the block then you can use this type of control to avoid having to use generic column names:
if apex_application.get_current_flow_sgid(:APP_ID) = apex_application.get_sgid then-- runtime :P9_SQL := vSQL;else-- design time null;end if;
But if all you want to do is capture the SQL debugging you can take all the references element in the block and use the insert statement (in a debug table) as I showed earlier.
Scott
-
Create function for ODD or EVEN (NUMBER) in pls sql
Create the function for ODD or EVEN (NUMBER) also
If number is odd, multiply by 5
If there is an even number, multiply it by 10;865253 wrote:
Create the function for ODD or EVEN (NUMBER) also
If number is odd, multiply by 5
If there is an even number, multiply it by 10;create function fn_get_no (n_in in number) return number is o_num number; begin if mod(n_in,2) = 0 then o_num := n_in*10; else o_num := n_in*5; end if; return o_num; end;
select fn_get_no(5) odd, fn_get_no(4) even from dual; ODD EVEN 25 40
Vivek L
-
Why the function of integrated separator string is missing in Oracle?
Hi all
It's maybe a generic/discussion question. And it's purely for learning about how Oracle prioritizes its development on the functions in construction.
Well, we have very userful built-in functions (http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions001.htm) is transformed during the versions of Oracle from simple to very complex (syntactic xml and data mining functions)
But why is this important function to split a string has been neglected (may not be the right word) by Oracle.
Be a learner curious and admirer of such a wonderful technology database called Oracle, I always thought that it must have a dedicated channel, divide the function.
My question is: is this something that can be generalized in a built-in function?
or
Is he coming releases?
At least a simple function first (I guessed right his name would be splitstr and the very basic features to do our job of splitting, maybe I'm wrong in thinking this way, please correct me if...) Thank you in advance!)
splitstr('A,B,c',',','col')-> (separator ',' and the fractionating column mode)
Output: A B C (three separate columns)
splitstr('A,B,c',',','row')-> (separator ',' and the mode line split)
Output:
A
B
C
----------
If oracle has this, there will be a lot of code reduced and we can be saved by connect or recursive with clause or as a matter of fact even xmltable (with or without tokenizer ) for the separation of the channels.
What you have to say about this? You can ignore this naïve question if is not a value you answer.
And thanks for everyone who reads this discussion!
See you soon,.
Manik.
Can you please help me understand why Oracle has its participation in develping and DBMS_UTILITY.COMMA_TO_TABLE now then?
http://docs.Oracle.com/CD/B19306_01/AppDev.102/b14258/d_util.htm
Oracle can only tell you why they have developed this particular function. But the fact that Oracle included in a package of "utility" tells me that they do not consider that there was a generic number of use cases. These functions often begin as internal functions that Oracle decides to publish.
But if you read this API spec you'll see that he does that to a VERY PARTICULAR use case and has several restrictions.
The
list
must be a list separated by commas of non-vide: another thing that a comma-separated list is rejected. Do not count the commas inside double quotes.Entries in the list separated by commas may not include multibyte and dashes (-) character.
Also, returns a collection which would normally be used only for a very limited number of items.
It is not yet near a general-purpose function.
A major complication with such a function in SQL is sql is generally used with more than one, or even millions, of lines.
How you specify to Oracle where to put the collection on each of these lines?
New - Oracle is a relational database. With the help of sql to manipulate collections is NOT a relational paradigm.
Just my opinion. Others can and will disagree. But you may have to wait for the weekend for these answers.
-
PL/SQL functions as LOV to use in another display object
Hello
We had a custom search to extract data from a display object and the data displayed as a Table of ADF. Now, there are few requests for searches on this report. Go see criteria and Panel request if we allow saved search. But the fields used in the research are going through a lot of logic and thus the PL/SQL functions are implemented. We used to call these functions and lists separated by commas and then divided the list into individual elements and put in the component "select options".
The value (String) returned by the pl/sql function is something like - APAC, EMEA, NORTH AMERICA, FDA
I am creating a LOV based on SQL-query "Select getRegions() from dual;
Now, I want the list separated by commas to divide so that I could use this LOV in an another view and try the display criteria and saved searches.
I tried to assign as LOV just to check and the criteria drop-down view for region displays same value as single element - "APAC, EMEA, NORTH AMERICA, LAD."
I want it to be 4 separate - elements
APAC
EMEA
NORTH AMERICA
DVL
Is there anyway to achieve this?
Or better is at - it another way to do this (maybe I'm wrong)
Thank you.
JDev: 11.1.2.4
Instead of a programmatic VO of PL/SQL, I found sometimes easier to write PL/SQL functions that return a table - need to CREATE a TYPE for the data items to be returned and a TYPE of TABLE IMBRIQUE tabular form of the first kind. The function returns the type of table, and can even be a PIPElined table function. Then I create a VO with the following text:
SELECT * from TABLE (my_function_returning_table)
The function can even take parameters, which you fill with variable BIND your VO.
-
I'm not able to compare two strings in OpenScript
Hello
I'm trying to compare two string in if condition. But it's going through.
My code is:
String PATTERN_TYPE = eval ("{{db. INPUTS_CREATE_REPRICING_PATTERN. PATTERN_TYPE}} ")." ToString();
String REPRICING_TYPE = eval ("{{db. INPUTS_CREATE_REPRICING_PATTERN. REPRICING_TYPE}} ")." ToString();
If (PATTERN_TYPE is 'Absolute')
{
Info ("absolute section");
If (REPRICING_TYPE is "FLAT")
{
Info ("absolute section PLATE");
}
}
Data Bank is to have values like "Absolute" and "FLAT" only if the two if conditions must have passed and the two info should come. But it's not going inside.
Note: I also tried without function toString().
Please advice.
Kind regards
Abhay
Hi Abhay,
Please use below...
World in java, strings are compared with equivalent to...
==
tests for equality of references..equals()
tests for equality of the values.String PATTERN_TYPE = eval ("{{db. INPUTS_CREATE_REPRICING_PATTERN. PATTERN_TYPE}} ")." ToString();
String REPRICING_TYPE = eval ("{{db. INPUTS_CREATE_REPRICING_PATTERN. REPRICING_TYPE}} ")." ToString();
If (PATTERN_TYPE.equals ("Absolute")
{
Info ("absolute section");
If (REPRICING_TYPE.equals ("FLAT")
{
Info ("absolute section PLATE");
}
}
-
SQL query for the mapping of a set of prizes to a group of classrooms
Hi all
I use Oracle database 11g Release 2.
I have the following data set:
Classrooms
ClassId ClassName ability group
------ ---------------------------------------------- -------------- -----------
Babbage/software Engg Lab 1 24 1
Basement 2 - block PG 63 1
3 1 56 1 class
Class 4 1 24 10
Class 5 1 24 11
Class 6 1 35 12
7 13 42 1 class
8 14 42 1 class
9 15 42 1 class
10 2 35 1 class
11 3 35 1 class
12 4 35 1 classroom
13 5 35 1 class
14 6 25 1 class
15 7 25 1 class
16 1 24 8 class
17 9 24 1 class
18 control Sys Lab 1 24
19 dig & Embd Sys Lab 20 1
20 PSD & Comm 20 1 Lab
21 electromechanical system Lab 28 1
Farabi 22/Web Tech Lab 1 36
23 gen purpose Lab 40 1
Shirazi/24dB Tech Lab 1 36
ADV 25 elect Lab 30 2
26 16 42 2 class
27 17 49 2 class
28 18 56 2 class
29 19 42 2 class
30 20 49 2 class
Class 31 21 35 3
32 22 35 3 class
33 20 3 MDA lab
DegreeBatches
BatchId BatchName force
--------------- ----------------------- --------------
1 BIT - 11 79
2 BIT - 12 28
3 BS (CS)-1 35
4 BS (CS) 78-2
5 BE (SE)-1 69
6. BE (SE) 84-2
7 BE (SE) 64-3
8 84 BYTČA-7
9 43 BYTČA-8
BEE-1 10, 112
11 151 BEE-2
BEE-3 12, 157
13 BEE-4 157
I want to map a combination of batch of degree for a class rooms group of such distance that they make full use of the maximum capacity of the class rooms within a group (ideally), or as close to this as possible. Can it be done with a SQL query?
Any response will be appreciated.
The SQL Scripts to generate the required tables and populate data is less to:
CREATE TABLE classrooms (ClassId NUMBER, ClassName VARCHAR2 (50), capacity NUMBER, group NUMBER);
INSERT INTO the classrooms of the VALUES (1, "Babbage/software Engg Lab', 24, 1");
INSERT INTO the classrooms of the VALUES (2, 'basement - PG block', 63, 1);
INSERT INTO the classrooms of the VALUES (3, '1 class room', 56, 1);
INSERT INTO the classrooms of the VALUES (4, '10 class room', 24, 1);
INSERT INTO the classrooms of the VALUES (5, '11 class room', 24, 1);
INSERT INTO the classrooms of the VALUES (6, 'class room 12', 35, 1);
INSERT INTO the classrooms of the VALUES (7, 'class room 13', 42, 1);
INSERT INTO the classrooms of the VALUES (8, 'class room 14', 42, 1);
INSERT INTO the classrooms of the VALUES (9, '15 'class, 42, 1);
INSERT INTO the classrooms of the VALUES (10, 'class 2', 35, 1);
INSERT INTO the classrooms of the VALUES (11, 'class room 3', 35, 1);
INSERT INTO the classrooms of the VALUES (12, 'class room 4', 35, 1);
INSERT INTO the classrooms of the VALUES (13, 'class room 5', 35, 1);
INSERT INTO the classrooms of the VALUES (14, 'class room 6', 25, 1);
INSERT INTO the classrooms of the VALUES (15, '7 class room', 25, 1);
INSERT INTO the classrooms of the VALUES (16, 'class Room 8', 24, 1);
INSERT INTO the classrooms of the VALUES (17, 'class room 9', 24, 1);
INSERT INTO the classrooms of the VALUES (18, 'Control Sys Lab', 24, 1);
INSERT INTO the classrooms of the VALUES (19, 'Dig & Embd Sys Lab', 20, 1);
INSERT INTO the classrooms of the VALUES (20, 'DSP & Comm Lab', 20, 1);
INSERT INTO the classrooms of the VALUES (21, 'system ELECTROMECHANICAL Lab', 28, 1);
INSERT INTO the classrooms of the VALUES (22, ' Farabi/Web Tech Lab', 36, 1);
INSERT INTO the classrooms of the VALUES (23, 'Gen purpose Lab', 40, 1);
INSERT INTO the classrooms of the VALUES (24, ' Shirazi/DB Tech Lab', 36, 1);
INSERT INTO the classrooms of the VALUES (25, 'Elected Adv Lab', 30, 2);
INSERT INTO the classrooms of the VALUES (26, 'class room 16', 42, 2);
INSERT INTO the classrooms of the VALUES (27, 'class room 17', 49, 2);
INSERT INTO the classrooms of the VALUES (28, '18 'class, 56, 2);
INSERT INTO the classrooms of the VALUES (29, '19 'class, 42, 2);
INSERT INTO the classrooms of the VALUES (30, 'class room 20', 49, 2);
INSERT INTO the classrooms of the VALUES (31, 'class room 21', 35, 3);
INSERT INTO the classrooms of the VALUES (32, 'room 22', 35, 3);
INSERT INTO the classrooms of the VALUES (33, 'MDA Lab', 20, 3);
CREATE TABLE DegreeBatches (BatchId NUMBER, BatchName VARCHAR2 (50), membership NUMBER);
INSERT INTO DegreeBatches VALUES(1,'BIT-11',79);
INSERT INTO DegreeBatches VALUES(2,'BIT-12',28);
INSERT INTO DegreeBatches VALUES (3, 'BS (CS) - 1', 35);
INSERT INTO DegreeBatches VALUES (4, 'BS (CS) - 2', 78);
INSERT INTO DegreeBatches VALUES (5,'BE (SE) - 1', 69);
INSERT INTO DegreeBatches VALUES (6,'BE (SE) - 2', 84);
INSERT INTO DegreeBatches VALUES (7,'BE (SE) - 3', 64);
INSERT INTO DegreeBatches VALUES(8,'BICSE-7',84);
INSERT INTO DegreeBatches VALUES(9,'BICSE-8',43);
INSERT INTO DegreeBatches VALUES(10,'BEE-1',112);
INSERT INTO DegreeBatches VALUES(11,'BEE-2',151);
INSERT INTO DegreeBatches VALUES(12,'BEE-3',157);
INSERT INTO DegreeBatches VALUES(13,'BEE-4',157);
Best regards
Bilal
Published by: Bilal on December 27, 2012 09:52
Published by: Bilal on December 27, 2012 10:07Bilal, thanks for the nice problem! Another possibility to double check is to write a small PL/SQL function that returns 1 if a duplicate id is found, then equate to 0: "NUMBER of RETURN of Duplicate_Token_Found (p_str_main in VARCHAR2, p_str_trial VARCHAR2). It should analyze the second string and could use p_str_main LIKE '%', | l_id | ', %' for each id. In any case, the query complete (without that) is given below:
Solution with names SQL> WITH rsf_itm (con_id, max_weight, nxt_id, lev, tot_weight, tot_profit, path, root_id, lev_1_id) AS ( 2 SELECT c.id, 3 c.max_weight, 4 i.id, 5 0, 6 i.item_weight, 7 i.item_profit, 8 ',' || i.id || ',', 9 i.id, 10 0 11 FROM items i 12 CROSS JOIN containers c 13 UNION ALL 14 SELECT r.con_id, 15 r.max_weight, 16 i.id, 17 r.lev + 1, 18 r.tot_weight + i.item_weight, 19 r.tot_profit + i.item_profit, 20 r.path || i.id || ',', 21 r.root_id, 22 CASE WHEN r.lev = 0 THEN i.id ELSE r.nxt_id END 23 FROM rsf_itm r 24 JOIN items i 25 ON i.id > r.nxt_id 26 AND r.tot_weight + i.item_weight <= r.max_weight 27 ORDER BY 1, 2 28 ) SEARCH DEPTH FIRST BY nxt_id SET line_no 29 , rsf_con (nxt_con_id, nxt_line_no, con_path, itm_path, tot_weight, tot_profit, lev) AS ( 30 SELECT con_id, 31 line_no, 32 To_Char(con_id), 33 ':' || con_id || '-' || (lev + 1) || ':' || path, 34 tot_weight, 35 tot_profit, 36 0 37 FROM rsf_itm 38 UNION ALL 39 SELECT r_i.con_id, 40 r_i.line_no, 41 r_c.con_path || ',' || r_i.con_id, 42 r_c.itm_path || ':' || r_i.con_id || '-' || (r_i.lev + 1) || ':' || r_i.path, 43 r_c.tot_weight + r_i.tot_weight, 44 r_c.tot_profit + r_i.tot_profit, 45 r_c.lev + 1 46 FROM rsf_con r_c 47 JOIN rsf_itm r_i 48 ON r_i.con_id > r_c.nxt_con_id 49 WHERE r_c.itm_path NOT LIKE '%,' || r_i.root_id || ',%' 50 AND r_c.itm_path NOT LIKE '%,' || r_i.lev_1_id || ',%' 51 AND r_c.itm_path NOT LIKE '%,' || r_i.nxt_id || ',%' 52 ) 53 , paths_ranked AS ( 54 SELECT itm_path || ':' itm_path, tot_weight, tot_profit, lev + 1 n_cons, 55 Rank () OVER (ORDER BY tot_profit DESC) rnk, 56 Row_Number () OVER (ORDER BY tot_profit DESC) sol_id 57 FROM rsf_con 58 ), best_paths AS ( 59 SELECT itm_path, tot_weight, tot_profit, n_cons, sol_id 60 FROM paths_ranked 61 WHERE rnk = 1 62 ), row_gen AS ( 63 SELECT LEVEL lev 64 FROM DUAL 65 CONNECT BY LEVEL <= (SELECT Count(*) FROM items) 66 ), con_v AS ( 67 SELECT b.itm_path, r.lev con_ind, b.sol_id, b.tot_weight, b.tot_profit, 68 Substr (b.itm_path, Instr (b.itm_path, ':', 1, 2*r.lev - 1) + 1, 69 Instr (b.itm_path, ':', 1, 2*r.lev) - Instr (b.itm_path, ':', 1, 2*r.lev - 1) - 1) 70 con_nit_id, 71 Substr (b.itm_path, Instr (b.itm_path, ':', 1, 2*r.lev) + 1, 72 Instr (b.itm_path, ':', 1, 2*r.lev + 1) - Instr (b.itm_path, ':', 1, 2*r.lev) - 1) 73 itm_str 74 FROM best_paths b 75 JOIN row_gen r 76 ON r.lev <= b.n_cons 77 ), con_split AS ( 78 SELECT itm_path, con_ind, sol_id, tot_weight, tot_profit, 79 Substr (con_nit_id, 1, Instr (con_nit_id, '-', 1) - 1) con_id, 80 Substr (con_nit_id, Instr (con_nit_id, '-', 1) + 1) n_items, 81 itm_str 82 FROM con_v 83 ), itm_v AS ( 84 SELECT c.itm_path, c.con_ind, c.sol_id, c.con_id, c.tot_weight, c.tot_profit, 85 Substr (c.itm_str, Instr (c.itm_str, ',', 1, r.lev) + 1, 86 Instr (c.itm_str, ',', 1, r.lev + 1) - Instr (c.itm_str, ',', 1, r.lev) - 1) 87 itm_id 88 FROM con_split c 89 JOIN row_gen r 90 ON r.lev <= c.n_items 91 ) 92 SELECT v.sol_id, 93 v.tot_weight s_wt, v.tot_profit s_pr, c.id c_id, c.name c_name, c.max_weight m_wt, 94 Sum (i.item_weight) OVER (PARTITION BY v.sol_id, c.id) c_wt, 95 i.id i_id, i.name i_name, i.item_weight i_wt, i.item_profit i_pr 96 FROM itm_v v 97 JOIN containers c 98 ON c.id = To_Number (v.con_id) 99 JOIN items i 100 ON i.id = To_Number (v.itm_id) 101 ORDER BY sol_id, con_id, itm_id 102 / SOL_ID S_WT S_PR C_ID C_NAME M_WT C_WT I_ID I_NAME I_WT I_PR ---------- ---- ---- ----- --------------- ---- ---- ----- ---------- ---- ---- 1 255 255 1 SEECS UG Block 100 100 1 BIT-10 35 35 2 BIT-11 40 40 6 BICSE-7 25 25 2 IAEC Building 70 70 4 BSCS-3 40 40 7 BESE-3 30 30 3 RIMMS Building 90 85 3 BSCS-2 35 35 5 BEE-4 50 50 2 255 255 1 SEECS UG Block 100 95 4 BSCS-3 40 40 6 BICSE-7 25 25 7 BESE-3 30 30 2 IAEC Building 70 70 1 BIT-10 35 35 3 BSCS-2 35 35 3 RIMMS Building 90 90 2 BIT-11 40 40 5 BEE-4 50 50 3 255 255 1 SEECS UG Block 100 100 3 BSCS-2 35 35 4 BSCS-3 40 40 6 BICSE-7 25 25 2 IAEC Building 70 65 1 BIT-10 35 35 7 BESE-3 30 30 3 RIMMS Building 90 90 2 BIT-11 40 40 5 BEE-4 50 50 4 255 255 1 SEECS UG Block 100 100 3 BSCS-2 35 35 4 BSCS-3 40 40 6 BICSE-7 25 25 2 IAEC Building 70 70 2 BIT-11 40 40 7 BESE-3 30 30 3 RIMMS Building 90 85 1 BIT-10 35 35 5 BEE-4 50 50 5 255 255 1 SEECS UG Block 100 95 2 BIT-11 40 40 6 BICSE-7 25 25 7 BESE-3 30 30 2 IAEC Building 70 70 1 BIT-10 35 35 3 BSCS-2 35 35 3 RIMMS Building 90 90 4 BSCS-3 40 40 5 BEE-4 50 50 6 255 255 1 SEECS UG Block 100 100 2 BIT-11 40 40 3 BSCS-2 35 35 6 BICSE-7 25 25 2 IAEC Building 70 65 1 BIT-10 35 35 7 BESE-3 30 30 3 RIMMS Building 90 90 4 BSCS-3 40 40 5 BEE-4 50 50 7 255 255 1 SEECS UG Block 100 100 2 BIT-11 40 40 3 BSCS-2 35 35 6 BICSE-7 25 25 2 IAEC Building 70 70 4 BSCS-3 40 40 7 BESE-3 30 30 3 RIMMS Building 90 85 1 BIT-10 35 35 5 BEE-4 50 50 8 255 255 1 SEECS UG Block 100 100 1 BIT-10 35 35 4 BSCS-3 40 40 6 BICSE-7 25 25 2 IAEC Building 70 70 2 BIT-11 40 40 7 BESE-3 30 30 3 RIMMS Building 90 85 3 BSCS-2 35 35 5 BEE-4 50 50 9 255 255 1 SEECS UG Block 100 100 1 BIT-10 35 35 4 BSCS-3 40 40 6 BICSE-7 25 25 2 IAEC Building 70 65 3 BSCS-2 35 35 7 BESE-3 30 30 3 RIMMS Building 90 90 2 BIT-11 40 40 5 BEE-4 50 50 10 255 255 1 SEECS UG Block 100 100 1 BIT-10 35 35 3 BSCS-2 35 35 7 BESE-3 30 30 2 IAEC Building 70 65 2 BIT-11 40 40 6 BICSE-7 25 25 3 RIMMS Building 90 90 4 BSCS-3 40 40 5 BEE-4 50 50 11 255 255 1 SEECS UG Block 100 100 1 BIT-10 35 35 3 BSCS-2 35 35 7 BESE-3 30 30 2 IAEC Building 70 65 4 BSCS-3 40 40 6 BICSE-7 25 25 3 RIMMS Building 90 90 2 BIT-11 40 40 5 BEE-4 50 50 12 255 255 1 SEECS UG Block 100 95 1 BIT-10 35 35 3 BSCS-2 35 35 6 BICSE-7 25 25 2 IAEC Building 70 70 2 BIT-11 40 40 7 BESE-3 30 30 3 RIMMS Building 90 90 4 BSCS-3 40 40 5 BEE-4 50 50 13 255 255 1 SEECS UG Block 100 95 1 BIT-10 35 35 3 BSCS-2 35 35 6 BICSE-7 25 25 2 IAEC Building 70 70 4 BSCS-3 40 40 7 BESE-3 30 30 3 RIMMS Building 90 90 2 BIT-11 40 40 5 BEE-4 50 50 14 255 255 1 SEECS UG Block 100 100 1 BIT-10 35 35 2 BIT-11 40 40 6 BICSE-7 25 25 2 IAEC Building 70 65 3 BSCS-2 35 35 7 BESE-3 30 30 3 RIMMS Building 90 90 4 BSCS-3 40 40 5 BEE-4 50 50 98 rows selected. Elapsed: 00:00:01.42
Published by: BrendanP on January 20, 2013 11:25
I found the need to deduplicate regular expression:AND RegExp_Instr (r_c.itm_path | r_i.path, ',(\d+),.*?,\1,') = 0)
-
can I use create valude function for MSSql scalar and table.
Hello
(1) can I use create scalar function for MSSql and function table?
(2) is there how many type of function defined by the user in oracle 11 g express?
(3) and I can reture 'type' any form user defined function?
Attract sincerely944768 wrote:
the answer lies in a few cases only,
The response illustrates the basic concept of how customers need to use cursors created using PL/SQL as a layer of abstraction - SQL and this concepts adapts to ALL cases where the customer wants to Oracle via PL/SQL cursor.
a case is,
If my function returns only a single value, then I can use oracle 'create function' with the return type as types predefined as a whole, varchar2 etc?
with regard to performance.With regard to this performance problem? And why now suddenly change the question to want to use a function to return data type number or string? How does this relate to PL/SQL to return a cursor now?
A function can return scalar values, not scalar. A function may return atomic values (such as a unique number, or a non-scalar list of numbers). A function can return a complex data structure consisting of scalar values, not scalar.
However, in PL/SQL function must NOT be used to read the lines of the database to cache lines in a memory of the server PL/SQL (PGA), then back to the client.
He does not. It does not fit. It is too bloody dangerous to the overall health of the server as such code plays silly blighters with very expensive server memory.
A PL/SQL function can also be used as guideline, returning data via expensive PGA, but via the SQL engine instead and using its slider interface (which allows output data to be "gradual" and not to return all data with a single copy of croustilleur mass of the call stack) directly. IT IS, HOWEVER, AN EXCEPTION. There is very rarely the need to make the functions PL/SQL pipeline table - and is often victims of abuse and bad demonstrated with examples of absurd code here.
-
APEX shortcuts using the source of the body of the PL/SQL function
Hi all
Recently, I came across the feature of "Shortcuts" in the "Shared components" section of the APEX and thought great, somewhere to set the common/standard items once, then use these several times in different pages of my application.
This seemed to work correctly when you use the 'Source' of "HTML Text" or "HTML text with special characters escaped", but then I wanted to explore the use of the "Body of the PL/SQL function" option to create a more dynamic shortcut/variable on the base.
This is where I came across a particular problem in the APEX (Version 3.2.1.00.10 on GR 11, 2 on Oracle Enterprise Linux). When I set my shortcut, and then perform a reference to my shortcut (using "MY_SHORTCUT") in an area of a page, the value of shortcut is back, but is added with the reference variable (ie. the 'MY_SHORTCUT' chain).
For simplicity, my example looks like this (of course, my real world example is a bit more complicated, but this example produces the same error):
(a) I define my shortcut called "MY_SHORTCUT" and using the body of the PL/SQL function under "Source Type", define my procedure as "htp.p(:USER)."
(b) I then create a new page (basic HTML page), and a new region of the 'type'-> 'HTML Text (with shortcuts).
(c) in the "Source region", I define my shortcut like - "MY_SHORTCUT".
(d) I apply changes and then run the page.
I'll be back will be name of the current user with "MY_SHORTCUT" appended/added immediately after the user name - for example. the string:-' BRAD «MY_SHORTCUT»»
Question is - how to stop the shortcut/reference text "MY_SHORTCUT" to be added to the variable you want to see the and thereafter on your page? I am just wanting the variable, NOT the reference for the shortcut. I do something wrong using the HTP package, and if yes, what should I use?
If "MY_SHORTCUT" is defined as "HTML text with special characters escaped" (where I can refer to elements of application using the syntax '& USER.') so that everything works correctly. My reason for using the PL/SQL is to generate a more dynamic output variable, based on elements of application throughout the entire application - and of course the use of shortcuts to minimize coding and duplication.
Thanks in advance,
BradHello
The body of the PL/SQL function must RETURN a value.
Try:
RETURN :APP_USER;
Andy
-
Problem inserting new line in a VO with SQL functions and subqueries
Hello
I use JDeveloper 10.1.3.4 and and stuck with insertion of a new line when the values to insert into some fields of the new line are returns of SQL functions and subqueries.
At the sqlplus prompt, the following sql statement is tested and developed successfully:
Note that the values for the fields of 4th and 5th are returns of subqueries and SQL functions.insert into VALIDATIONS values ( '111223333', 'JANE', 'DOE', SYSDATE, (select to_char(sysdate, 'yymmdd') from dual)|| (select to_char(count(TRANSACTION_DATE)+1,'fm0999') from VALIDATIONS where trunc(TRANSACTION_DATE) = to_char(sysdate)) );
Ideally, it would be simple to assemble a SQL and executed him as he did to the old way of servlet:
I'm not sure it can be done in JDeveloper, and it was not found in the developer's guide. What I found was rather:String sql = "insert into VALIDATIONS values ('" + id + "', '" + firstName + "', '" + lastName + "', SYSDATE, (select to_char( ......)))"; statement.executeUpdate(sql);
In my case, it would be OK for the first three fields as shown below (in the code of transactionsRecords is a display object). But what about the 4th and 5th fields?// 1. Find the ServiceRequests view object instance. ViewObject svcReqs = am.findViewObject("ServiceRequests"); // 2. Create a new row and insert it into the row set Row newSvcReq = svcReqs.createRow(); svcReqs.insertRow(newSvcReq); // 3. Show effect of entity object defaulting for Status attribute System.out.println("Status defaults to: "+newSvcReq.getAttribute("Status")); // 4. Set values for some of the required attributes newSvcReq.setAttribute("CreatedBy",308); // Nancy Greenberg (user) Date now = new Date(new Timestamp(System.currentTimeMillis())); newSvcReq.setAttribute("RequestDate",now); newSvcReq.setAttribute("ProdId",119); // Ice Maker newSvcReq.setAttribute("ProblemDescription","Cubes melt immediately"); // 5. Commit the transaction am.getTransaction().commit();
A big thank you to those who know or have experience before!Row newTransaction = transactionsRecords.createRow(); transactionsRecords.insertRow(newTransaction); newTransaction.setAttribute("StudentId", id); newTransaction.setAttribute("FirstName", firstName); newTransaction.setAttribute("LastName", lastName); newTransaction.setAttribute("TransactionDate", <how to put "SYSDATE" here?>); newTransaction.setAttribute("ConfirmNumber", <how to put subqueries here?>);
NewmanNewman,
You can do this via a procedure call. This technique is described here
I guess you can't do this directly in the EO or VO.
You can do it the old way to create a prepared directly query and call it as you described. To get the declaration use getDBTransaction () .createPreparedStatement (...) method available in the module of your application.
Be aware of the implications using the given solution. The framework doesn't know anything of what you are doing. So to see the changes that you used to update the tables that you change.Timo
-
Acrobat Adobe function DC compare Pro
Hey,.
I don't get "Acrobat could not compare the document completely. Want to see the report anyway? "error.
Before it was working fine, but after upgrading to windows 10 it has stopped working.
Operating system: Windows Pro 10
Version Acrobat: Adobe Acrobat Pro XI (11.0.17)
Under file-> properties-> Description-> advanced-> PDF producer it is said "Python PDF library - . http://pybrary.NET/pyPdf/
After selecting the first document it will automatically select "Bridges of presentation, drawings or illustrations", but it must stay on "reports, spreadsheets, presentations magazine.
I tried to reinstall Adobe Acrobat Pro DC, but it did not help.
It works if I open pdf with word and save it as pdf but our client does not want to do these steps, because it was working before.
Hello
Greetings! I'm sorry to hear that you are facing problems with function to compare. Please try the files in our comparison of improved features in the latest version of Acrobat Pro DC. Reach out to us in this case, you face all the questions. You can also log in a bug report or make a feature request at: Adobe Acrobat - feature request/Bug Report Form
Also, we have significantly improved the feature compare in our new version of Adobe Acrobat DC.
Please update to the latest version to give it a try. The new tool file compare offers a Side-by-Side view, which provides a better experience in the identification of the differences and a modern user interface.
Latest version of Adobe Acrobat DC build number: 2015.020.20039 (ongoing).
For more info about the new comparison tool, visit: https://helpx.adobe.com/acrobat/using/compare-documents.html as well.
If you're still on Acrobat X or XI, you can consult our trial version at: https://acrobat.adobe.com/in/en/free-trial-download.html
Thank you
Adobe Acrobat DC Team.
Maybe you are looking for
-
Why is the excessive MSIE browser history if I use Firefox?
I am running SP3 Windows XP (32-Bit Version) with MSIE 8The system is common with all Microsoft updates and application vendors Whenever I start, clear the history of navigation for Firefox and Internet EXPLORER 8. Then I run Disk Cleanup. If I use F
-
Question of X120e ABGN driver in Windows 7 Pro x 64
I recently bought a x120e and installed an SSD with my own copy of Windows 7 Professional 64-bit. I managed to install all the drivers, but my ABGN 2 x 2 wlan card driver refuses to install correctly. I get a code 10 this device cannot start the mess
-
EliteBook 6930p: Bluetooth pin code
Hello! I'm trying to connect my Smartphone from Huawei y360 to Elitebook computer 6930p laptop via bluetooth but Huawei asks for a pin code and I don't know what it is. I tried: 0000, 1111, 1234.
-
Hello Helpers, I use toshiba M300 satellite with windows vista basic 32-bit operating system. Recently, my bluetooth software installed in my computer did not work. Whenever I go to the bluetooth file transfer Wizard can't find all devices at all. Wh
-
Errors appear in the profile of the host, but nobody else. Problems with the bar side in the profile of the host, but box for comments function profile works very well. Adobe reader software also works at the end of comments, but does not work in the