sql statement that activates the trigger to capture
HelloI'm trying to enter the sql code that activates the trigger with this procedure:
CREATE OR REPLACE TRIGGER t_trg
after insert or update
on the manikin
for each line
declare
long p_stmt;
sql_lines directory.
MSG VARCHAR2 (32000);
Return VARCHAR2 (2): = Chr (13).
triggering_sql dbms_standard.ora_name_list_t;
Start
-get the SQL trigger
sql_lines: = sql_txt (triggering_sql);
FOR loop_counter IN triggering_sql. FIRST... triggering_sql. LAST
LOOP
-Add the SQL trigger to the message
MSG: = msg | triggering_sql (loop_counter) | line feed;
END LOOP;
Insert into values dummy2 (msg) (cad);
end t_trg;
but...
ORA-06531: Referencia a una recopilacion no inicializada
ORA-06512: en "TRASPASO. T_TRG ', line 11.
ORA-04088: error during the run "TRASPASO del disparador. T_TRG'
Kind regards
Daniel
PD. Sorry for my bad English
Published by: user10660485 on 30 / abr / 2010 0:35
What is your version of the database? There is a bug with this statement. However, you can try the following
CREATE OR REPLACE TRIGGER EMP_TRG1
BEFORE UPDATE ON EMPLOYEES
declare
v_num NUMBER;
sql_stmt varchar2(2000);
sql_text ora_name_list_t;
BEGIN
v_num:=ora_sql_txt(sql_text);
FOR i in 1..NVL(v_num,0) LOOP
sql_stmt:=sql_stmt||sql_text(i);
END LOOP;
INSERT INTO EMP_LOG VALUES(sql_stmt);
--dbms_output.put_line(sql_stmt);
END;
In my database to Oracle Database 10g Express Edition Release 10.2.0.1.0 that it always returns the value null;
For more information, please visit http://www.orafaq.com/forum/t/68667/2/
Tags: Database
Similar Questions
-
Identify the SQL statements that are executed frequently
I would like to identify SQL statements that are executed may times (e.g., > 1000 times) during an interval AWR.
I am aware of coloring a SQL_ID with exec ('...') dbms_workload_repository.add_colored_sql; but then the SQL ID must be known.
Is it also possible to do the same for the (not yet known) SQL statements that are executed > 1000 times? I think that the SQL statements that run very quickly (for example 1 s <) won't be captured automatically in a CWA even if those statements are frequently performed.
Version 11.2.0.4 on SLES11
Try this...
fixed lines 155
execs from collar to 999 999 999
Col min_etime to 999,999.99
Col max_etime to 999,999.99
Col avg_etime to 999,999.999
Col avg_lio to 999,999,999.9
Col norm_stddev to 999,999.9999
Col begin_interval_time to a30
node of col to 99999
break on plan_hash_value on startup_time skip 1
Select * from)
Select sql_id, sum (execs), min (avg_etime) min_etime, max (avg_etime) max_etime stddev_etime/min (avg_etime) norm_stddev
de)
Select sql_id, execs, plan_hash_value, avg_etime,
StdDev (avg_etime) on stddev_etime (sql_id partition)
de)
Select sql_id, plan_hash_value,.
Sum (NVL(executions_delta,0)) execs,
(sum (elapsed_time_delta) /decode (sum (nvl(executions_delta,0)), 0.1, sum (executions_delta)) / 1000000) avg_etime
-sum ((buffer_gets_delta/decode (nvl(buffer_gets_delta,0), 0.1, executions_delta))) avg_lio
DBA_HIST_SQLSTAT s, DBA_HIST_SNAPSHOT SS
where ss.snap_id = S.snap_id
and ss.instance_number = S.instance_number
and executions_delta > 0
Group of sql_id, plan_hash_value
)
)
Group of sql_id, stddev_etime
)
where norm_stddev > nvl (to_number('&min_stddev'), 2)
and max_etime > nvl (to_number('&min_etime'),.1)
order of norm_stddev
/
-
How to execute a SQL statement that is stored within a SQL Table
Hello
If someone please help me with the following problem I would be eternally grateful
I have a SQL statement that is stored inside a certain SQL table, I want to use this SQL statement inside my PL/SQL procedure.
Thought a simple solution was to get the SQL statement in a table, and then run it, but how could I do so exactly with PL/SQL? I only started to play with PL/SQL in the last days.
Thanks in advance!
This is what it looks like more or less:
Display result for:
---------------------
SELECT TRIM (OBJ_VALU_TXT)
OF OBJ_VALU_DOC
WHERE TYPE_OBJET = 'FLD '.
AND OBJECT_CODE = 15443
AND OBJ_VALU_CD = 'CAB '.
ORDER BYDOC_SEQ_NO
00001
------------------------------------------------------------------
SELECT
VALUE (MAX (RECEIPT_NO) + 1,: OUT-COMP-FACTOR)
THE FRONT DESK
WHERE (RECEIPT_NO BETWEEN
(: OUT-COMP-FACTOR AND: OUT TO A NUMBER) OR
(RECEIPT_NO >: OUT-COMP-FACTOR AND)
(: OUT-TO-NUMBER = 0)
Here's a demo of your condition.
create table t (col1 varchar2 (200));
table created
insert into values t ('select * from double ');
1 row inserted
declare
v_col varchar2 (200);
v_val varchar2 (200);
StartSelect col1 in t v_col;
run immediately v_col in v_val;
dbms_output.put_line (v_val);
end;-----
XUse in the clause, you can use as many variables as needed. But the basic approach remains the same.
But storage in DB SQL is not an efficient design.
Ishan
-
See all SQL statements that have been executed in a transaction active?
When I ask transaction$ v, $session of v and v$ sql, all that I see is the SQL statement being executed in a transaction active.
How can I view all of the SQL statements that were executed as part of an operation running since the beginning of this transaction?If you use database 11g, you can use bed > view and manage Transactions that shows all the steps of sql in transactions.
KDSDBA
OCP -
SQL statement to select the tables that are updated today...
Hi guys,.
I need to find the names of all the tables that contain rows that are inserted/updated on a given time stamp...
Below the statement gives me the list of all tables in the database...
All these tables in the database have a rowversion column which gives the date of update/insertion of a record. I need to write a select statement (probably dynamic) that will give me the names of the tables that contain the rowversion value 24/01/2013...select t.table_name from all_tables t;
Any help is appreciated...Napster says:
Hi kitsoukou,Thanks for your reply...
But when I run your select statement I get an error indicating that the table SYS. DBMS_XMLGEN does not exist.
Probably something wrong in my environment?
If I'm not mistaken there are DBMS_XMLGEN 9i.
The source code is available under
karthick% ls -lrt $ORACLE_HOME/rdbms/admin/dbmsxml.sql -rw-r--r-- 1 oracle dba 7977 Mar 23 2004 /home/oracle/product/10.2.0.5/rdbms/admin/dbmsxml.sql
You can take this and run to install DBMS_XMLGEN.
-
"PL/SQL: statement ignored ' from the outset?
I am brand new to PL/SQL and I just can't understand what is wrong. Any help?
I did very simple procedures with several settings, but this code just won't go.SQL> SQL> create or replace procedure HW3 ( 2 p_buy number ) as 3 4 v_pay number; 5 6 begin 7 v_pay := p_buy(3/4); 8 9 dbms_output.put_line ('You entered: ' || p_buy); 10 dbms_output.put_line ('You will be charged for: '||trunc(v_pay)); 11 12 end; 13 / Warning: Procedure created with compilation errors. SQL> SQL> show errors; Errors for PROCEDURE HW3: LINE/COL ERROR -------- ----------------------------------------------------------------- 7/2 PL/SQL: Statement ignored 7/11 PLS-00222: no function with name 'P_BUY' exists in this scope SQL> SQL> spool off
Have you defined a p_buy function?
Or finally do you hear that in the first line after begin in your code?
v_pay := p_buy * (3/4);
When you write p_buy(3/4) the compiler thinks p_buy is a function and you want to call with parameter 3/4.
Published by: hm on 11.10.2011 23:39
-
Run the second sql statement only if the first sql statement is set to zero.
Hey guys I seem to have a mental block here. I have two sql statements. I would like to than the second to run only if the first sql statement is set to zero. I know that I can use PLsql but I would really like to see if I can do this with sql upward. Your answers are very much appreciated.
This is the first sql
second sql statementSelect ft.fund_code, ft.orgn_code, ft.acct_code, ft.amount, fb.owner_pidm, ft.prog_code from ftrbremb fb , ftcractg ft where fb.doc_code = 'TR000038' and fb.ftpbport_id = ft.ftpbport_id
How can I combine these two statements together so that when the first is null the second run. As a bonus, I want to get just the first line as well.Select ft.fund_code, ft.orgn_code, ft.acct_code, ft.amount, fb.owner_pidm, ft.prog_code from ftrbremb fb , ftcractg ft, ftprexps fx where fb.doc_code = 'TR000038' --and fb.ftpbport_id = ft.ftpbport_id and fx.ftrbremb_id = fb.id and ft.ftprexps_id = fx.id;
Any help would be greatly appreciated. I tried to accomplish with the case statement but it dosent everything seems to work for me.
Thank youMiguel,
the idea is simple: join the two queries (via the union of all) and to change the second part as to return only the rows if the first query returns no rows by changing the NOT EXISTS (first request). Hope I made it clear... ;)
-
SQL statement that was passed in a procedure or trigger
Hello
OK, alright its really weird, but I have a good reason for it. I'll post my reason in a response to this post in order not to clutter.
I have the following trigger
BEFORE INSERT ON I_RUN_SQL_LOCAL
FOR EACH LINE
BEGIN
SELECT I_RUN_SQL_LOCAL_SEQ. NEXTVAL INTO: NEW. RECID FROM DUAL;
/ * Execute the sql command * /.
: NEW. SQL_COMMAND
END;
I get errors when I compile it.
The SQL_COMMAND field is varchar2 (200) and is supposed to have a SQL command in it like...
"Delete from < table_name > '.
How to run the text in: NEW. SQL_COMMAND?
Thank you
ScottHow to run the text in: NEW. SQL_COMMAND?
execute immediate 'the text in :NEW.SQL_COMMAND'
Concerning
Etbin
http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14261/executeimmediate_statement.htm#LNPLS01317
He appeared somewhat weird (as a joke) so a link should be provided
Edited by: Etbin on 1.8.2009 08:33
-
Select SQL statement - See all the value of the range of month of entry
Hi all
I have a vision that is a union of other views
But the description of the view is as below
-current data in the viewdesc dashboard_monthly_view Name Null Type ------------------------------ ---- ------------ MONTHS VARCHAR2(17) NUM_DEPENDENT_IN_ASSESSMENT NUMBER NUM_REFERRED_AODTC NUMBER NUM_AT_DETERMINATION_HEARING NUMBER NUM_ACCEPTED NUMBER NUM_NOT_ACCEPTED NUMBER NUM_EXITED_SUCCESS NUMBER AVERAGE_DAY_TO_EXIST NUMBER NUM_EXITED_UNSUCCESS NUMBER AVERAGE_DAY_TO_EXIST_UNSUCCESS NUMBER COURT_NAME VARCHAR2(9)
-My select query isMONTHS NUM_DEPENDENT_IN_ASSESSMENT NUM_REFERRED_AODTC NUM_AT_DETERMINATION_HEARING NUM_ACCEPTED NUM_NOT_ACCEPTED NUM_EXITED_SUCCESS AVERAGE_DAY_TO_EXIST NUM_EXITED_UNSUCCESS AVERAGE_DAY_TO_EXIST_UNSUCCESS COURT_NAME ----------------- --------------------------- ---------------------- ---------------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ------------------------------ ---------- AUG 2012 1 0 0 0 0 0 0 0 0 AAA OCT 2012 8 1 3 1 1 1 44 1 4 AAA SEP 2012 2 0 2 2 0 0 0 0 0 AAA *UNDEFINED* 0 11 7 1 1 0 0 1 0 AAA NOV 2012 0 0 0 0 0 0 0 1 54 BBB OCT 2012 4 1 2 1 1 1 9 0 0 BBB SEP 2012 1 0 0 0 0 1 14 0 0 BBB *UNDEFINED* 0 5 4 1 0 0 0 1 0 BBB AUG 2012 1 0 0 0 0 0 0 0 0 COMBINED NOV 2012 0 0 0 0 0 0 0 1 54 COMBINED OCT 2012 12 2 5 2 2 2 26.5 1 4 COMBINED SEP 2012 3 0 2 2 0 1 14 0 0 COMBINED *UNDEFINED* 0 16 11 2 1 0 0 2 0 COMBINED 13 rows selected
- And the result isDEFINE startmonth = "Aug 2012"; DEFINE endmonth = "Nov 2012"; with all_months as ( select to_char(which_month, 'MON YYYY') month from (select add_months(to_date('&startmonth','MON YYYY'), rownum-1) which_month from all_objects where rownum <= months_between(to_date(NVL('&endmonth', '&startmonth'),'MON YYYY'), add_months(to_date('&startmonth','MON YYYY'), -1)) order by which_month ) ) select nvl(months, '**ALL**') AS "MONTHS", TO_DATE(MONTHS, 'MON YYYY') AS MONTH_SORT , sum(num_dependent_in_assessment) AS num_dependent_in_assessment , sum(num_referred_aodtc) AS num_referred_aodtc , sum(num_at_determination_hearing) as num_at_determination_hearing , sum(num_accepted) AS num_accepted , sum (num_not_accepted) AS num_not_accepted , sum(num_exited_success) as num_exited_success , sum(average_day_to_exist) as average_day_to_exist , sum(num_exited_unsuccess) as num_exited_unsuccess , sum (average_day_to_exist_unsuccess) as average_day_to_exist_unsuccess from DASHBOARD_MONTHLY_VIEW right outer join all_months on DASHBOARD_MONTHLY_VIEW.months = all_months.month --where months in (select month from all_months) and upper(court_name) like 'AAA' group by (months) order by month_sort
-The requirement of results I have to produce isMONTHS MONTH_SORT NUM_DEPENDENT_IN_ASSESSMENT NUM_REFERRED_AODTC NUM_AT_DETERMINATION_HEARING NUM_ACCEPTED NUM_NOT_ACCEPTED NUM_EXITED_SUCCESS AVERAGE_DAY_TO_EXIST NUM_EXITED_UNSUCCESS AVERAGE_DAY_TO_EXIST_UNSUCCESS ----------------- ------------------------- --------------------------- ---------------------- ---------------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ------------------------------ AUG 2012 01/08/12 1 0 0 0 0 0 0 0 0 SEP 2012 01/09/12 2 0 2 2 0 0 0 0 0 OCT 2012 01/10/12 8 1 3 1 1 1 44 1 4 **ALL**
On the tota (* EVERYTHING *) l, I tried to use the rollup but he total average too, which is not correct. I think the reason because he cannot read the form that was used to calculate the column.MONTHS MONTH_SORT NUM_DEPENDENT_IN_ASSESSMENT NUM_REFERRED_AODTC NUM_AT_DETERMINATION_HEARING NUM_ACCEPTED NUM_NOT_ACCEPTED NUM_EXITED_SUCCESS AVERAGE_DAY_TO_EXIST NUM_EXITED_UNSUCCESS AVERAGE_DAY_TO_EXIST_UNSUCCESS ----------------- ------------------------- --------------------------- ---------------------- ---------------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ------------------------------ AUG 2012 01/08/12 1 0 0 0 0 0 0 0 0 SEP 2012 01/09/12 2 0 2 2 0 0 0 0 0 OCT 2012 01/10/12 8 1 3 1 1 1 44 1 4 NOV 2012 01/11/12 0 0 0 0 0 0 0 0 0 **ALL**
How can I fix this, should I create, select another below one, with the sum of each column and the average for the other columns.
Also, the business analyst want to show all the months between the start and end of the month.
I used the right outer join, but apparently does not produce the right result.
If anyone of you have any ideas, please advise.
We use Oracle 11 g, it is a select statement for an Oracle APEX report.
The APEX version is 4.0.2. I'm a junior developer of the APEX and I still have to learn a lot about SQL Oracle analytic function.
Thank you very much in advance.
AnnHi, Ann.
Ann586341 wrote:
... I created a table to contain a simplified version of this viewThank you. It is much easier to work with.
... My query is
DEFINE startmonth = "Aug 2012"; DEFINE endmonth = "Nov 2012"; with all_months as ( select to_char(which_month, 'MON YYYY') month from (select add_months(to_date('&startmonth','MON YYYY'), rownum-1) which_month from all_objects where rownum <= months_between(to_date(NVL('&endmonth', '&startmonth'),'MON YYYY'), add_months(to_date('&startmonth','MON YYYY'), -1)) order by which_month ) ) , tbl_dashboard_active as ( select * from tbl_dashboard_monthly where months != '**UNDEFINED**' ) select tbl.months AS "MONTHS" --, TO_DATE(tbl.MONTHS, 'MON YYYY') AS MONTH_SORT , tbl.num_hearing , tbl.num_exited_success , tbl.avg_day_success_exist , tbl.num_exited_unsuccess , tbl.avg_day_unsuccess_exist from tbl_dashboard_active tbl right outer join all_months am on tbl.months = am.month and upper(tbl.court_name) like 'BBB' UNION ALL select 'ALL' AS "TOTAL" , SUM(tbl.num_hearing) , SUM(tbl.num_exited_success) , round(AVG(tbl.avg_day_success_exist),2) , SUM(tbl.num_exited_unsuccess) , round(AVG(tbl.avg_day_unsuccess_exist),2) --order by to_date(am.month,'MON YYYY') from tbl_dashboard_monthly tbl right outer join all_months am on tbl.months = am.month and upper(tbl.court_name) like 'BBB'
- And the result I got
MONTHS NUM_HEARING NUM_EXITED_SUCCESS AVG_DAY_SUCCESS_EXIST NUM_EXITED_UNSUCCESS AVG_DAY_UNSUCCESS_EXIST ----------------- ----------- ------------------ --------------------- -------------------- ----------------------- AUG 2012 1 0 0 0 0 OCT 2012 1 0 0 2 35 SEP 2012 1 0 0 0 0 ALL 3 0 0 2 11.67
I don't know why even I already filter all lines that the month is undefined, I still have a blank line in the result set.
This is the line for November. You do an outer join, in order to ensure that each value of am.month is displayed, even if it does not match what anyone in tbl. When it does not match anything, then all the columns tbl is supposed to provide will be NULL. You decide to view tbl. months, which is one of the following columns will be NULL. You should display mod. monmth instead.
But if I run for handset Court, I don't see this problem. The reason is that the Court combined have given for all four months?
When you say "on behalf of the combined Court", do you mean the unconditional "upper (tbl.court_name) as"BBB "?
If Yes, that would explain it.Also is it possible to list all the months between the start and end month assuring the user even if the statistics are 0.
Once again, in the case of lines that are present, even if they do not have the status of outer join, all of these columns will be NULL. Use NVL to map these nulls to 0.
and how to sort the month
GROUP OF two expressions, which depend on each other: one for sorting and the other for display.
For the sort expression, you can use months as a DATE. (It seems that you have tried this, but commented on the ORDER BY clause in your query is before the FROM clause.) The ORDER BY clause is always at the end of the query, after the FROM clause.)
Another expression of sorting is the number you used to generate the first month. That's what I used below.Here's a way to get the results you requested:
WITH got_months AS ( SELECT TO_DATE ('&startmonth', 'Mon YYYY') AS startmonth_dt , TO_DATE ( NVL ( '&endmonth' , '&startmonth' ) , 'Mon YYYY' ) AS endmonth_dt FROM dual ) , all_months AS ( SELECT rownum AS month_num , TO_CHAR ( ADD_MONTHS ( m.startmonth_dt , ROWNUM - 1 ) , 'MON YYYY' ) AS months FROM got_months m CROSS JOIN all_objects WHERE ROWNUM <= 1 + MONTHS_BETWEEN ( m.endmonth_dt , m.startmonth_dt ) ) SELECT NVL ( am.months , 'All' ) AS months , SUM (NVL (tbl.num_hearing, 0)) AS num_hearing , SUM (NVL (tbl.num_exited_success, 0)) AS num_exited_success , AVG (NVL (tbl.avg_day_success_exist, 0)) AS avg_day_success_exist , SUM (NVL (tbl.num_exited_unsuccess, 0)) AS num_exited_unsuccess , AVG (NVL (tbl.avg_day_unsuccess_exist, 0)) AS avg_day_unsuccess_exist FROM all_months am LEFT OUTER JOIN tbl_dashboard_monthly tbl ON am.months = tbl.months AND UPPER (tbl.court_name) = 'BBB' GROUP BY GROUPING SETS ( (am.month_num, am.months) , () ) ORDER BY am.month_num ;
Again, I used two GROUP BY expressions: one for sorting, the other for display. These depend on each other, that is, given one, you could derive from each other, and it is not sensible to dependent ROLLUP GROUP BY expressions like that, so I used GROUPING SETS ROLLUP instead, so it would be only 1 rank of great aggregate (in other words, 'all').
Output:
` AVG_ AVG_ NUM_ DAY_ NUM_ DAY_ NUM_ EXITED_ SUCCESS EXITED_ UNSUCCESS MONTHS HEARING SUCCESS _EXIST UNSUCCESS _EXIST --------- ------- ------- ---------- --------- ---------- AUG 2012 1 0 0 0 0 SEP 2012 1 0 0 0 0 OCT 2012 1 0 0 2 35 NOV 2012 0 0 0 0 0 All 3 0 0 2 8.75
-
SQL statement by using the min aggregate function result extract a line - how?
Need help, try to do something seemingly simple. I'll give a simple example to illustrate the problem.
I'll use a simple table of addresses with 4 fields.
Create the table:
complete with 6 rowsCREATE TABLE "ADDRESSES" ( "OWNER_NAME" VARCHAR2(20 BYTE), "STREET_NAME" VARCHAR2(20 BYTE), "STREET_NUMBER" NUMBER ) ;
We now have this:Insert into ADDRESSES (OWNER_NAME,STREET_NAME,STREET_NUMBER) values ('FRED','MAIN',1); Insert into ADDRESSES (OWNER_NAME,STREET_NAME,STREET_NUMBER) values ('JOAN','MAIN',2); Insert into ADDRESSES (OWNER_NAME,STREET_NAME,STREET_NUMBER) values ('JEAN','MAIN',3); Insert into ADDRESSES (OWNER_NAME,STREET_NAME,STREET_NUMBER) values ('JACK','ELM',1); Insert into ADDRESSES (OWNER_NAME,STREET_NAME,STREET_NUMBER) values ('JANE','ELM',2); Insert into ADDRESSES (OWNER_NAME,STREET_NAME,STREET_NUMBER) values ('JEFF','ELM',3);
Select * from addresses
Now, I want to group by street name and obtain a number of houses. At the same time, I would like to know the number of the first and the last HouseOWNER_NAME STREET_NAME STREET_NUMBER -------------------- -------------------- ---------------------- FRED MAIN 1 JOAN MAIN 2 JEAN MAIN 3 JACK ELM 1 JANE ELM 2 JEFF ELM 3 6 rows selected
Excellent. Now for the problem. I would also like to list on each line, the owner who lives at number House first and/or the last. It should be noted, assume that the name of the street and the number is uniqueselect street_name, count(*) "NBR HOUSES", min(street_number) "First Number", max(street_number) "Last Number" from addresses group by street_name produces STREET_NAME NBR HOUSES First Number Last Number -------------------- ---------------------- ---------------------- ---------------------- ELM 3 1 3 MAIN 3 1 3 2 rows selected
It seems I have everything that I need. Don't know how to get home.
I tried:
But getting a syntax error sql group function unauthorized when I add the subselect statement.select street_name, count(*) "NBR HOUSES", min(street_number) "First Number", max(street_number) "Last Number", (Select b.owner_name from addresses b where b.street_number = min(street_number) and b.owner_name = owner_name) "First Owner" from addresses group by street_name
any ideas?
Thanks for any help.
Published by: user6876601 on November 19, 2009 19:08
Published by: user6876601 on November 19, 2009 19:30Hello
Welcome to the forum!
Get the minimum and maximum number for each street is a pretty simple concept; simpler to describe and simple to code.
Now you want to the owner_name associate the maximum and minimum, which is a concept more complex; a little more difficult to describe and, unfortunately, much less simple to code and much, much more difficult to explain:select street_name, count (*) "NBR HOUSES", min (street_number) "First Number", min (owner_name) KEEP (DENSE_RANK FIRST ORDER BY street_number) "First Owner", max (street_number) "Last Number", min (owner_name) KEEP (DENSE_RANK LAST ORDER BY street_number) "Last Owner" from addresses group by street_name ;
You will notice that I used min for "Original owner" and "last owner". Why is this?
The key word in these functions is the FIRST or the LAST word that comes after DENSE_RANK and before ORDER BY. The function at the beginning is simply a break.In other words, MIN in this context refers only to what needs to happen when there is a link to the first or last in the group. Even if such a thing is impossibe in your data, generic functions must have a mechanism to return a single owner_name when two or more rows have an equal right to having the highest street_number. For example, if we change the address of Joan in 1 hand, then MIN (street_number) is always 1, of course, but who is the person associated with the minimum street_number: Fred or Joan? Both have an equal claim that he owns with the smallest address on Main Street, but aggregate functions must return a single value, so we must have a mechanism to indicate to the system, whether to return 'JOAN' or 'FRED '. In this example, I arbitrarily in the network said een of tie, the lowest name, in alphabetical order, must be returned. In this case, 'FRED' would return, "FRED" prior to "JOAN".
Thank you for including CREATE TABLE and INSERT!
-
SQL QUERY THAT RETURNS THE PL/SQL
Hello
I'm putting in 4.2 below apex
DECLARE
date of frdate: =: P22_FROMDATE;
date date: =: P22_TODATE;
l_date1 varchar2 (11): = to_char(frdate,'dd-mon-yyyy');
l_date2 varchar2 (11): = to_char(todate,'dd-mon-yyyy');
v_sql varchar2 (32000);
v_Name varchar2 (4000): = months_name (frdate, todate);
char (1) of the v1: = q "[']";
number of lbr1 (6): =: P22_FROMBRANCH;
number of LBR2 (6): =: P22_TOBRANCH;
number of M1 (6): = 11;
Start
v_sql: ='SELECT * FROM (SELECT LBRCODE, PRDACCTID, MN, AVGX FROM (SELECT LBRCODE, PRDACCTID, MN, SUM (BALL) BALL, COUNT (MN) DAYS, ROUND (SUM (BAL) count (MN), 2) AVGX ';))
v_sql: = v_sql | "FROM (SELECT LBRCODE, PRDACCTID, TO_CHAR (BALDATE,'|)) CHR (39) | ' MM' | CHR (39) |') ' | ' ||'|| CHR (39) | » _'|| CHR (39) |' | ' || «TO_CHAR (BALDATE,'|)» CHR (39) | ' AAAA '. CHR (39) |') MN, BALL ';
V_SQL: = V_SQL | "(SELECT Q2. LBRCODE, Q2. PRDACCTID, T1. BALDATE, T_OST_NEW (Q2. LBRCODE, Q2. PRDACCTID, T1. BALDATE) BALL ';
V_SQL: = V_SQL | "FROM (select TO_DATE('||) Chr (39) | l_date1 | Chr (39) | «, » || CHR (39) | ' DD-MON-YYYY ' | CHR (39) |') baldate FROM DUAL Union all the ';
V_SQL: = V_SQL |' select (TO_DATE('||) Chr (39) | l_date1 | Chr (39) | «, » || CHR (39) | ' DD-MON-YYYY ' | CHR (39) |') + level) double baldate ';
V_SQL: = V_SQL |' connect by level < = (TO_DATE('||) Chr (39) | l_date2 | Chr (39) | «, » || CHR (39) | ' DD-MON-YYYY ' | CHR (39) |') -TO_DATE('||) Chr (39) | l_date1 | Chr (39) | «, » || CHR (39) | ' Dd-mon-yyyy ' | CHR (39) |')) ) Q1,';
V_SQL: = V_SQL | "(SELECT LBRCODE,'|) ' (rpad (prdcd, 8,'|)) V1 ||'' || v1 |') || LTRIM (rpad('|| v1 ||) » x'|| V1 | «, 25, » || v1 | » 0' || v1||'),'|| v1 | » x'|| v1 |')) prdacctid OF D009021 WHERE the LBRCODE between ' | : P22_FROMBRANCH |' and ' | : P22_TOBRANCH | "AND moduleinfo =' | TO_NUMBER(:P22_SELECTLIST);
V_SQL: = V_SQL |') ((Q2)) GROUP BY LBRCODE, PRDACCTID, MN))';
V_SQL: = V_SQL | "PIVOT (MAX (AVGX) (MN) IN (';))
V_SQL: = V_SQL | V_NAME;
V_SQL: = V_SQL |')) ORDER OF LBRCODE, PRDACCTID ';
RETURN V_SQL;
END;
I created all the elements of the required page
I get the error message like missing expression
to test, I created a function to return the query, it works very well know to return a query that gives me desired report
am I missing something?
Help, please
HEMU wrote:
Hello Sir
Sorry to bother you again
I tried to use «function that returns colon-delimited topics»
and I got following error
unable to determine query headings: ORA-06550: line 1, column 138: PLS-00103: Encountered the symbol ";" when expecting one of the following: . ( ) , * % & = - + < / > at in is mod remainder not rem => <> or != or ~= >= <= <> and or like like2 like4 likec between || multiset member submultiset The symbol ")" was substituted for ";" to continue.
failed to parse SQL query:
can take you a look at page901 once again please and a function named months_namex
is it feasible that I'm looking for?
The immediate cause of this error is simply incorrect report headings function call syntax:
return months_namex(to_date(:p901_fromdate,'dd-mon-yyyy'),to_date(:p901_todate,'dd-mon-yyyy')
This should be:
return months_namex(to_date(:p901_fromdate,'dd-mon-yyyy'),to_date(:p901_todate,'dd-mon-yyyy'));
However there is no
months_namex
function defined in the workspace. -
How to write a pl/sql procedure that checks the remote db?
Hi all
I have one criticism PROD remote database I want to check every 10 minutes for its connectivity. If the connection fails then an email and a text Message is sent to me.
My question is what is the best way to check if the remote database is running?
Can I use sqlplus system/manager@PROD? But sometimes this has taken so long and suspended. I want the best response time?
How can I write a pl/sql procedure control connection? What do something like the ff:
I created a table for my tnsname.ora entries.
Something like that?cursor is c1 select dbname from tnsnames_tbl; begin connect system/[email protected]; print c1.dbname || 'DB Connection OK'; exception when others; print c1.dbname || 'DB Connection Not OK'; end; end;
Thank you
KinzNot really feasible at the level of PL/SQL.
The reason is that the greatest strength of TCP's robustness. TCP will try as hard as possible to succeed, before failing. It was designed to still work on the severely damaged or broken communication as a result of nuclear infrastructure. A TCP connection can take up to 15 minutes, maybe even more, before failing. It can be as slow as a turtle-, but he's wearing a hardshell. (unlike the UDP, which is the opposite)
So if you want to test the TCP connectivity, you must design your own custom code to implement your assumptions about the latency of packets, earthquakes and drops and so on.
Otherwise, you will need to use a standard TCP socket, set a time limit, try to login - and hope for the best.
This approach, I have demonstrated in {message identifier: = 10111306}.
If the TCP test works, it means that the listener is in place. Does not mean that the database itself is in place. Which means then using a database link to be tested. And this in turn can hang due to problems with archive record being stuck, not enough idle servers shared, etc..
-
SQL statement error INSERT The conflicted with the FOREIGN KEY constraint
I recently installed a reporting for vmware vsphere software, but I get a SQL error. I opened a request for assistance with vmware, but so far they have not come up with a solution. The error is caused by: com.microsoft.sqlserver.jdbc.SQLServerException: instruction INSERT The conflicted with the FOREIGN KEY constraint 'FK_CB_VSM_NETWORK_VC_ID '. The conflict occurred in database 'VCChargebackVCC02', table "dbo." " CB_VSM_SERVER', column 'VC_ID '. I don't know a lot about SQL, so I'm lost in the extent of troubleshooting is concerned. If anyone has any ideas I'd love to hear them.
SQL questions are better posed on Technet. They are better equipped to manage the
http://social.technet.Microsoft.com/forums/en-us/categories/
-
HE did exactly as the instructions said. Double-click the file to launch the game. is not the case. I get a box that appears and indicates that windows closes the file because it has ceased to work with an error.
any body can help me. I have windows vista 32-bit. a solution was to lower the load and to buy the program DriverCure. Well I don't really have extra money right now. is there another solution to this problem so that I can play my game.
No, it's not the same game as the PSX one. It's an arcade of Oberon Media (shareware, available athttp://gamecenter.oberon-media.com/game.htm?code=111274487&RefId=&origin=pcat_gm_d). The version that you contains no *.hta file and play very well if you do not use "launcher.exe" of the game (which has a script, leading to an infinite loop error), but the 'treasures of the Deep.exe' instead. Any necessary compatibility setting. "192GO should be enough for everyone." (of the miniseries "Next generation jokes")
-
Outlook won't let me enter my contacts and States that removing the file is in use?
I need help to figure out how to recover my contacts in outlook, it won't let me in my contacts folder it says use scanpst.exe to repair and I don't know what it is? / or how to access it? Please ELP
I need help to figure out how to recover my contacts in outlook, it won't let me in my contacts folder it says use scanpst.exe to repair and I don't know what it is? / or how to access it? Please ELP
Where is scanpast.exe...
Start button > computer > right click on the drive C (System) > Properties > Program files, right-click, click Open > defiler scroll to Microsoft Office, right-click and click Open > Office12, right-click, click Open > scroll down to find scanpst.exet-4-2
Maybe you are looking for
-
HP Officejet 5740: Msg 'printer is in an error state.
Hello I have a 5740 which is defined as a remote wireless printer by itself in my home network. Recently, I received the message 'printer is in an error state' when I press print and found out the print job will be lance automatically, only after I t
-
XS708E super hot race and crashes after about 2-3 weeks of use
Hi guys,. I installed the XS708E at home for my home enterntain system. I have reaised the switch may become hot after a while. The switch is installed in an open space where it is well ventilated. I realized that the perfomance of the switch slow do
-
W2K8 R2 Licensing Issue: passes during the migration of parallel hardware
We have a very old application server run on W2K8 R2 stand-alone (no advertising). We decide to migrate the server to new hardware. Freshly install us the operating system, create user accounts, and install the application on the new hardware. To p
-
You will need to upgrade memory. Currently have 3 gigs - memory how much more I can install? Thank you. bobdad
-
Slow down the first print Page
HP Officejet 5610 all-in-One printer; Win 7 Home Premium 64-bit When I print multiple-page documents in a project framework, the first page of the printer is very slow, 60 sec. +. The following pages are at a speed I know is a parameter "print proj