an INTO clause in this SELECT statement
Hello
This query is to start an error, an INTO clause in the SELECT statement. I have a line in my table
DECLARE
TNom VARCHAR (100);
BEGIN
Select tNom under Tnom in t_conf where Tna = 'Home';
If instr (tNom, 'living room') > 0
then return true;
otherwise return false;
end if;
END;
DECLARE
v_Tname VARCHAR (100);
BEGIN
Select Tname in v_Tname t_conf where Tna = 'Home';
If instr (v_Tname, "living room") > 0
then return true;
otherwise return false;
end if;
END;
Tags: Database
Similar Questions
-
Error PLS-00428: an INTO clause in this SELECT statement
Dear Experts,
I'm new to PL/SQL programming
I try to run the following query, I get the error message.
Please help me solve the error.
declare
var_cd number (20);
Start
If: P1_TYP_CAT is not null then
SELECT max (CAT_cd + 1) as var_cd from IM_AST_CAT by CAT_cd;
insert into IM_AST_CAT (CAT_NM, CAT_CD) values ((upper (:P1_TYP_CAT)),(:var_cd));
on the other
RAISE_APPLICATION_ERROR ('-20001,' both Department and location must be provided ");
end if;
end;
In PL/SQL, must be used IN the clause when using SELECT statements.
SELECT max (CAT_cd + 1) as var_cd
in variable - it is missing in your code
from IM_AST_CAT by CAT_cd;
Your code should be
declare
var_cd number (20);
Start
If: P1_TYP_CAT is not null then
SELECT max (CAT_cd + 1).
in var_cd
of IM_AST_CAT
order of CAT_cd;insert into IM_AST_CAT (CAT_NM, CAT_CD) values (upper(:P1_TYP_CAT), var_cd);
on the other
RAISE_APPLICATION_ERROR ('-20001,' both Department and location must be provided ");
end if;
end;
For example:
DECLARE
l_first_name varchar2 (100);
BEGIN
Select first_name
in l_first_name
employees
where employee_id = 100;
END;
Post edited by: Suri
-
How to split string separated by commas and pass to the clause of the select statement
Referring to article How to divide string separated by commas, then pass to clause of a select statement, tquery that there the following plan:
Query1:
select * from emp where ename in ( select regexp_substr('SMITH,ALLEN,WARD,JONES','[^,]+', 1, level) from dual connect by regexp_substr('SMITH,ALLEN,WARD,JONES', '[^,]+', 1, level) is not null );
Base1:
Plan hash value: 4242290184 -------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 133 | 7 (29)| 00:00:01 | |* 1 | HASH JOIN | | 1 | 133 | 7 (29)| 00:00:01 | | 2 | VIEW | VW_NSO_1 | 1 | 46 | 3 (34)| 00:00:01 | | 3 | HASH UNIQUE | | 1 | | 3 (34)| 00:00:01 | |* 4 | CONNECT BY WITHOUT FILTERING| | | | | | | 5 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 | | 6 | TABLE ACCESS FULL | EMP | 14 | 1218 | 3 (0)| 00:00:01 | -------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - access("ENAME"="$nso_col_1") 4 - filter( REGEXP_SUBSTR ('SMITH,ALLEN,WARD,JONES','[^,]+',1,LEVEL) IS NOT NULL)
However, the following query generates the plan I want:
Query2:
select * from emp where ename in ('SMITH','ALLEN','WARD','JONES');
Plan2:
Plan hash value: 3956160932 -------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 4 | 348 | 3 (0)| 00:00:01 | |* 1 | TABLE ACCESS FULL| EMP | 4 | 348 | 3 (0)| 00:00:01 | -------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - filter("ENAME"='ALLEN' OR "ENAME"='JONES' OR "ENAME"='SMITH' OR "ENAME"='WARD')
Can I change the query1 query for plan2?
As Juliet was mentioned in the first SQL that you generate from the ENAME list that you must pass in the IN clause when executing. But in the second SQL, it passed as a static value. So first SQL must do more work. So you see a different execution plan.
But this is a work around to get what you are looking for. But I can't say it's a foolproof method. But anyway here you go.
SQL > var ename_list varchar2 (100)
SQL > exec: ename_list: = 'SMITH, ALLEN, WARD, JONES ';PL/SQL procedure successfully completed.
SQL > select *.
2 of PEM
where the 3 «,» | : ename_list | ',' like '%', | Ename | ',%';EMPNO, ENAME, JOB HIREDATE DEPTNO ID COM SAL MGR
---------- ------ --------- ---------- --------- ---------- ---------- ---------- ----------
7369 SMITH COMMITTED 7902 2975 2 APRIL 81 0 20
7499 ALLEN 7698 1600 20 FEBRUARY SALESMAN 81 300 30
7521 WARD 7698 1250 22 FEBRUARY SALESMAN 81 500 30
7566 JONES MANAGER 7839 2975 2 APRIL 81 0 20SQL > select * from table (dbms_xplan.display_cursor);
PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------------------------------
SQL_ID, 848zhvbvgf7d6, number of children 0
-------------------------------------
Select * from emp where «,» | : ename_list | ',' like '%', | Ename
|| ',%'Hash value of plan: 2872589290
--------------------------------------------------------------------------
| ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 2 (100) | |
|* 1 | TABLE ACCESS FULL | EMP | 1. 38. 2 (0) | 00:00:01 |
--------------------------------------------------------------------------Information of predicates (identified by the operation identity card):
---------------------------------------------------1 - filter(','||:ENAME_LIST||',' LIKE '%,'||") ENAME "|", %')
19 selected lines.
SQL >
-
Nothing wrong with including ORDER BY in INSERT into... SELECT statement?
Are there implications due to the use of ORDER BY (field3 control) in bottom INSERT INTO... SELECT statement.
insert into mytable ( field1, field2, field3 ) select field1, field2, field3 from source_Table order by field3;
Order by is used with functions select but not a mandate. Usually people uninterested by what people order insert data in a table. We have to try to keep operations and it inserts into a table.
-
call a function in a where clause of a select statement clause
Hello
is it possible to call a function in a where clause of a select statement clause?
ex: select col1, col2
from my_table
where my_package.my_function (32199, 2008, col3, 'P');
and I have the error message ' ORA-00920: invalid relational operator.
FUNCTION ma_fonction (v_matricule in NUMBER,
v_Year in NUMBERS
T_DATE IN a DATE,
v_type in DEFAULT CHAR 'P')
RETURN A BOOLEAN VALUE;
@+ RosagioYes, it is possible.
But you have no relational operator:
where my_package.my_function (32199, 2008, col3, 'P') =?
where my_package.my_function (32199, 2008, col3, 'P') >?
where my_package.my_function (32199, 2008, col3, 'P')<>Oops, I just noticed that your function returns a Boolean value.
Can't do that as in a SQL statement.
Boolean is known only to other code PL/SQL, no SQL statements.
Published by: SomeoneElse on November 7, 2008 09:24
-
How to convert this select statement in the update
Hai All
I have two tables namely Daily_attend, Train_mast
The Daily_attend are made up of fields are Train_mast are made up of fields are
Name varchar form no var
Date of empcode Num V_DATE
Intimate Date Train_name var
Outtime date Late_hrs var
Number IND_IN
Number IDE_OUT
Date of Attend_date
I need to update the table Depend of IDE_IN in Daily_attend in late_hrs in the Train_mast table
I got through in the select statement, it is my select statement
Select to_number (TO_DATE (TO_CHAR(Intime,'DD-MON-YYYY') |)) » '||
To_char (0815, '0000'), 'MON-DD-YYYY HH24') + late_hrs /(24*60)-respondent
) * 24 * 60 dail_Att, train_mast;
How can I convert to update
Any help is highly appricateable
Thanks in advance
Concerning
Srikkanth.MSrikkanth,
Try this code. And 1 thing, I don't see any WHERE condition to join between the 2 tables, DAIL_ATT, TRAIN_MAST.
UPDATE DAIL_ATT A SET A.IDE_IN = (SELECT TO_NUMBER(TO_DATE(TO_CHAR(INTIME, 'DD-MON-YYYY')|| ' ' || TO_CHAR(0815, '0000'), 'DD-MON-YYYY HH24:MI') + LATE_HRS / (24 * 60) - INTIME) * 24 * 60 FROM TRAIN_MAST B WHERE
); Kind regards
Manu.
If my answer or the answer to another person has been useful or appropriate, please mark accordingly
-
Hello
I have this scenario where I have to pass multiple values to a parameter of a procedure of monkey and then collect in another variable (the lines can be multiple).
The parameter must be used in the where clause of the statement select here I create a sample table for the problem.
Create table test_tab (number of trans_id, cmts varchar2 (50));
insert into test_tab values (568890112115, ' wnlb-CMTS-11-04' ");
insert into test_tab values (568890112115, ' wnlb-CMTS-11-04' ");
insert into test_tab values (568890112115, ' wnlb-CMTS-11-01' ");
insert into test_tab values (568890112115, ' wnlb-CMTS-11-01' ");
insert into test_tab values (568890112115, ' wnlb-CMTS-11-01' ");
insert into test_tab values (568890112115, ' wnlb-CMTS-12-02' ");
insert into test_tab values (568890112115, ' wnlb-CMTS-12-02' ");
This is so all cmts have same trans_id but different name
This query gives the result as -
Select the cmts, count (1)
of test_tab
where cmts ("wnlb-cmts-11-04','wnlb-cmts-11-01", "wnlb-CMTS-11-02'")
and trans_id = 568890112115
Cmts group;
COUNTY OF CMTS
WNLB-CMTS-11-04 2
3 WNLB-CMTS-11-01
Now, I want to use this query in a PLSQL block like where I can spend the CMTS collection and trans_id as a scalar variable and once again an OUTPUT parameter that holds the result of the query.
I use OUT parameter because it will be called to the JAVA program.
Here, I write a PACKAGE for it but it gives me compilation error!
create or replace package CMTS_SUCCESS_FAILED_API
is
type t_item_name is table of index varchar2 (50) by pls_integer;
TYPE t_cmts_count () IS RENDERING
CMTS VARCHAR2 (30),
number of NUMBER
);
type t_reseg_dtl is table of index t_cmts_count by pls_integer;
procedure CMTS_SUCCESS_FAILED_RESEG_ORDR (p_item_name t_item_name, p_trans_id in numbers, p_reseg_dtl to t_reseg_dtl);
end CMTS_SUCCESS_FAILED_API;
/
Now that I have created a different PACKAGE BODY, but none don't work!
1.
create or replace package CMTS_SUCCESS_FAILED_API
is
type t_item_name is table of index varchar2 (50) by pls_integer;
TYPE t_cmts_count () IS RENDERING
CMTS VARCHAR2 (30),
number of NUMBER
);
type t_reseg_dtl is table of index t_cmts_count by pls_integer;
procedure CMTS_SUCCESS_FAILED_RESEG_ORDR (p_item_name t_item_name, p_trans_id in numbers, p_reseg_dtl to t_reseg_dtl);
end;
/
create or replace package CMTS_SUCCESS_FAILED_API body
is
procedure CMTS_SUCCESS_FAILED_RESEG_ORDR (p_item_name t_item_name, p_trans_id in numbers, p_reseg_dtl to t_reseg_dtl)
is
Start
I'm in p_item_name.first... p_item_name. Last
loop
Select the cmts, count (1)
bulk collect into p_reseg_dtl (i)
of test_tab
where cmts = p_item_name (i)
and trans_id = p_trans_id
Cmts group;
end loop;
for r in p_reseg_dtl.first... p_reseg_dtl. Last
loop
dbms_output.put_line (p_reseg_dtl (r). TRANSACTION_ID | » '|| p_reseg_dtl (r). JOB_STATUS | » '|| p_reseg_dtl (r). CMTS);
end loop;
end CMTS_SUCCESS_FAILED_RESEG_ORDR;
end CMTS_SUCCESS_FAILED_API;
While I run this procedure it is said TOO_MANY LINES.
2.
create or replace package CMTS_SUCCESS_FAILED_API body
is
procedure CMTS_SUCCESS_FAILED_RESEG_ORDR (p_item_name t_item_name, p_trans_id in numbers, p_reseg_dtl to t_reseg_dtl)
is
cursor c_dtl is
Select the cmts, count (1)
of test_tab
where cmts = p_item_name < < error
and trans_id = p_trans_id
Cmts group;
Start
Open c_dtl;
collect the fetch c_dtl in bulk in p_reseg_dtl;
close c_dtl;
-for i in p_item_name.first... p_item_name. Last
-loop
-end loop;
end;
end;
THIS error GIVES BODY as EXPRESSION IS OF TYPE INCORRECT for where clause where I mark it as "BOLD".
I think Miss me a small detail to add here, but I can't do even now it seems for me that I'm working on it since the morning and SQL are a little complex in real time who also write.
I use-Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production
Please suggest me!
Until then I'm also working on this issue hope will find a solution.
In the database (we show it with a standalone function, you should put it in a package):
create or replace function CMTS_SUCCESS_FAILED_RESEG_ORDR ( p_item_name IN SYS.DBMS_DEBUG_VC2COLL, p_trans_id IN number ) return sys_refcursor is l_refcur sys_refcursor; begin open l_refcur for SELECT cmts , COUNT(*) FROM test_tab WHERE cmts member of p_item_name AND trans_id = p_trans_id GROUP BY cmts; return l_refcur; end CMTS_SUCCESS_FAILED_RESEG_ORDR; /
In Java:
import java.math.BigDecimal; import java.sql.CallableStatement; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import oracle.jdbc.OracleCallableStatement; import oracle.jdbc.OracleTypes; import oracle.jdbc.pool.OracleDataSource; import oracle.sql.ARRAY; import oracle.sql.ArrayDescriptor; public class SQLCollection { public static void main(String[] args) throws SQLException { System.out.println("Class SQLCollection started."); OracleDataSource ods = null; Connection conn = null; CallableStatement cs = null; ResultSet rset = null; try { ods = new OracleDataSource(); String url = "jdbc:oracle:thin:@//127.0.0.1:1522/orcl.localdomain"; ods.setURL(url); ods.setUser("stew"); ods.setPassword("stew"); conn = ods.getConnection(); conn.setAutoCommit(false); ArrayDescriptor oracleVarchar2Collection = ArrayDescriptor.createDescriptor("SYS.DBMS_DEBUG_VC2COLL", conn); String[] inset = new String[2]; inset[0] = "wnlb-cmts-11-04"; inset[1] = "wnlb-cmts-11-01"; ARRAY ora_inset = new ARRAY(oracleVarchar2Collection, conn, inset); cs = conn.prepareCall("begin ? := CMTS_SUCCESS_FAILED_RESEG_ORDR(?, ?); end;"); cs.registerOutParameter(1, OracleTypes.CURSOR); cs.setArray(2, ora_inset); cs.setBigDecimal(3, new BigDecimal("568890112115")); cs.execute(); // Dump the cursor rset = ((OracleCallableStatement)cs).getCursor(1); while (rset.next()) System.out.println(rset.getString(1) + ": " + rset.getInt(2)); } catch (Exception e) { e.printStackTrace(); } finally { if (rset != null) { rset.close(); } if (cs != null) { cs.close(); } if (conn != null) { conn.close(); } System.out.println("Class SQLCollection ended."); } } }
-
Conditional clause in the select statement
Hi all
Suppose for example of diagram of HR that I have the following query where it counts the number of Department based on their identity papers and the total number of jobs:
The total number of global jobs regardless of which Department is 107. Question: How to make a query that displays the result above and makes the JOBID and DEPARTMENTID column value to two TotalAgregate where the count indicates 107? Like this:SQL> select decode(grouping(job_id),1,'total_job',job_id) as JobID, decode(group ing(department_id),1,'all_department',department_id) as DepartmentID, count(*) f rom employees group by rollup(job_id,department_id) order by job_id,department_i d; JOBID DEPARTMENTID COUNT(*) ---------- ---------------------------------------- ---------- AC_ACCOUNT 110 1 AC_ACCOUNT all_department 1 AC_MGR 110 1 AC_MGR all_department 1 AD_ASST 10 1 AD_ASST all_department 1 AD_PRES 90 1 AD_PRES all_department 1 AD_VP 90 2 AD_VP all_department 2 FI_ACCOUNT 100 5 JOBID DEPARTMENTID COUNT(*) ---------- ---------------------------------------- ---------- FI_ACCOUNT all_department 5 FI_MGR 100 1 FI_MGR all_department 1 HR_REP 40 1 HR_REP all_department 1 IT_PROG 60 5 IT_PROG all_department 5 MK_MAN 20 1 MK_MAN all_department 1 MK_REP 20 1 MK_REP all_department 1 JOBID DEPARTMENTID COUNT(*) ---------- ---------------------------------------- ---------- PR_REP 70 1 PR_REP all_department 1 PU_CLERK 30 5 PU_CLERK all_department 5 PU_MAN 30 1 PU_MAN all_department 1 SA_MAN 80 5 SA_MAN all_department 5 SA_REP 80 29 SA_REP 1 SA_REP all_department 30 JOBID DEPARTMENTID COUNT(*) ---------- ---------------------------------------- ---------- SH_CLERK 50 20 SH_CLERK all_department 20 ST_CLERK 50 20 ST_CLERK all_department 20 ST_MAN 50 5 ST_MAN all_department 5 total_job all_department 107 40 rows selected.
Best regardsJOBID DEPARTMENTID COUNT(*) ---------- ---------------------------------------- ---------- AC_ACCOUNT 110 1 AC_ACCOUNT all_department 1 AC_MGR 110 1 AC_MGR all_department 1 AD_ASST 10 1 AD_ASST all_department 1 AD_PRES 90 1 AD_PRES all_department 1 AD_VP 90 2 AD_VP all_department 2 FI_ACCOUNT 100 5 JOBID DEPARTMENTID COUNT(*) ---------- ---------------------------------------- ---------- FI_ACCOUNT all_department 5 FI_MGR 100 1 FI_MGR all_department 1 HR_REP 40 1 HR_REP all_department 1 IT_PROG 60 5 IT_PROG all_department 5 MK_MAN 20 1 MK_MAN all_department 1 MK_REP 20 1 MK_REP all_department 1 JOBID DEPARTMENTID COUNT(*) ---------- ---------------------------------------- ---------- PR_REP 70 1 PR_REP all_department 1 PU_CLERK 30 5 PU_CLERK all_department 5 PU_MAN 30 1 PU_MAN all_department 1 SA_MAN 80 5 SA_MAN all_department 5 SA_REP 80 29 SA_REP 1 SA_REP all_department 30 JOBID DEPARTMENTID COUNT(*) ---------- ---------------------------------------- ---------- SH_CLERK 50 20 SH_CLERK all_department 20 ST_CLERK 50 20 ST_CLERK all_department 20 ST_MAN 50 5 ST_MAN all_department 5 TotalAgregate TotalAgregate 107 40 rows selected.
ValerieI do not have the HR schema to play with, but isn't it just a nested decode it takes?
for example something like...
select decode(grouping(job_id),1,'TotalAggregate',job_id) as JobID ,decode(grouping(department_id),1,decode(grouping(job_id),1,'TotalAggregate','all_department'),department_id) as DepartmentID ,count(*) from employees group by rollup(job_id,department_id) order by job_id,department_id;
-
SELECT statement in a Package body
I have the following in my package body and it gives me an error:
- Error (7.1): PLS-00428: an INTO clause in this SELECT statement
PROCEDURE MyQuery
AS
BEGIN
Select * from customer;
END MyQuery;
The error message is correct.
Your selection must have an INTO clause and must return 1 and only 1 row.
-
Insert and update by the select statement
Hi all
How can I insert and update in an oracle 10g database table
by a select statement. do not merge.Florian wrote:
Hi all
How can I insert and update in an oracle 10g database table
by a select statement. do not merge.
>How can I insert and update in a table of database oracle 10g via a select statement. do not merge.
Do you mean by using subqueries?
Something like
insert into whatever ...select statement update whatever set (column, column) = (select column, column ...)
There is a lot of information on this topic in the online documentation
-
There are two select statement, which are as follows: 1) select project id, the name of ppm.pm_projects project_name and request_id 2) select id, name from request_type_name to kcrt_request_details. There is a column called entity that can store a value i.e. project or request. I want to write a select statement containing a condition that is if the entity name is project and then run the select statement 1 otherwise, if the name of the entity's request, then run the select statement 2. All this must be written in a select statement. Can someone help me how to write this select statement type.
Hello
Hello
2726057 wrote:
... There is a column called entity that can store a value i.e. project or request. ...
In which table is this column? Assuming that it is in a table called entity_table, you can do something like this:
SELECT project AS id
project name AS the name
OF ppm.pm_projects
WHEN THERE IS)
SELECT 1
Of entity_table
Entity WHERE = "Project".
)
UNION ALL
SELECT request_id ID
request_type_name AS name
OF kcrt_request_details
WHEN THERE IS)
SELECT 1
Of entity_table
Entity WHERE = 'ask '.
)
;
This does not have anything on the number of lines is entity_table, or what are the values in the column of the entity. In other words, the query works in all cases. If any line in entity_table entity = 'Project', then the pm_projects data will be included in the result set. If any line in entity_table entity = 'Request', kcrt_request_details data will be included.
I hope that answers your question.
If this isn't the case, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum: https://forums.oracle.com/message/9362002#9362002
-
Impossible to get a select statement to work
Hi guys, I tried to get this select statement to work. But it won't be fair
SELECT THE "GEN".
WHEN'M ' THEN 'MALE '.
WHEN 'F' THEN 'WOMAN '.
END OTHER 'UNKNOWN '.
THE EMPLOYEE
That run, however, I just get unknown ranks.
Summer racking me my brains on this simple thing for a half hour :(
Thanks :)HC wrote:
Otherwise, if I have not ' around GEN, then it says it's an invalid identifier.
Who says table used has no column named gen. You use SQL * more? If so, publication:
employee of ESCR
This will give you a list of columns in the table. Make sure that gen is one of the columns.
SY.
-
How to INSERT a SELECT statement with a GROUP BY clause on a table with an IDENTITY column?
n an application, I intend to truncate and insertion on a 12 c Oracle database, but have found this problem with a
IDENTITY
column. Even if theINSERT... SELECT
statement works on mostSELECT
uses I tried, if this statement was also aGROUP BY
clause, it does not work, delivering a "ORA-00979: not aGROUP BY
expression ' complaint. Some examples of code:create table aux ( owner_name varchar2(20), pet varchar2(20) );
insert into aux values ('Scott', 'dog');
insert into aux values ('Mike', 'dog');
insert into aux values ('Mike', 'cat');
insert into aux values ('John', 'turtle');
create table T1 (
id number generated always as identity,
owner_name varchar2(20),
pet_count number );
select owner_name, count(*) as pet_count from aux group by owner_name; -- works just fine
insert into T1 (owner_name, pet_count) select owner_name, count(*) as pet_count from aux group by owner_name; -- doesn't work
The select statement works by itself, but it fails as an INSERT... SELECT statement.
Appreciate the help!
Looks like a bug. You must open the SR with Oracle. Meanwhile, you could materialize select:
SQL > insert into T1 (owner_name, pet_count)
2 with t as (select / * + materialize * / owner_name, count (*) as pet_count to the owner_name group)
3. Select owner_name, pet_count t
4.3 lines were created.
SQL > select * from t1;
ID OWNER_NAME PET_COUNT
---------- -------------------- ----------
1 John 1
Scott 2 1
3 Mike 2SQL >
Keep in mind index THAT MATERIALIZE is undocumented.
SY.
-
If then the clause for a simple select statement.
Good afternoon
I'm sure this will be really simple for a person: I have three paintings that I need to access it in a simple select statement. However, I need to make two separate petitions by a field has an entry or not. Here is the code I wrote so far. It is only to retune the ELSE part, which means that I know I'm close, but I know I'm missing something incredibly simple and boring for me right now.
IF common_event.efeanme IS NULL THEN SELECT a.num_1 AS "EVENT NUMBER", CONCAT(CONCAT(CONCAT(CONCAT(SUBSTR(a.cdts,5,2), '/'), SUBSTR(a.cdts,7,2)), '/'), SUBSTR(a.cdts,1,4)) AS "EVENT DATE", CONCAT(CONCAT(c.xstreet1, ' / '), c.xstreet2) AS "EVENT LOCATION" FROM common_event c JOIN agency_event a ON c.eid=a.eid JOIN disposition_type d ON a.ag_id=d.ag_id WHERE a.ag_id='JCSO' AND a.lev3='JC3' AND a.cdts BETWEEN '20140701' AND '20141001' AND d.tycod='CIT' ORDER BY a.num_1; ELSE SELECT a.num_1 AS "EVENT NUMBER", CONCAT(CONCAT(CONCAT(CONCAT(SUBSTR(a.cdts,5,2), '/'), SUBSTR(a.cdts,7,2)), '/'), SUBSTR(a.cdts,1,4)) AS "EVENT DATE", CONCAT(CONCAT(CONCAT(CONCAT(CONCAT(CONCAT(c.estnum, ' '), c.edirpre), ' '), c.efeanme), ' '), c.efeatyp) AS "EVENT LOCATION" FROM common_event c JOIN agency_event a ON c.eid=a.eid JOIN disposition_type d ON a.ag_id=d.ag_id WHERE a.ag_id='JCSO' AND a.lev3='JC3' AND a.cdts BETWEEN '20140701' AND '20141001' AND d.tycod='CIT' ORDER BY a.num_1; END IF;
If I run a query on its own, it works as expected. Which means that I don't get something right (in my opinion) in my CASE SO the ELSE clause. As I said, it's probably something so simple I forget only she, but I better ask for a direction somewhat see where I'm going to do it right.
Thanks in advance for any guidance.
Tony
Cant you just do:
SELECT a.num_1 'EVENT NUMBER. "
Concat (Concat (Concat (Concat (substr (a.CDTS, 5, 2), ' / '), SUBSTR (a.cdts, 7, 2)), ' / '), SUBSTR (a.cdts, 1, 4)) AS 'EVENT DATE ',.
-case when c.efeanme IS NULL
then CONCAT (CONCAT (c.xstreet1, ' /'), c.xstreet2)
of another CONCAT (CONCAT (CONCAT (CONCAT (CONCAT (CONCAT (c.estnum, ' '), c.edirpre), ' '), c.efeanme), ' '), c.efeatyp)
end AS 'EVENT ADDRESS'
OF common_event c
JOIN THE
agency_event one
WE c.eid = a.eid
JOIN the disposition_type d
ON a.ag_id = d.ag_id
WHERE a.ag_id = 'JCSO.
AND a.lev3 = 'JC3.
AND a.cdts BETWEEN '20140701' AND '20141001'
AND d.tycod = 'CIT '.
ORDER BY a.num_1
Concerning
Etbin
Deleted AND c.efeanme IS NULL
-
Exception No_data_found to insert into... select statement
Hai,
I have a doubt in plsql exceptions. In the sub program mentioned plsql.
Start
insert into select abc * xyz a, b of cdf where a.c1 = b.c2;
exception
When no_data_found then
do some operations
end;
In the pl/sql block above, if the select statement returns no rows, whether or not the exception is triggered? If not, how do the same. Any available alternative.
Thanks in advance.
Concerning
SridharYou would get an error no_data_found triggered at that time there, because it's perfectly valid to insert rows 0.
You will need to check SQL ROWCOUNT % and raise the no_data_found if it is equal to 0.
Maybe you are looking for
-
Please, I beg you! Firefox for OS 10.4.11, am desperate!
I can't use a service online because of old safari, andmy Firefox has disappeared. I hope you can get a compatibleinherited. I'll be happy to pay you. Thank you very much.
-
Satellite L300-1BV - series of blue screens
Hello normal startup - impossible safe mode - for 5 minutes of most, the screens, then blue, giving various critical errors -checked with a Vista Ultimate DVD to reinstall the OS, do not: "error - \windows\system32\ntkrnlpa.exe file is missing or dam
-
Sony PC Companion does not work
I try to repair my phone with Sony PC companions Support area. When I try to run it I get an error message:"Try to agenow from another computer, which directs winds 8.1, Windows 7 or an earlier version of the operation system".I use Windows 8 Pro. An
-
4.4.4 Android deployment
Have no clue as to when we can see 4.4.4 for the Z2?
-
I have problem with screenshooT. I thought that I can my notification panel screenshoot or take a screenshoot just by swap my hand as the samsung phone. In fact, I'm wrong. And that's my regret buying this phone T__T