ORA-00900: the SQL statement invalid when you run for immediate assistance.
HelloI write code simple db is 9.2.0.8
create or replace procedure gather_part_stats(p_schema in varchar2, p_table in varchar2)
as
l_quarter varchar2(8) := to_char(sysdate, '"Y"YYYY"_Q"q') ;
l_sql varchar2(2000) := 'exec dbms_stats.gather_table_stats(:schema, :table, method_opt => ''for all columns size 1'' , cascade => true , estimate_percent => 1 , granularity => ''PARTITION'', partname=>:part);';
begin
dbms_output.put_line('l_quarter: ' || l_quarter);
dbms_output.put_line(l_sql);
execute immediate l_sql using in p_schema, in p_table, in l_quarter ;
end;
/
Trying to collect statistics of the table with the selected partition but mess up something with... something :)I use use to avoid sql injection, please advice.
Error is:
SQL > gather_part_stats exec ('TEST', 'TEST');
l_quarter: Y2012_Q2
exec dbms_stats.gather_table_stats (: schema,: table, method_opt = > ' for all columns size 1', cascade = > true, estimate_percent = > 1, granularity = > 'PARTITION', partname = >: part);
BEGIN gather_part_stats ('TEST', 'TEST'); END;
*
ERROR on line 1:
ORA-00900: invalid SQL statement
ORA-06512: at the 'INSTALL '. GATHER_PART_STATS', line 8
ORA-06512: at line 1
Concerning
GregG
You must use the dynamic PL/SQL
create or replace procedure gather_part_stats(p_schema in varchar2, p_table in varchar2)
as
l_quarter varchar2(8) := to_char(sysdate, '"Y"YYYY"_Q"q') ;
l_sql varchar2(2000) := 'begin dbms_stats.gather_table_stats(ownname=>:schema, tabname=>:table, method_opt => ''for all columns size 1'' , cascade => true , estimate_percent => 1 , granularity => ''PARTITION'', partname=>:part); end;';
begin
dbms_output.put_line('l_quarter: ' || l_quarter);
dbms_output.put_line(l_sql);
execute immediate l_sql using in p_schema, in p_table, in l_quarter ;
end;
/
Tags: Database
Similar Questions
-
ORA-00900 - the SQL commands: invalid SQL statement
Hello world
I installed Oracle Xe on a Centos 5.5 host yesteday.
Installation was Ok, I can connect to the web interface on "http://127.0.0.1:8080 / apex / '.
But when I want to use sql commands, regardless of the input control, I have the "ORA-00900: invalid SQL statement" message.
I can enter the command "Show all", for example, in a terminal after SQL > command prompt, it works... but not in the web interface...
I tried to import the .sql, script trought the web interface, no much result, no display in the window.
Can someone help me,
Thank youShow all is NOT a SQL command is a command that I think, not a command from pl/sql, sql more... Why not try to do a select on a table is know YOU the schema...
Thank you
Tony Miller
Webster, TX -
Error 6 - the handle is invalid when you try to start the services.
Error 6 - the handle is invalid
HII
I really need help
If you sat down me - it would be great.
in my organzition - 5 different computers - all THE of THEM with the HELP of Win Xp Sp3
started having error - error 6 - the handle is invalid
When we want to start very imporatnt services
print spooler
the Windows Installer
EXC
When we try to start these service - we get the error - thT THE HANDLE IS INVALID - ERROR 6
and the service - was able to start10 x in advance
Thank you very much
We have made the controls more
is it was the fault of the Anti Virus
We always face the problem - but we know who is to blame
We use the endpoint of Symantec Enterprise solution
When we disabled anti virus service - other services began to operate properlyWe contacted Symantec support to see if they have a solution to the problem
really 10 X -
"Rowset cannot be loaded because the stream is invalid" when you use vb6 Windows XP
So try to run the application in VB6 with SP5 runtim in Window XP, I get the error "rowset cannot be loaded because the stream is invalid. In fact, our requirement is VB6 with SP5. I can't fine the SP5 in Microsoft sites that's why I'm running in SP5 runtime. But I get the above error. Please give the solution for this problem
Hi Vincent SubbarayuduMamilla Alaiah,.
The question you posted would be better suited in the MSDN Forums. I would recommend posting your query in the MSDN Forums.
MSDN forums
http://social.msdn.Microsoft.com/forums/en/category/VisualBasic
-
"The operation is not allowed in the current state" message when you delete the folder
I'm test ESXi 5.5 and mounted a datatsore of oriented export NFS in an attempt to redirect my ScratchConfig at this place. I found that I can create a folder in the datasore NFS fine but when I try to delete it, I get a message saying "the operation is not allowed in the current state. This happens on any of the files/sub-sub-sub-folders and only used account's root - I also confirmed that these directory drwxr-xr-x permissions.
As suggested by KB1003829 which is a bit useful, but not really, I restarted the management on the host agents but it made no difference. Has anyone else seen elsewhere?
I got this resolved, stumbling on the good guid for the NFS data store. Only after clicking around in WinSCP and realize that the NFS data store guid secondary, shorter - I then tried again to remove the original test directory and it worked.
On a separate but similar note, then I tried to update my position zero config by applying this same guid with the command "vim - cmd hostsvc/advopt/updated updated ScratchConfig.ConfiguredScratchLocation string vmfs/volumes / [guid] / logs" (followed by a restart of the host) and it worked also.
-
Dear Experts,
I need a clarification. Is it possible to use the fn - bea: function execute sql (Oracle Service Bus) to perform an insert operation in a database with the data extracted from the message of the Organization (i.e. $body/Info/username)? If it is possible which is the right syntax?
Any suggestion is appreciated.
Kind regards
Mike
Published by: ITDeveloper on November 19, 2009 2.55
Published by: ITDeveloper on November 19, 2009 3.01Hi Mike,.
Please refer to my post for the same question to the fn - bea: sql performance with 'Insert INTO' the sql statement
Thank you best regards &,.
Vivek
-
Error ORA-00979 when you run the SQL in Oracle 11.2.0.3
Hi Oracle Experts,
I am trying to execute a SQL statement which consist of 2-3 levels of inline queries. Part of this SQL statement is as below:
When I run the level the lowest and second lowest level inline queries statements, which consists of a select field of data and functions, there is no error and capable of generating the result.SELECT "SAMPLE_RESULT"."PROPERTYID", "SAMPLE_RESULT"."QUALIFIER", ROUND(AVG(SAMPLE_RESULT.RESULT),2) avg_result, AVG(DECODE(SAMPLE.QUALITYSTATUS, 'P', 1,'F', 5)) qltystatus, TO_CHAR("SAMPLE"."SAMPLEDT",'dd-Mon-yyyy') sampledt, TO_CHAR("SAMPLE"."SAMPLEDT",'rrrr-mm-dd') sortdate STD.stdev, getCL.cl FROM ( SELECT ROUND(stddev(INS.avg_result),2) stdev FROM ( SELECT "SAMPLE_RESULT"."PROPERTYID", "SAMPLE_RESULT"."QUALIFIER", ROUND(AVG(SAMPLE_RESULT.RESULT),2) avg_result, AVG(DECODE(SAMPLE.QUALITYSTATUS, 'P', 1,'F', 5)) qltystatus, TO_CHAR("SAMPLE"."SAMPLEDT",'dd-Mon-yyyy') sampledt FROM "SAMPLE", "SAMPLE_RESULT", "ACTIVITY" WHERE ( "SAMPLE"."SAMPLEID" = "SAMPLE_RESULT"."SAMPLEID" ) AND ( "SAMPLE_RESULT"."TESTINSTANCE" = fn_max_instance ( sample.sampleid, sample_result.testid, sample_result.propertyid ) ) AND ( "SAMPLE"."ACTIVITYID" = "ACTIVITY"."ACTIVITYID" ) AND ( ACTIVITY.VARIANTID IN ('Sales Gas','Contaminants End') ) AND ( ACTIVITY.LOCATIONID = 'S-5003C' ) AND ( SAMPLE.EVENTID <> 'AD-HOC' ) AND ( "SAMPLE"."SAMPLESTATUS" = 'L' ) AND ( TO_DATE(TO_CHAR(SAMPLE.SAMPLEDT,'dd-mon-yyyy')) BETWEEN TO_DATE (TO_CHAR(:StartDate,'dd-Mon-RRRR')) AND TO_DATE(TO_CHAR( :StartDate,'dd-Mon-RRRR')) + 6 ) AND ( SAMPLE_RESULT.PROPERTYID = 'GCV' ) GROUP BY SAMPLE_RESULT.PROPERTYID, SAMPLE_RESULT.QUALIFIER, TO_CHAR("SAMPLE"."SAMPLEDT",'dd-Mon-yyyy') ) INS ) STD, ( SELECT ROUND(AVG(INS.avg_result),2) cl FROM ( SELECT "SAMPLE_RESULT"."PROPERTYID", "SAMPLE_RESULT"."QUALIFIER", ROUND(AVG(SAMPLE_RESULT.RESULT),2) avg_result, AVG(DECODE(SAMPLE.QUALITYSTATUS, 'P', 1,'F', 5)) qltystatus, TO_CHAR("SAMPLE"."SAMPLEDT",'dd-Mon-yyyy') sampledt FROM "SAMPLE", "SAMPLE_RESULT", "ACTIVITY" WHERE ( "SAMPLE"."SAMPLEID" = "SAMPLE_RESULT"."SAMPLEID" ) AND ( "SAMPLE_RESULT"."TESTINSTANCE" = fn_max_instance ( sample.sampleid, sample_result.testid, sample_result.propertyid ) ) AND ( "SAMPLE"."ACTIVITYID" = "ACTIVITY"."ACTIVITYID" ) AND ( ACTIVITY.VARIANTID IN ('Sales Gas','Contaminants End') ) AND ( ACTIVITY.LOCATIONID = 'S-5003C' ) AND ( SAMPLE.EVENTID <> 'AD-HOC' ) AND ( "SAMPLE"."SAMPLESTATUS" = 'L' ) AND ( TO_DATE(TO_CHAR(SAMPLE.SAMPLEDT,'dd-mon-yyyy')) BETWEEN TO_DATE (TO_CHAR(:StartDate,'dd-Mon-RRRR')) AND TO_DATE(TO_CHAR( :StartDate,'dd-Mon-RRRR')) + 6 ) AND ( SAMPLE_RESULT.PROPERTYID = 'GCV' ) GROUP BY SAMPLE_RESULT.PROPERTYID, SAMPLE_RESULT.QUALIFIER, TO_CHAR("SAMPLE"."SAMPLEDT",'dd-Mon-yyyy') ) INS ) getCL, "SAMPLE", "SAMPLE_RESULT", "ACTIVITY" WHERE ( "SAMPLE"."SAMPLEID" = "SAMPLE_RESULT"."SAMPLEID" ) AND ( "SAMPLE_RESULT"."TESTINSTANCE" = fn_max_instance (sample.sampleid, sample_result.testid, sample_result.propertyid) ) AND ( "SAMPLE"."ACTIVITYID" = "ACTIVITY"."ACTIVITYID" ) AND ( ACTIVITY.VARIANTID IN ('Sales Gas','Contaminants End') ) AND ( ACTIVITY.LOCATIONID = 'S-5003C' ) AND ( SAMPLE_RESULT.PROPERTYID IN ('GCV','SG','T. Sulphur','Dew Point', 'HC Dew Pts') ) AND ( TO_DATE(TO_CHAR(SAMPLE.SAMPLEDT,'dd-mon-yyyy')) BETWEEN TO_DATE(TO_CHAR (:StartDate,'dd-Mon-RRRR')) AND TO_DATE(TO_CHAR(:StartDate, 'dd-Mon-RRRR')) + 6 ) GROUP BY "SAMPLE_RESULT"."PROPERTYID", "SAMPLE_RESULT"."QUALIFIER", TO_CHAR("SAMPLE"."SAMPLEDT",'dd-Mon-yyyy'), TO_CHAR("SAMPLE"."SAMPLEDT",'rrrr-mm-dd'), STD.stdev, getCL.cl )
But when I run the statement which refer to the alias of queries inline (STD, getCL), it prompted an error ORA-00979 not a group by expression. This happened only Oracle 11.2.0.3. If I run the statement in another version of Oracle (11 GR 1 material and below), I am able to generate the result.
Please advice how can I fix this problem.
Published by: xysOra on 29 April 2013 19:37It seems that this should be the "SAMPLE" TO_CHAR conversions "" SAMPLEDT ".
You seem to be willing to cut the time part of SAMPLEDT. The best way to do so is TRUNC (SAMPLEDT).
In each of the groups of clauses, replace TO_CHAR ('SAMPLE'. ("' SAMPLEDT ', 'dd-Mon-yyyy') with TRUNC ('SAMPLE'. (' "SAMPLEDT") and completely remove the TO_CHAR ('SAMPLE'. ("' SAMPLEDT ',"dd-mm-rrrr") in the last group of.
Replace in selection lists, TO_CHAR ('SAMPLE'. ("' SAMPLEDT ', 'dd-Mon-yyyy') with TO_CHAR (TRUNC ('SAMPLE'. ((' ' SAMPLEDT '), 'dd-Mon-yyyy') and replace TO_CHAR ("SAMPLE". "SAMPLEDT", "dd-mm-rrrr") with TO_CHAR (TRUNC ("SAMPLE" ".")) " "" "SAMPLEDT"), "dd-mm-rrrr").
These changes can take you the ORA-00979 not one group by expression.
Also the date manipulation is wrong — you do implicit conversions to date using default formats, when what you seem to want is to truncate the time part. Instead of
TO_DATE(TO_CHAR(SAMPLE.SAMPLEDT,'dd-mon-yyyy')) BETWEEN TO_DATE(TO_CHAR (:StartDate,'dd-Mon-RRRR')) AND TO_DATE(TO_CHAR(:StartDate, 'dd-Mon-RRRR')) + 6
use
TRUNC(SAMPLE.SAMPLEDT) BETWEEN TRUNC(:StartDate) AND TRUNC(:StartDate) + 6
I hope this helps.
David -
"Activation key is not valid" when you try to reinstall Windows after a crashed hard drive. I have a disc of Windows 7 Home Premium and I am using the product key from the back of a computer (it was originally an installation of Windows 7 Home Premium). Why do not match the keys, and what I have to report the earlier installation somehow is no longer active before attempting to reactivate?
Skip entering your product key Windows 7 and complete the installation.
When you reach the desktop, click Start, right-click on computer
Click on properties
Scroll down to the Windows Activation
Click the link x days before activation.
Click on the link that says: "show me other ways to activate.
Enter the product key
Click next
Select the Activation of the phone
Click Next when you enter your key page
Select your country
Click Next, call the number listed
Be sure to explain your situation to the Appeals Officer.
Provide the installation generated when ID requested by the call agent
They give a confirmation ID in return, enter it
Click next to complete the activation.
or
How to activate Windows 7 manually (activate by phone)
1) click Start and in the search for box type: slui.exe 4
(2) press the ENTER"" key.
(3) select your "country" in the list.
(4) choose the option "activate phone".
(5) stay on the phone (do not select/press all options) and wait for a person to help you with the activation.
(6) explain your problem clearly to the support person.
http://support.Microsoft.com/kb/950929/en-us -
ORA-01403: no given available problem when you use FETCH of AUTOMATIC LINE to fill
ORA-01403: no given available problem when you use FETCH of AUTOMATIC LINE to fill out a form.
1) has created a FORM on the use of assistants of EMP. This creates an AUTOMATIC FETCH of LINE
NAME OF THE TABLE - EMP
The PRIMARY KEY containing - P2099_EMPNO point
Primary key column - EMPNO
By default, automatic extraction has a "process Error Message' of"Unable to fetch line."
(2) created an HTML region. In this region add
text P2099_FIND_EMPNO element
GET_EMP submit button
The update branch the conditional branch created when the Create button to set P2099_EMPNO with & P2099_FIND_EMPNO.
If I then turn the page, enter an employee in P2099_EMPNO number and press the GET_EMP button, the form is filled correctly. But if I get an employee who does not exist, then I get error oracle ORA-01403: no data found and no form but a message at the top of the page 'Action transformed '. I was expecting a blank form is displayed with the message 'Could not extract line.'
In conditioning automated extraction so that it checks that the line exists first, I can work around that. Change the fetch EMP automated line so that it is conditional
EXIST (SQL query returns at least one row)
Select 'x '.
from EMP
where EMPNO =: P2099_EMPNO
But this means that when the employee exists I must be get DB twice, once to the State, and then again for the extraction of the actual line.
I can't change so I don't get the Oracle error, rather than work around for a above is there something? I wonder now if the automatic extraction of line is only supposed to be used when you bind a report to a form and that I should manually write the extraction process. The reason for which I don't have at the moment, it is that I'm trying to stick with the auto generation Assistant as I can.
Any ideas?
Thanks, PetePete:
The process Assistant APEX (ARF, ARP etc) errors are generally not recoverable. The error encountered is simply displayed on a page by using the model of "Error Message. So as you said yourself, you create your own process line Fetch and have the opportunity to customize the management mistakes, or you paste a validation on the page to verify that a folder can be accessed for the views expressed.
CITY
-
How can I pass a condition of the table in the sql statement?
For example, in the table in the COND Varchar2 column (200) there is the value ' VAR > 10'.
| COND |
|' VAR > 10' |
where VAR is the name of the table column. I would like to make statement CASE WHEN VAR > 10 AND 0... I tried with as subquery
WHEN BOX (SELECT COND FROM TABLE WHERE...) THEN 0, but it does not work.
Hello
You can do this by using dynamic SQL.
that is to say:
declare v_stm varchar2(4000); v_cond varchar2(100); v_result integer; begin select cond into v_cond from yourtable where a=1; v_stm := 'select case when '||v_cond||' then 0 ...'; -- dynamic sql execute immediate v_stm into v_result; end; /
Remember that, in general, dynamic SQL has a performance degradation that SQL static and should be avoided when possible.
Storage condition or the SQL statements in the tables is not a good practice.
Kind regards.
Alberto
-
Re: "insufficient privileges" error when you run the Java stored procedure in another schema
I get an "insufficient privileges" error when you run the Java stored procedure in another schema, see details below. I don't know what are missing privileges (I already granted the EXECUTE privilege), suggestions? -Thank you.
Define a simple java class and deploy it as a Java stored procedure to test:
Schema: User1
test of the package;
public class HelloWorld {}
public HelloWorld() {
Super();
}
public static String Hello () {}
Return "HELLO";
}
}
CREATE or REPLACE FUNCTION HELLO RETURN VARCHAR2 AUTHID CURRENT_USER AS LANGUAGE JAVA NAME ' test. HelloWorld.hello () return java.lang.String';
Grant execute on USER2 HELLO
Test the Java stored procedure through the PL/SQL function call (in the same schema):
Schema: User1
SET SERVEROUTPUT ON
DECLARE
v_Return VARCHAR2 (200);
BEGIN
v_Return: = User1. HELLO;
DBMS_OUTPUT. Put_line ('v_Return =' | v_Return);
END;
anonymous block filled
v_Return = HELLO
Test the Java stored procedure through the PL/SQL function call in a different pattern:
Schema: USER2
SET SERVEROUTPUT ON
DECLARE
v_Return VARCHAR2 (200);
BEGIN
v_Return: = User1. HELLO;
DBMS_OUTPUT. Put_line ('v_Return =' | v_Return);
END;
Error report-
ORA-01031: insufficient privileges
ORA-06512: at "User1." HELLO', line 1
ORA-06512: at line 4 level
01031 00000 - "insufficient privileges".
* Cause: An attempt was made to change the user name or password
without the privilege appropriate. This error also occurs if
trying to install a database without the need for employment
access privileges.
When Trusted Oracle is configure in DBMS MAC, this error may occur
If the user has been granted the privilege necessary for a higher label
that the connection is active.
* Action: Ask the database to perform the operation or grant administrator
the required privileges.
For users Trusted Oracle get this error, well that granted the
the privilege that is suitable for the top label, ask the database
administrator to grant the privilege to the appropriate label.
You have created the function with AUTHID CURRENT_USER, which means that the function is executed with the rights of the applicant (but not with the rights of the author). This means that the applicant must have grants (directly or through roles) on all used/accessible objects in the service. In your case the user USER2 has not granted with EXECUTE on the class/source Java test. Class HelloWorld, causing the ORA-01031 exception. You create service without AUTHID CURRENT_USER (i.e. with AUTHID DEFINE, which is by default, if you do not have a specific reason to use AUTHID CURRENT_USER) or grant EXECUTE on JAVA test SOURCE. Class HelloWorld to User2.
Dimitar
-
Hello. all.
I wonder how to find sql_id using a sql statement, including transport retrun and tab space multiple.
To be more precise,
My sql is:
Select
col_a,
col_b,
..
..
I usually use the following query to find the sql_id
Select sql_id in v$ sql where sql_text like 'MY SQL STATEMENT %.
When MY SQL STATEMENT includes carriage return and tab space multiple, how can I do?
Thanks in advance.
Best regards.Hello
Did you look at regular expressions? Use regexp_like instead of as.
http://www.Stanford.edu/dept/ITSS/docs/Oracle/10G/server.101/b10759/conditions018.htm
Kind regards
-
CALL THE PROCEDURE IN THE SQL STATEMENT
Why we cannot call a procedure inside the SQL statement?Hello
Usually when you select an item should return you data. In the case of a procedure, you cannot return any return value from the procedure directly it has to be done through some settings and to access these settings, you cannot use a simple sql statement. Where as in a function, you must return one of data that can be easily obtained accordingly.
see you soon
VT
-
Hi all
I just created a function that returns a TABLE;
I am grateful if some body guide me how to display the values in the table at the call of my sqlplus as function
Select * from func_avg_cost() of double;
its fine when you return a single value of work. But I'm back a table to retrieve the value from the table in the sql statement
Thank you!now, I must return two numbers function. as possible through table.
which is also possible with a simple object:
SQL> create or replace type my_number_typ as object (n1 number, n2 number) / Type created. SQL> create or replace function my_numbers (n1 number := 0, n2 number := 0) return my_number_typ as begin return my_number_typ (n1, n2); end my_numbers; / Function created. SQL> select my_numbers (2, 3) from dual / MY_NUMBERS(2,3) -------------------------------------------------- (2; 3) 1 row selected. SQL> select my_numbers (sal, deptno) my_numbers from emp where empno = 7788 / MY_NUMBERS -------------------------------------------------- (3000; 20) 1 row selected. SQL> select my_numbers (sal, deptno).n1 sal, my_numbers (sal, deptno).n2 deptno from emp where empno = 7788 / SAL DEPTNO ---------- ---------- 3000 20 1 row selected.
-
parameters in the SQL statement.
Hello
I am creating a report of PL/SQL. The report, for example, has 3 columns say X, Y, Z. When I run the report, I have 2 Optional parameters P1 and P2.
My question is,
If I enter a value in the parameter P1, then where condition of the report should be something like
WHERE X = P1.
If I enter a value in the parameter P2, then where condition of the report should be something like
WHERE Y = P2.
If I enter a value in the parameters P1 and P2, then where condition of the report should be something like
WHERE X = P1 AND Y = P2.
Can someone give an idea how to make this possiblie.
Thank you
KumarI'm a fan of NVL for this...
WHERE X = NVL(P1, X) AND Y = NVL(P2, Y)
Therefore if P1 or P2 is null, you get X = X or Y = Y, actually drop your sql criteria. You can also link, in which case you have only a single sql statement analyze and you needn't pl/sql at all.
Maybe you are looking for
-
No sound on Tecra S5, "THotkey" error starting Windows XP Home edition
I have a laptop Tecra S5, I deleted some old programs for card readers.Now, sound does not work and starting the PC, windows starts and I get the message: "Error THotkey" this audio diviece is not supported. Is it just the audio driver what is missin
-
Some issues with the new facility on Satellite A100-691
Hello yesterday, I received the laptop from a friend of mine.He had a troyan horse program, so we decided to install everything again. We use the product recovery CD for the Installation of XP, then 'Tools & Utilities CD Rom', but there are now a few
-
Adapters and beam forming...
Just bought an AC2400 of "creation of beam." My card is a WUSB600N. The new adapters support the beam forming? I have some problems of connection in large part because of the distance and interference between my router and adapter--all things being
-
I can't save my puzzles on BrainsBreaker program.
I try to save my BrainsBreaker puzzle but it won't save. I get an Access denied error message (openingc: / program files) BrainsBreaker/whateverjpuzzle I am trying to record.
-
Cannot add a Cisco CP 2.1 wireless
Hello I am very new with Cisco devices. I have a Cisco 851 router wireless and I configured manually (a simple local network with a Wan interface for internet). Now, I'm trying to add a Wpa wireless network to complete the configuration of my wanted.