T/t with the WHERE clause using a list breaks
Hello, all,.
I have a project where I need to use a list as part of the WHERE clause for a t/t, and it is breaking. I don't know what I'm doing wrong.
For some pseudo-code, do I have a complete query of a database called 'people '. A list of values for the t/t with the first query; the second query is my t/t:
<cfquery name="getDIR" datasource="#request.THISDSN#"> SELECT thisName dir FROM orgs WHERE thisID in (<cfqueryparam value="#form.org#" cfsqltype="cf_sql_varchar" list="yes" />) </cfquery> <cfquery name="people" database="people"> SELECT colA, colB, colC, colD FROM people WHERE 1=1 AND ( div IN (<cfqueryparam value="#valueList(getDIR.dir)#" cfsqltype="varchar" list="yes" />) OR dir IN (<cfqueryparam value="#valueList(getDIR.dir)#" cfsqltype="varchar" list="yes" />) ) </cfquery>
I get the error message is "t/t syntax error: encountered" div IN \'thisValue\' ".» Incorrect conditional expression, waiting for one of [as | null | between | in | comparison] condition. »
Can support _not_ QoQ lists of WHERE clauses?
V/r,
^_^
SMH - so much... I just found.
I forgot to give the lists in the second query bracket.
(The pseudocode was manually typed, since my dev system is isolated from the internet, and I added the in my pseudo code when they were not in my original code.)
* headdesk * headdesk * headdesk * headdesk *.
V/r,
^_^
Tags: ColdFusion
Similar Questions
-
I have a Select statement where I want to select rows where weighs only 1 of the selected date 3 columns is null. Is this possible?
Select rec_date, prior_rec_date2, prev_rec_date3
of my_receipts
where (not more than 1 or the date 3 fields is null)
Any help would be greatly appreciated.Hello
WHERE NVL2 (rec_date, 1, 0) + NVL2 (prior_rec_date2, 1, 0) + NVL2 (prev_rec_date3, 1, 0) >= 2
-
Tuning - using the CASE statement in the WHERE clause of the query
Hi all
My request has been changed to use a CASE statement in the WHERE clause to examine the data to some columns based on a parameter value. This modified request is made a full table and constantly running scan. Please suggest what can be done to improve its performance:
Query:
Description of the table:SELECT LAST_DAY(TRUNC(TO_TIMESTAMP(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))) AS summary_date, os.acctnum, os.avieworigin_refid, COUNT(1) cnt_articleview, SUM(NVL(autocompletedterm,0)) cnt_autocompletedterm FROM TABLE1 os WHERE os.acctnum IS NOT NULL AND os.avieworigin_refid IS NOT NULL AND os.requestdatetime IS NOT NULL AND UPPER(os.success_ind) = 'S' AND CASE WHEN Param_ValueToCheck = 'FULL' AND get_date_timestamp(os.requestdatetime) BETWEEN TO_DATE('01-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND TO_DATE('31-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') THEN 1 WHEN Param_ValueToCheck = 'INCR' AND os.entry_createddate BETWEEN TO_DATE('01-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND TO_DATE('31-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') THEN 1 END = 1 AND CASE WHEN Param_ValueToCheck = 'FULL' AND os.entry_CreatedDate BETWEEN TO_DATE('01-APR-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND TO_DATE('07-JUN-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') THEN 1 WHEN Param_ValueToCheck = 'INCR' THEN 1 END = 1 GROUP BY LAST_DAY(TRUNC(TO_TIMESTAMP(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))), os.acctnum,os.avieworigin_refid;
(Number of lines: approx. > amount 600 000 000)
Explain PlanName Null Type ------------------------------ -------- ------------ ARTICLEID NOT NULL NUMBER(20) USERKEY NUMBER(10) AVIEWORIGIN_REFID VARCHAR2(10) SUCCESS_IND VARCHAR2(2) ENTRY_CREATEDDATE DATE CREATED_BY VARCHAR2(10) FILENUMBER NUMBER(10) LINENUMBER NUMBER(10) ACCTNUM VARCHAR2(10) AUTOCOMPLETEDTERM NUMBER(2) REQUESTDATETIME VARCHAR2(19)
Published by: Chaitanya on June 9, 2011 02:44SQL> select * from table(dbms_xplan.display); PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Plan hash value: 2224314832 ---------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | ---------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 590 | 33040 | 2501K (1)| 08:20:15 | | | | 1 | HASH GROUP BY | | 590 | 33040 | 2501K (1)| 08:20:15 | | | | 2 | PARTITION RANGE ALL| | 590 | 33040 | 2501K (1)| 08:20:15 | 1 |1048575| |* 3 | TABLE ACCESS FULL | TABLE1 | 590 | 33040 | 2501K (1)| 08:20:15 | 1 |1048575| ---------------------------------------------------------------------------------------------------------- PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Predicate Information (identified by operation id): --------------------------------------------------- 3 - filter(UPPER("OS"."SUCCESS_IND")='S' AND CASE WHEN ('FULL'='FULL' AND "OS"."ENTRY_CREATEDDATE">=TO_DATE(' 2011-04-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "OS"."ENTRY_CREATEDDATE"<=TO_DATE(' 2011-06-07 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) THEN 1 WHEN 'FULL'='INCR' THEN 1 END =1 AND "OS"."REQUESTDATETIME" IS NOT NULL AND CASE WHEN ('FULL'='FULL' AND "ODS"."GET_DATE_TIMESTAMP"("REQUESTDATETIME")>=TO_DATE(' 2011-05-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "ODS"."GET_DATE_TIMESTAMP"("REQUESTDATETIME")<=TO_DATE(' 2011-05-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) THEN 1 WHEN ('FULL'='INCR' AND "OS"."ENTRY_CREATEDDATE">=TO_DATE(' 2011-05-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "OS"."ENTRY_CREATEDDATE"<=TO_DATE(' PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 2011-05-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) THEN 1 END =1 AND "OS"."ACCTNUM" IS NOT NULL AND "OS"."AVIEWORIGIN_REFID" IS NOT NULL)
Published by: Chaitanya on June 9, 2011 02:47When it is executed individually, MERGE LOGIC 1 and LOGIC of MERGE 2 take about ten for a daterange of 30 days data.
BUT FULL is to get the scores of APR - JUN, INCR becomes partitions for MAY so not both 30 days.
Are compare us like with like? -
How to filter the result with a where clause clause?
Hello
I have a nice sql query. I would like to include a where clause with a joker clause.
If the user selects for example a "AGENT_ID", then where clause would include the AGENT_ID, otherwise, every thing would appear.
The WHERE clause:SELECT "FICHE"."FICHE_ID" "FICHE_ID", "FICHE"."AGENT_ID" "AGENT_ID", "FICHE"."EQUIPE_ID" "EQUIPE_ID", "FICHE"."DATE_ACTIVITE" "DATE_ACTIVITE", "FICHE"."DATE_CREATION" "DATE_CREATION", "FICHE"."TYPE_FICHE" "TYPE_FICHE", "FICHE"."FICHE_CREE_PAR" "FICHE_CREE_PAR", "FICHE"."TOTAL_HEURES" "TOTAL_HEURES", "FICHE"."TOTAL_HEURES_EXCEPTIONNELLES" "TOTAL_HEURES_EXCEPTIONNELLES", "FICHE"."DATE_MODIFICATION" "DATE_MODIFICATION" FROM "FICHE"
WHERE AGENT_ID = ' * ' if nothing is selected.
WHERE AGENT_ID = "4290" If an agent ID is selected.
Hope I'm clear that English is not my mother tongue.
Thanks for you help.
ChristianHello
Try this
WHERE "FICHE".AGENT_ID like NVL(:val, '%')
see you soon
VT
-
Trouble using a function in the where clause
Hello
I use a function that is located at ask.tom.oracle.com, which converts a long data type in a character. The function returns an error when it is placed in the where clause. The sql statement, the error message and the function of asking tom are listed below. Does anyone know how to fix this?
< pre >
SELECT A.FLDPHYSICAL,
A.FLDEXPOSURE,
A.FLDDATEDUE,
A.FLDDATELAST,
A.FLDEMPLOYEE,
B.FLDBDATE,
B.FLDMAILSTOP,
B.FLDREC_NUM,
B.FLDLNAME,
B.FLDMI,
B.FLDFNAME,
B.FLDBDATE,
B.FLDDEPT,
B.FLDSTATUS,
B.FLDSSN,
B.FLDHOMEPHON,
B.FLDWORKPHON,
B.FLDID,
B.FLDDIVISION
OF REQEXAM,.
B OF THE EMPLOYEE,
C EMPLOYEE_MEMO
WHERE A.FLDEMPLOYEE = B.FLDREC_NUM
AND b.flduserstr = c.fldrec_num
AND OHM_PKG. GET_LONG ('EMPLOYEE_MEMO', 'FLDDATA', C.ROWID) AS ' % CDL YES % '.
"AND A.FLDDATEDUE > 1 January 1900"
AND A.FLDPHYSICAL = 'COP '.
ORDER OF B.FLDDIVISION,
B.FLDLNAME,
B.FLDFNAME,
B.FLDMI,
A.FLDDATEDUE
-------------------------------------------------------------------------
The error message
Error in the command line: 26 column: 4
Error report:
SQL error: ORA-00904: "OHM_PKG." "" GET_LONG ": invalid identifier
00904, 00000 - '% s: invalid identifier '.
-------------------------------------------------------
create or replace
PACKAGE OHM_PKG AS
/ * TODO type (types, exceptions, methods etc.) package declarations here * /.
getlong function (p_tname in varchar2, p_cname in varchar2, p_rowid in rowid) return varchar2;
END OHM_PKG;
create or replace
PACKAGE BODY OHM_PKG AS
getlong function (p_tname in varchar2, p_cname in varchar2, p_rowid in rowid) return varchar2 as
whole l_cursor default dbms_sql.open_cursor;
number of l_n;
l_long_val varchar2 (4000);
number of l_long_len;
number of l_buflen: = 4000;
l_curpos number: = 0;
Start
DBMS_SQL. Parse (l_cursor,
"select" | p_cname | 'from ' | p_tname |
' where rowid =: x',.
DBMS_SQL.native);
DBMS_SQL.bind_variable (l_cursor, ': x', p_rowid);
DBMS_SQL.define_column_long (l_cursor, 1);
l_n: = dbms_sql.execute (l_cursor);
If (dbms_sql.fetch_rows (l_cursor) > 0)
then
DBMS_SQL.column_value_long (l_cursor, 1, l_buflen, l_curpos,)
(l_long_val, l_long_len);
end if;
DBMS_SQL.close_cursor (l_cursor);
Return l_long_val;
getLong end;
END OHM_PKG;
< / prev >Remove the '_' in the name of the function as below:
AND OHM_PKG. GETLONG('EMPLOYEE_MEMO', 'FLDDATA', C.ROWID) AS "CDL % YES % '.
-
Try adding conditions to clause "and" stored in the table for the where clause, unknown syntax
I am trying to add additional segments to the 'where' clause, and I don't know exactly how to proceed. I am currently using another table to search for keywords and sometimes there aren't everything. I use this table containing the key words to search the description and associate a symbol with a path.
The code loops through the keywords with the keywords most associated and try to find links to a symbol then excludes those and search for symbols that correspond to those with less keywords and all. I am able to do this with 6 queries and manually changing the arguments, but I want to loop together so that if the changes need to be made in the future, I won't need to go digging in the code.
Thanks, but that's ok. I already have a solution for this.
-
Need help with dynamic where clause.
Hello world. I'm kind of a novice with PL/SQL, so please be patient with me. I am building a web application using Weblogic Oracle 11 g and Oracle database.
To make a long story short, I need to generate the complex dynamic WHERE clause. I don't know what will be the name of the column or the operator of comparison or the value will be until the moment of execution.
I'm not 100% certain, but I think I need to use dynamic SQL statements. Unless there is a better way to do it.
I'm sure that using dynamic SQL opens me up to SQL injection attacks if I use simple string concatenation. I would like to use bind variable if possible.
In any case, it seems like trying to build a dynamic where clause does not seem to work as I want it would be...
bv1 := 'colA = 5 and colB >= 9'; query_str := 'SELECT * FROM view WHERE :bv1'; OPEN CUR FOR query_str USING bv1;
The code above pours out when I try to run it.
Is there a way to build dynamic where the provisions without the use of concatenation of simple string that leaves me open to attacks by SQL injection?
Thank you
Hello. I have read briefly upward on things, you suggested, but it seems a bit abstract for me since I was a novice.
Can you give us an explanation or an example of how to use it to accomplish what I need to do?
Do ypu really plan create a query with a WHERE clause that contains a predicate for all possible columns?
Variable bind offer performance when the same query is executed several times with different values for bind variables.
Select * from emp where empno =: v_empno
After the first run Oracle will always be this query in the library cache. The next running can use the version of the cache even if the bind value is different.
Select * from emp where empno =: v_empno;
Select * from emp where ename =: v_ename;
Select * from emp where sal =: v_sal;
Each one is a DIFFERENT query. Yes - each of them uses a variable binding, but queries are different.
So, if your username select EMPNO, an '=', and a value from the first query can be executed. But the next time that the user can select the ENAME column so that 'stored' first request may not be used given that the query does not match.
The third time your user selects SAL so none of the first two queries can be used in the library cache. The use of bind variables gives performance during the SAME QUERY is used multiple times with DIFFERENT values for the variable binding. Oracle is not to analyze the hard query everything simply because the VALUE is different.
So bind variables do not help you if most of the queries were completely DIFFERENT sets of predicates. And SYS_CONTEXT will not help either since that simply provides a way to define binds the values of the variables.
Just for the simple example above, there are at least SIX possible combinations of columns that could choose your user name: empno, ename, sal, empno ename, empno & sal, ename & sal
-
In the WHERE clause string variable
I have the procedure
CREATE OR REPLACE PROCEDURE proc1 (p_1 IN varchar2)
IS
BEGIN
DELETE FROM TABLE1
WHERE
Col1 = '@p_1. '
;
Dbms_output.put_line (number of rows sql %);
COMMIT;
EXCEPTION
WHILE OTHERS THEN
ROLLBACK;
RAISE_APPLICATION_ERROR (-20000, SQLERRM);
Proc1 END;
/
You will need to pass a string input parameter to the procedure. This string is applied to the WHERE clause. The foregoing does not work correctly the value of @p1 is in the WHERE clause. The value passed to the stored procedure does not run.
Please let me know the solution. I have to use BIND variables only.
Thank youuser12038051 wrote:
Thank you all. Yes, the underside of the works.DELETE FROM TABLE1
WHERE
Col1 = p_1
;PS: Both COL1 and p_1 are string values. Would like to know how it works with out the quotes because it is a string.
In addition I would like to follow the number of lines executed in each statement. Preference will have to use sql % rowcount. Are there other alternatives. Please let me know. Thanks in advance.
Oracle 'knows' that the variable p_1 is a varchar2 data type and that col1 is a varchar2 data type, so he makes a comparison between them strinf. This is how variables work in any programming language that I am aware. The only time that you must provide a value is when you use a literal value (for example in an assignment variable, or as a parameter of a procedure).
If you need to know the number of deleted rows, then sql % rowcount is the only sensible option. Just be aware that you need to get the value before committing yourself ot other options of SQL.
John
-
How to create a procedure for REF CURSOR output with any WHERE clause?
I have a requirement like this: I have a huge question that need to reuse in my code over 10 times. This SQL has about 50 lines. Here for these 10 odd times sometimes changes in WHERE clause (columns are the same). So I can't create a view as SQL is not static.
I thought to write a procedure with a para of WHERE_CLAUSE entry. I pulled out a refcursor sys by adding where clause. But I can't do it because you cannot add a clause like this where clause.
i.e.
The foregoing gives an error.PROCEDURE dynamyic_query (p_where_clause IN VARCHAR2, p_out_query OUT SYS_REFCURSOR ) IS BEGIN OPEN p_out_query FOR SELECT ......... FROM table WHERE || ' ' || p_where_clause; END;
How to handle such a situation? Any help would be greatly appreciated.Hello
Channa wrote:
... However, when I change the procedure like this:PROCEDURE FORMS_TEXT_DYN_SQL_TEST(p_where_cluase IN VARCHAR2, p_out_cursor OUT SYS_REFCURSOR) IS v_stmt VARCHAR2(1000); BEGIN v_stmt := 'SELECT tname FROM tab_test WHERE tname LIKE ''%ABS_V4%'' AND :y'; OPEN p_out_cursor FOR v_stmt using p_where_cluase; END;
And run this block of code:
declare v_tname varchar2(200); out_cursor sys_refcursor; begin forms_text_dyn_sql_test(' 1 = 1 ', out_cursor ); LOOP fetch out_cursor INTO v_tname; exit when out_cursor%NOTFOUND; DBMS_OUTPUT.PUT_LINE(v_tname); END LOOP; end; /
I get the error:
[1]: (Error): ORA-00920: invalid relational operator ORA-06512: at "ABS.FORMS_TEXT_DYN_SQL_TEST", line 6 ORA-06512: at line 5
Looks like you can only set column_name =: z, column_name =: values of type y. You can not it seems to replace it with no WHERE CLAUSE?
A bind variable, such as: it, represents a single value.
If: is the VARCHAR2 '1 = 1', thenSELECT tname FROM tab_test WHERE tname LIKE '%ABS_V4%' AND :y
takes the value
SELECT tname FROM tab_test WHERE tname LIKE '%ABS_V4%' AND '1 = 1'
I think you want something like this:
CREATE OR REPLACE PROCEDURE FORMS_TEXT_DYN_SQL_TEST ( p_where_clause IN VARCHAR2 , p_out_cursor OUT SYS_REFCURSOR ) IS v_stmt VARCHAR2(1000); BEGIN v_stmt := 'SELECT ename FROM scott.emp WHERE ename LIKE ''%A%'' AND ' || p_where_clause; OPEN p_out_cursor FOR v_stmt; END; / show errors SET SERVEROUTPUT ON declare v_tname varchar2(200); out_cursor sys_refcursor; begin forms_text_dyn_sql_test(' 1 = 1 ', out_cursor ); LOOP fetch out_cursor INTO v_tname; exit when out_cursor%NOTFOUND; DBMS_OUTPUT.PUT_LINE(v_tname); END LOOP; end; /
Output:
ALLEN WARD MARTIN BLAKE CLARK ADAMS JAMES
-
DECODE inside the WHERE clause
Hi all:
I can't get the DECODE statement to work inside my WHERE clause. I have read the information on
Tahiti.Oracle.com
http://download.Oracle.com/docs/CD/E11882_01/server.112/e17118/functions049.htm#i1017437
But still can not get it to work. Initially, I had he works as dynamic SQL and then run that string, but I am not allowed to use dynamic SQL statements and to do 'Real' PL/SQL.
I have the following WHERE clause (more info after the WHERE clause)
As you can see, initially I was adding values of "whereClauseStatus, whereClauseFromDate, whereClauseToDate" and it has been defined with the following PL/SQL code:WHERE a.ebiz_asn_no(+) = te.ebiz_cntrl_no AND w.ebiz_work_no(+) = te.ebiz_cntrl_no AND o.ebiz_ord_no(+) = ebiz_cntrl_no AND t.ebiz_trailer_no(+) = te.ebiz_trailer_no AND ms.ebiz_sku_no(+) = te.ebiz_sku_no AND NVL(ms.ebiz_sku_no, -1) = NVL(p_SKU, nvl(ms.ebiz_sku_no, -1)) AND tl.ebiz_lp_no(+) = te.ebiz_lp_no AND NVL(te.ebiz_lp_no, -1) = NVL(p_LP, nvl(te.ebiz_lp_no, -1)) AND eu.ebiz_user_no(+) = te.act_ebiz_user_no AND NVL(te.act_ebiz_user_no, -1) = NVL(p_UserID, NVL(te.act_ebiz_user_no, -1)) AND NVL(te.begin_location, '~') = NVL(p_BeginLocation, NVL(te.begin_location, '~')) AND NVL(te.end_location, '~') = NVL(p_EndLocation, NVL(te.end_location, '~')) AND te.comp_id = p_CompID AND te.site_id = p_SiteID AND INSTR('' || p_TaskType || '', te.task_type) > 0 AND NVL(task_priority, -1) = NVL(p_Priority, NVL(task_priority, -1)) AND NVL(te.ebiz_cntrl_no, -1) = DECODE(te.task_type, 'IULD', DECODE(p_Order, null, te.ebiz_cntrl_no, ebiz_po2asn.get_ebiz_po_no(p_Order)), NVL(p_Order, NVL (te.ebiz_cntrl_no,-1))) AND NVL(te.batch_no,'~') = NVL(p_Batch, NVL(te.batch_no, '~')) AND NVL(te.ebiz_wave_no, -1) = NVL(p_Wave, NVL(te.ebiz_wave_no, -1)) || whereClauseStatus || whereClauseFromDate || whereClauseToDate;
I have serious problems getting the DECODE statement to replace the three variables in the annex.IF(p_TaskStatus = 'C') THEN ------------------------------------------------------------------------------------------- -- Set From Date Clause ------------------------------------------------------------------------------------------- IF(p_FromShipDate IS NOT NULL) THEN whereClauseFromDate := ' AND TRUNC(te.act_end_date) >= TO_DATE(''' || p_FromShipDate || ''',''MM/dd/yyyy'') '; END IF; ------------------------------------------------------------------------------------------- -- Set To Date Clause ------------------------------------------------------------------------------------------- IF (p_ToShipDate IS NOT NULL) THEN whereClauseToDate := ' AND TRUNC(te.act_end_date) <= TO_DATE(''' || p_ToShipDate || ''',''MM/dd/yyyy'') '; END IF; ELSE ------------------------------------------------------------------------------------------- -- Incomplete and All statuses are filtered on the currdate ------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------- -- Set From Date Clause ------------------------------------------------------------------------------------------- IF(p_FromShipDate IS NOT NULL) THEN whereClauseFromDate := ' AND TRUNC(te.currdate) >= TO_DATE(''' || p_FromShipDate || ''',''MM/dd/yyyy'') '; END IF; ------------------------------------------------------------------------------------------- -- Set To Date Clause ------------------------------------------------------------------------------------------- IF (p_ToShipDate IS NOT NULL) THEN whereClauseToDate := ' AND TRUNC(te.currdate) <= TO_DATE(''' || p_ToShipDate || ''',''MM/dd/yyyy'') '; END IF; END IF; IF (p_TaskStatus = 'I') THEN whereClauseStatus := ' AND act_end_date IS NULL '; ELSIF (p_TaskStatus = 'C') THEN whereClauseStatus := ' AND act_end_date IS NOT NULL '; ELSE whereClauseStatus := ''; END IF;
Any help would be greatly appreciated.
Thank you
Andy
Published by: BluShadow on August 2, 2011 15:11
addition of {noformat}{noformat} tags for clarity. Please read {message:id=9360002} and learn to do this yourself.
I'll take a wild shot in the dark, and suggests that it is perhaps what you are looking for...
WHERE a.ebiz_asn_no(+) = te.ebiz_cntrl_no AND w.ebiz_work_no(+) = te.ebiz_cntrl_no AND o.ebiz_ord_no(+) = ebiz_cntrl_no AND t.ebiz_trailer_no(+) = te.ebiz_trailer_no AND ms.ebiz_sku_no(+) = te.ebiz_sku_no AND NVL(ms.ebiz_sku_no, -1) = NVL(p_SKU, nvl(ms.ebiz_sku_no, -1)) AND tl.ebiz_lp_no(+) = te.ebiz_lp_no AND NVL(te.ebiz_lp_no, -1) = NVL(p_LP, nvl(te.ebiz_lp_no, -1)) AND eu.ebiz_user_no(+) = te.act_ebiz_user_no AND NVL(te.act_ebiz_user_no, -1) = NVL(p_UserID, NVL(te.act_ebiz_user_no, -1)) AND NVL(te.begin_location, '~') = NVL(p_BeginLocation, NVL(te.begin_location, '~')) AND NVL(te.end_location, '~') = NVL(p_EndLocation, NVL(te.end_location, '~')) AND te.comp_id = p_CompID AND te.site_id = p_SiteID AND INSTR('' || p_TaskType || '', te.task_type) > 0 AND NVL(task_priority, -1) = NVL(p_Priority, NVL(task_priority, -1)) AND NVL(te.ebiz_cntrl_no, -1) = DECODE(te.task_type, 'IULD', DECODE(p_Order, null, te.ebiz_cntrl_no, ebiz_po2asn.get_ebiz_po_no(p_Order)), NVL(p_Order, NVL (te.ebiz_cntrl_no,-1))) AND NVL(te.batch_no,'~') = NVL(p_Batch, NVL(te.batch_no, '~')) AND NVL(te.ebiz_wave_no, -1) = NVL(p_Wave, NVL(te.ebiz_wave_no, -1)) AND TRUNC(te.act_end_date) >= NVL(TO_DATE(p_FromShipDate,'MM/dd/yyyy'),TRUNC(te.act_end_date)) AND TRUNC(te.act_end_date) <= NVL(TO_DATE(p_ToShipDate,'MM/dd/yyyy'),TRUNC(tw.act_end_date)) AND TRUNC(te.currdate) >= NVL(TO_DATE(p_FromShipDate,'MM/dd/yyyy'),TRUNC(te.currdate)) AND TRUNC(te.currdate) <= NVL(TO_DATE(p_ToShipDate,'MM/dd/yyyy'),TRUNC(te.currdate)) AND ( (act_end_date IS NULL AND p_TaskStatus = 'I') OR (act_end_date IS NOT NULL AND p_TaskStatus = 'C') OR p_TaskStatus NOT IN ('I','C') )
Published by: BluShadow on August 2, 2011 16:27
spleen the last clause. Oops. -
outer join on query with the GOLD clause
Hi all, I have a problem outerjoining a clause or a request with
Here's my data
as you can see I am attaching the table 1 and table 2. I join with txt1, if txt1 is null, then join by txt2, if null, then reach by txt3 and so on.WITH table1 AS ( SELECT 'test' txt1, 'pak' txt2, 'ced' txt3, 'su' txt4 FROM dual UNION ALL SELECT null txt1, 'pak' txt2, 'ced2' txt3, 'su2' txt4 FROM dual UNION ALL SELECT null txt1, NULL txt2, 'ced3' txt3, 'su3' txt4 FROM dual UNION ALL SELECT null txt1, NULL txt2, null txt3, 'su3' txt4 FROM dual UNION ALL SELECT 'text5' txt1, NULL txt2, null txt3, 'su3' txt4 FROM dual UNION ALL SELECT null txt1, NULL txt2, null txt3, null txt4 FROM dual ) ,table2 AS ( SELECT 111 pid, 'test' txt1, 'pak4' txt2, 'ced' txt3, 'su' txt4 FROM dual UNION ALL SELECT 222 pid, 'test1' txt1, 'pak' txt2, 'ced2' txt3, 'su2' txt4 FROM dual UNION ALL SELECT 333 pid, 'test2' txt1, 'pak3' txt2, 'ced3' txt3, 'su4' txt4 FROM dual UNION ALL SELECT 444 pid, 'test2' txt1, 'pak3' txt2, 'ced4' txt3, 'su3' txt4 FROM dual ) SELECT b.pid, a.* from table1 a, table2 b WHERE (a.txt1 = b.txt1 OR a.txt1 IS NULL AND a.txt2=b.txt2 OR Nvl(a.txt2, a.txt1) IS NULL AND a.txt3 = b.txt3 OR Nvl(a.txt2, a.txt1) IS NULL AND a.txt3 IS NULL AND a.txt4 = b.txt4 )
the above produces this output code
This output is partially correct. only 4 lines were in display and two has been left outPID TXT1 TXT2 TXT3 TXT4 === ==== === ==== ==== 111 test pak ced su 222 pak ced2 su2 333 ced3 su3 444 su3
I tried to use the outer join, but oracle will complain that I can't use outerjoin with the GOLD clause.SELECT 'text5' txt1, NULL txt2, null txt3, 'su3' txt4 FROM dual UNION ALL SELECT null txt1, NULL txt2, null txt3, null txt4 FROM dual
can someone modify my query to display the output below?
PID TXT1 TXT2 TXT3 TXT4 === ==== === ==== ==== 111 test pak ced su 222 pak ced2 su2 333 ced3 su3 444 su3 NULL NULL NULL NULL NULL test5
Not sure you can do it with the style of the Oracle of outer joins, but open ANSI style joins is simple, in fact exactly as you had it.
SQL> set null null; SQL> WITH table1 AS ( 2 SELECT 'test' txt1, 'pak' txt2, 'ced' txt3, 'su' txt4 FROM dual UNION ALL 3 SELECT null txt1, 'pak' txt2, 'ced2' txt3, 'su2' txt4 FROM dual UNION ALL 4 SELECT null txt1, NULL txt2, 'ced3' txt3, 'su3' txt4 FROM dual UNION ALL 5 SELECT null txt1, NULL txt2, null txt3, 'su3' txt4 FROM dual UNION ALL 6 SELECT 'text5' txt1, NULL txt2, null txt3, 'su3' txt4 FROM dual UNION ALL 7 SELECT null txt1, NULL txt2, null txt3, null txt4 FROM dual), 8 table2 AS ( 9 SELECT 111 pid, 'test' txt1, 'pak4' txt2, 'ced' txt3, 'su' txt4 FROM dual UNION ALL 10 SELECT 222 pid, 'test1' txt1, 'pak' txt2, 'ced2' txt3, 'su2' txt4 FROM dual UNION ALL 11 SELECT 333 pid, 'test2' txt1, 'pak3' txt2, 'ced3' txt3, 'su4' txt4 FROM dual UNION ALL 12 SELECT 444 pid, 'test2' txt1, 'pak3' txt2, 'ced4' txt3, 'su3' txt4 FROM dual) 13 SELECT b.pid, a.* 14 from table1 a 15 LEFT JOIN table2 b 16 ON (a.txt1 = b.txt1 OR 17 a.txt1 IS NULL AND a.txt2=b.txt2 OR 18 Nvl(a.txt2, a.txt1) IS NULL AND a.txt3 = b.txt3 OR 19 Nvl(a.txt2, a.txt1) IS NULL AND a.txt3 IS NULL AND a.txt4 = b.txt4); PID TXT1 TXT2 TXT3 TXT4 ---------- ------ ------ ------ ------ 111 test pak ced su 222 null pak ced2 su2 333 null null ced3 su3 444 null null null su3 null text5 null null su3 null null null null null
John
-
'create columns with a where clause' in MDB
Hi all
I have a question on the OBI EE meta data layer.
We have OBIEE sitting on a with a star schema data warehouse.
Our fact table contains the following fields...
EmployeeID
CompanyID
ID of the measure
The measure name
MEASURE
That's what we have in the physical layer, layer MDB and the presentation layer, but I want to be able to "create columns with a where clause.
So my table of facts in the presentation layer would look like this
Quantity sold
Unit cost
Amount of the company
I thought I could just create a logical with column
Quantity = measurement
where as name = "quantity".
But I can't find any to do so.
Any ideas?
Thank youHello
I think that what you want to achieve must be done in the physical layer and not the business layer.
Instead of using your physical table directly from the DB, you must create a physical table based on an SQL statement.
GO to the physical layer you / create the new object table in Table type choose "Select" and then you write your select statement as you want.
Once this is done to create your physical joins and import your table into your business layer and create your complex joins
This should do the trick.
It may be usefulConcerning
-
Beginner: Get on the WHERE clause syntax error in SELECT
I am very new to php and mySQL. Use DW master/detail to generate Basic code I need. One thing I have to do is to modify a select statement in the master to include a WHERE clause to limit the selection to a particular value in a field.
I get a syntax error with the select statement in the WHERE clause, I add to the map.
It's the part of the error message showing the location of the error:
"WHERE group = 'Community' LIMIT 0, 10'"
Php that generated the select is:
$query_maps = "SELECT * FROM tblmaps ORDER BY tblmaps.» DispSeq ';
$query_limit_maps = sprintf ("%s WHERE group =' LIMIT %s %d, %d", $query_maps, $selectGroup, $startRow_maps, $maxRows_maps);
This approach to create the select statement is on the generated code for the master page. He added the LIMIT clause. I didn't add the ' WHERE group = '%s' and the variable $selectGroup, which comes from the old code.» You can see that the $selectGroup variable is equal to the "community: group.»
I scanned the web to see what syntax error, I could do, but haven't found anything that explains it.
The resolved full select statement is:
SELECT * FROM tblmaps ORDER BY tblmaps. WHERE DispSeq = 'Community' LIMIT 0,10 group
What I don't see?
Tom
The group is a reserved word in MySQL. You could probably put single quotes around it, but I suggest to rename this column. Do not use reserved words for column names.
-
DECODE does not work in the WHERE clause when subquery returns more than one line
Hi gurus,
I want to write a query against the table CCENTERS (Script given below) and wait for the following result:
1. in the transition from a value of 0 for the ID, it returns all the rows in the table.
2. in the passage of one value other than 0, it returns the row corresponding to the given value and all its records of the child.
CCENTER has parent-child relationship in the column ID and the BASE. I use a query with the DECODE function. but the function in the WHERE clause is not capable of managing the subquery with multiple lines of DECODE.
*************************************************
VARIABLE ParaCCenter NUMBER
BEGIN
: paraccenter: = 0;
END;
/
CREATE TABLE ccenters
(id NUMBER,
name VARCHAR2 (20).
number base);
INSERT INTO ccenters VALUES(1,'NUST',null);
INSERT INTO ccenters VALUES(2,'SEECS',1);
INSERT INTO ccenters VALUES(3,'NBS',1);
commit;
SELECT * from ccenters
WHERE id IN DECODE(:ParaCCenter, 0, id,)
(SELECT id FROM ccenters
START WITH basic =: ParaCCenter
ID of CONNECTION BY PRIOR = base
UNION
SELECT: ParaCCenter OF double
)
)
/
BEGIN
: paraCCenter: = 1;
END;
/
SELECT * from ccenters
WHERE id IN DECODE(:ParaCCenter, 0, id,)
(SELECT id FROM ccenters
START WITH basic =: ParaCCenter
ID of CONNECTION BY PRIOR = base
UNION
SELECT: ParaCCenter double))
/
The result is
(SELECT id FROM ccenters
*
ERROR at line 3:
ORA-01427: einreihig subquery returns multiple rows
How this query can be rewritten for the given feature. Any response will be appreciated.
Thank youTry something like this:
SELECT * FROM ccenters WHERE :ParaCCenter = 0 OR id in (SELECT id FROM ccenters START WITH base=:ParaCCenter CONNECT BY PRIOR id = base UNION SELECT :ParaCCenter FROM dual )
-
I have Windows 8 and you are unable to open a session. I have reset my password online successfully, but the new password does not work. The message says: "your computer is offline. Please sign in with the last password used on this computer. "I don't remember last password that I used. Any ideas?
Original titile: password is not working on Windows 8
People it is a very simple and easy solution to this problem! Once you have reset your password from another PC/laptop or any other server for windows 8, you go back to your PC / laptop original where you forgot your password and do the following...
1. even if you have reset your password, make sure you have an internet connection for this laptop can be wired or WIFI Hotspot even
2. make sure that connect you using the option under your network settings in the lower left corner of your logg in screen.
3. Once you are connected then only can type you the new password that you changed.
NOW, the simple reason for this is that when you have conveniently forgotten your logg in detail on this pc it does not recognize your new password unless it is connected to your online account.
Maybe you are looking for
-
Calendar dead after upgrade to El Capitan
Upgrade to El Capitan yesterday evening and calendar is now non-functional. Can not see my ical calendars, can not see the events, can't access preferences (nothing happens when you select it), after adding a subscription (Google Calendar), nothing h
-
Problem of Style window Win API WS_EX_NOACTIVATE
Hello I have a requirement for an application that the window is not activated. That means that when you click on the window, it isn't flying goal away from the last window you were active. This normally is not really a problem. I use the window API
-
Driver for HP C410a does not...
I just got my HP C410a printer and I am trying to set up on my laptop Gateway 64 - bit Windows 7... I tried to install driver from the site with print HP Web plugged in and out... when I download and it starts the computer check, a white box appears
-
When I opened the Hotmail emails a message box appears that I can't get rid of
When I opened the Hotmail emails a message box appears which says: this page is accessing ifformation which is not under its control. It is a security risk. -What this means and how do I get rid of him?
-
HP LaserJet P4515 - error 13.05.00 out of Fuser, paper thin, Jam.
HP LaserJet P4515 - error 13.05.00 out of Fuser, paper thin, Jam. I have frequent errors of this type during work duplex paper jam. Simplex jobs seem to work unless I'm trying to duplex manually by printing on one side then the other well. When the j