How to transform this PL/SQL request into a PL/SQL function ?
Hi nice people !
I have a beautiful flash chart which SQL code is below. I want to display this chart only if this query returns results. I tried to put it as condition. How to transformt this SQL ciode as "SLQ Function returning a boolean" ?
DECLARE
X VARCHAR2 (4000);
BEGIN
x :=
'SELECT NULL LINK, trunc(a.DATE1, '''||:P13_TRUNC||'''), avg(b.pourcentage_remplissage)
FROM EVV_'||:P13_SITE||' a, bassin_remplissage b
WHERE a.CLEF_VAR = (SELECT CLEF_VAR FROM SITE_ECHELLE WHERE SITE='''||:P13_SITE||''')
AND round(a.valeur, 1) = b.cote_ngf
AND DATE1 BETWEEN
TO_DATE ('''||:P13_DATE_DEBUT||'000000'', ''DD/MM/YYYYHH24MISS'') AND
TO_DATE ('''||:P13_DATE_FIN||'235959'', ''DD/MM/YYYYHH24MISS'')
group by trunc(a.DATE1, '''||:P13_TRUNC||''')
ORDER BY trunc(a.DATE1, '''||:P13_TRUNC||''')';
RETURN (X);
END;Thank you for your kind answers.
Christian
Hello Christian,
>> I don't understand your input
Your error is most likely because the dynamic select statement you are trying to build is not correct. As local variables, like the ‘x’ you are using, are not persistence, it’s probably hard for you to see the final value of x.
You should define an application item, like TEMP1, and use it to hold the generated select statement:
BEGIN
:TEMP1 := 'SELECT COUNT(*) INTO WWV_FLOW.g_id
FROM EVV_'
|| :p13_site
|| ' a, bassin_remplissage b
WHERE a.CLEF_VAR = (SELECT CLEF_VAR FROM SITE_ECHELLE WHERE SITE='''
|| :p13_site
|| ''')
AND round(a.valeur, 1) = b.cote_ngf
AND DATE1 BETWEEN
TO_DATE ('''
|| :p13_date_debut
|| '000000'', ''DD/MM/YYYYHH24MISS'') AND
TO_DATE ('''
|| :p13_date_fin
|| '235959'', ''DD/MM/YYYYHH24MISS'')
group by trunc(a.DATE1, '''
|| :p13_trunc
|| ''')
ORDER BY trunc(a.DATE1, '''
|| :p13_trunc
|| ''')';
return false;
END;Now the process should be evaluated without errors, and TEMP1 should hold the select statement that produces the error. Now, using the developer toolbar, you can inspect the actual select statement ant analyze its syntax and format.
Once you’ll find the error in the select statement, you can go back to Denes original code proposal.
Regards,
Arie.
Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.
Similar Messages
-
How to Break this String and put into a Table
Hi all,
Currently i working on the Reading of Csv file.THe Csv file wil be stored as BLOB in one table.
The Format of the Csv file is
EMPCODE :DATEOFBIRTH
312089 ,12/01/1984
321456 ,03/05/1980
120212 ,04/08/1987
312456 ,23/12/1977
311110 ,12/04/1998
323232 ,20/06/1990
UPLOAD_BLOB
column Datatype
UploadId Number
File_details BLOB
And i reading the BLOB in one procedure and i m getting the String as like this ---->
"312089 ,12/01/1984
321456 ,03/05/1980
120212 ,04/08/1987
312456 ,23/12/1977
311110 ,12/04/1998
323232 ,20/06/1990"
I am Dont know how to Parse this String and put in table
While 1<STRING.LENGTH
LOOP
EMPCODE=SUBSTRING();
DATEOFBIRTH=SUBSTRING();
INSERT INTO TABLE VALID_EMPCODE(EMPCODE,DATEOFBIRTH)VALUES(......);END LOOP
VALID_EMPCODE
EMPCODE VARCHAR2(30)
DATEOFBIRTH VARCHAR2(15)
Can any one tell me how to parse this whole string and break themDuplicate post
How to Break this String and put into a Table -
How to transform this pascal code into java code!
I want to transform this pascal code into java code . Please tel me how to do it because I really don't know how to do it!
Thanks!
{CALCULATE HOHN-LONDON FACTORS}
var kk:tab4;
PROCEDURE INTENS(var kk:tab4);
begin
for n:=0 to nr+2 do
begin
kk^[1,n]:=sqrt(lup*lup*yg*(yg-4)+4*sqr(n+1)) +lup*(yg-2);
kk^[2,n]:= sqrt(lup*lup*yg*(yg-4)+4*sqr(n+1))-lup*(yg-2);
kk^[3,n]:=0.5*(kk^[1,n]*kk^[1,n]+4*(sqr(n+1)-lup*lup));
kk^[4,n]:= 0.5*(kk^[2,n]*kk^[2,n]+4*(sqr(n+1)-lup*lup));
kk^[5,n]:= sqrt(ldown*ldown*yd*(yd-4)+4*sqr(n+1)) +ldown*(yd-2);
end;
end;
BEGIN
new (kk);
intens(kk);
writeln(f2,' ','N ','V','branch ','H-L');
for n:=1 to np do
begin
fp1[n,v]:=(n-ldown)*(n+ldown+1)*sqr(kk^[2,n-1]*kk^[6,n]+4*(n+ldown)*(n-ldown+1));
fp1[n,v]:=fp1[n,v]/(4*(n+0.5)*kk^[4,n-1]*kk^[8,n]) ;
writeln(f2,' ',n,' ',v,' fp1 ',fp1[n,v]:10:2);
end;
for n:=1 to nq do
begin
fq1[n,v]:=sqr(kk^[2,n]*kk^[6,n]*(ldown+0.5)+4*(n-ldown+1)*(n+ldown+1)*(ldown-0.5)) ;
fq1[n,v]:=fq1[n,v]/(2*(n+0.5)*kk^[4,n]*kk^[8,n]*(n+1.5));
fq1[n,v]:=fq1[n,v]*(n+1);
writeln(f2,' ',n,' ',v,' fq1 ',fq1[n,v]:10:2);
end;
for n:=1 to nr do
begin
fr1[n,v]:=sqr(kk^[2,n+1]*kk^[6,n]+4*(n-ldown+2)*(n+ldown+1));
fr1[n,v]:=fr1[n,v]/(4*kk^[4,n+1]*kk^[8,n]*(n+1.5));
fr1[n,v]:=fr1[n,v]*(n-ldown+1)*(n+ldown+2) ;
writeln(f2,' ',n,' ',v,' fr1 ',fr1[n,v]:10:2);
end;Basically it looks like this:
public class KK{
private your_type[][] kk = new your_type[length][length];
private void intens(your_type[] kk){
for(int n= 0; n<nr+2; n++){
kk[1][n] = Math.sqrt(lup*lup*yg*(yg-4)+4*Math.pow((n+1), 2)) +lup*(yg-2);
kk[2][n] = Math.sqrt(lup*lup*yg*(yg-4)+4*Math.pow((n+1), 2))-lup*(yg-2);
kk[3][n] = 0.5*(kk[1][n]*kk[1][n]+4*(Math.pow((n+1), 2)-lup*lup));
kk[4][n] = 0.5*(kk[2][n]*kk[2][n]+4*(Math.pow((n+1), 2)-lup*lup));
kk[5][n] = Math.sqrt(ldown*ldown*yd*(yd-4)+4*Math.pow((n+1), 2)) +ldown*(yd-2);
public static void main(String args[]){
KK k = new KK();
k.intens(kk);
System.out.println(f2 + ' ' + 'N ' + 'V' + 'branch ' + 'H-L');
for(int n=1; n < np; n++){
fp1[n][v] = (n-ldown)*(n+ldown+1)*Math.pow((kk[2][n-1]*kk[6][n]+4*(n+ldown)*(n-ldown+1)), 2);
fp1[n][v] = fp1[n][v]/(4*(n+0.5)*kk[4][n-1]*kk[8][n]) ;
System.out.println(f2 + ' ' + n + ' ' + v + ' fp1 ' + fp1[n][v]:10:2);
for(int n=1; n< nq;n++){
fq1[n][v] = Math.pow((kk[2][n]*kk[6][n]*(ldown+0.5)+4*(n-ldown+1)*(n+ldown+1)*(ldown-0.5)), 2);
fq1[n][v] = fq1[n][v]/(2*(n+0.5)*kk[4][n]*kk[8][n]*(n+1.5));
fq1[n][v] = fq1[n][v]*(n+1);
System.out.println(f2 + ' ' + n + ' ' + v + ' fq1 ' + fq1[n][v]:10:2);
for(int n=1; n < nr; n++){
fr1[n][v] = Math.pow((kk[2][n+1]*kk[6][n]+4*(n-ldown+2)*(n+ldown+1)), 2);
fr1[n][v] = fr1[n][v]/(4*kk[4][n+1]*kk[8][n]*(n+1.5));
fr1[n][v] = fr1[n][v]*(n-ldown+1)*(n+ldown+2) ;
System.out.println(f2 + ' ' + n + ' ' + v + ' fr1 ' + fr1[n][v]:10:2); //fr1[n][v]:10:2 --> Here you must use the BigDecimal class
}I'm not very sure because my pascal knowledge is extremely "dated".
What about the converter I told you about? -
How to Achieve this in SQL Query?
How to Achieve this ?
I have a table with numeric value populated like this
create table random_numeral (numerals Number(10));
insert into random_numeral values (1);
insert into random_numeral values (2);
insert into random_numeral values (3);
insert into random_numeral values (4);
insert into random_numeral values (5);
insert into random_numeral values (6);
insert into random_numeral values (56);
insert into random_numeral values (85);
insert into random_numeral values (24);
insert into random_numeral values (11);
insert into random_numeral values (120);
insert into random_numeral values (114);
Numerals
1
2
3
4
5
6
56
85
24
11
120
114
I want to display the data as follows
col1 / col2 / col3
1 / 2 / 3
4 / 5 / 6
11 / 24 / 56
85 / 114 / 120
Can anyone Help me?I hope there might be some simple way to do this and waiting for experts to reply.
Try the below query.
SQL> select * from random_numeral;
NUMERALS
1
2
3
4
5
6
56
85
24
11
120
NUMERALS
114
100
140
14 rows selected.
SQL> select a.numerals ||' / '||b.numerals||' / '||c.numerals from
2 (select numerals,rownum rn1 from
3 (
4 select numerals,mod(row_number() over(partition by 1 order by numerals),3)
5 from random_numeral
6 )
7 where rn=1) a,
8 (select numerals,rownum rn1 from
9 (
10 select numerals,mod(row_number() over(partition by 1 order by numerals),3)
11 from random_numeral
12 )
13 where rn=2) b,
14 (select numerals,rownum rn1 from
15 (
16 select numerals,mod(row_number() over(partition by 1 order by numerals),3)
17 from random_numeral
18 )
19 where rn=0) c
20 where a.rn1=b.rn1(+)
21 and b.rn1=c.rn1(+)
22 /
A.NUMERALS||'/'||B.NUMERALS||'/'||C.NUMERALS
1 / 2 / 3
4 / 5 / 6
11 / 24 / 56
85 / 100 / 114
120 / 140 /
SQL>Cheers,
Mohana -
How to Improve this PL/SQL script
Hi All,
I have a package/procedure that insert data into table but it takes time more than 2 days. Have any known how to modify this script to improve the performance and reduce loading time, The following code is procedure I used to insert data.....
Procedure INSERT_DATA (p_month IN DATE, p_product_id IN NUMBER ) IS
cursor c1 is select * from tab#1; --reference data
cursor c2 is select * from tab#2;
cursor c3 is select * from tab#3;
cursor c4 is select * from tab#4;
cursor c5 is select * from tab#5;
v_rec claim_table%rowtype;
Begin
for c1rec in c1 loop
exit when c1%notfound;
call procedure in package....;
open c2(c1rec.claim_no);
fetch c2 into v_location_cd ,v_claim_type_cd ;
close c2;
v_rec.location_cd := v_location_cd;
v_rec.claim_type_cd := v_claim_type_cd ;
open c3(c1rec.claim_no);
fetch c3 into v_col#3,v_col#4;
close c3;
v_rec.col#3 := v_col#3 ;
v_rec.col#4 := v_col#4 ;
open c4(c1rec.claim_no);
fetch c4 into v_col#5,v_col#6;
close c4;
v_rec.col#5 := v_col#5 ;
v_rec.col#6 := v_col#6 ;
insert into claim_table values ( v_rec.location_cd, v_rec.claim_type_cd , v_rec.col#3 , .......) ;
if (c1%rowcount/1000) = trunc(c1%rowcount /1000) then
commit;
end if;
end loop;
commit;
Exception
exception statement....
commit;
End;
Thanks All,
MckaA copy and paste of a reply I posted just a hour or so ago to the exact same approach used by a poster in [url http://forums.oracle.com/forums/thread.jspa?threadID=636929]this thread.
Yucky code IMO. You are using PL/SQL to drive a nested loop join. Why? SQL is by far more capable of joining tables and is not limited to a using a nested loop approach only.
Also, as you are using PL/SQL to drive it, it means that each cursor fetch in each (nested) FOR loop is a slow context switch from PL/SQL to SQL, in order to ship the row's data from the SQL engine to the PL/SQL engine. Only then to have that very same data shipped back (via yet another context switch) to the SQL engine to be inserted into table4.
This code violates one of the most rudimentary performance principles in Oracle - it is not maximizing SQL and it it not minimizing PL/SQL. It is doing the exact opposite.
As for the ad-hoc commits inside the loop - this does not make much sense. This will generate more redo and more overheads. Also, when something goes pear shape in that process, some rows would have been processed and inserted and committed. Some not.
In this case, how do you expect to restart the failed process at the very first row that failed to be committed and continue processing from there? -
Here is one for the tekkies. How to do this in SQL?
Input : String 541862356
Table has 2 columns:
SNO SLENGTH
5418 4
54186 5
54321 5
Output should be 54186.
We don't have any other input. i.e. we have to get the closest match for the input string.
How to do this??
Edited by: user12240205 on May 3, 2012 10:51 PMuser12240205 wrote:
We don't have any other input. i.e. we have to get the closest match for the input string.You haven't explained what "closest match" actually means.
Something as simple as this could do what you want with the sample data you've provided...
SQL> ed
Wrote file afiedt.buf
1 WITH t AS (SELECT 5418 sno, 4 cnt FROM DUAL UNION
2 SELECT 54186, 5 FROM DUAL UNION
3 SELECT 54321, 5 FROM DUAL)
4 ,r as (select 541862356 as r from dual)
5 --
6 -- end of test data
7 --
8 select max(sno)
9 from t,r
10* where instr(r, sno) > 0
SQL> /
MAX(SNO)
54186... without the need for any Henry Winkler matching stuff (as we affectionately call it round here). -
How to Update this T-SQL Table?
Hello,
I am having trouble finding the correct syntax for updating this T-SQL table.
Here is my Query which is adding an additional ' at the beginning and end.
Query:
Update [denodo].[dbo].[wrappers]
SET wrapperWhereClause = '''AND County_Input=''Cheyenne & Arapaho Tribal Court'' AND WrapperID=729'''
WHERE wrapperID = '729'
The Outcome:
'AND County_Input='Cheyenne & Arapaho Tribal Court' AND WrapperID=729'
The Outcome I am hoping for:
AND County_Input='Cheyenne & Arapaho Tribal Court' AND WrapperID=729
Can anyone help me edit this so I can receive the outcome I am hoping for?>> Please learn
I am having trouble finding the correct syntax for updating this T-SQL table. Here is my Query [sic] which is adding an additional ' at the beginning and end. <<
Please learn basic terms so
we can communicate. UPDATE is a statement and not a query. You do not know ISO-11179 rules, etc.
Why are you building statements in SQL? You are doing bad SQL programming
and need to stop. Your silly meta-data “wrapper_where_clause” and “county_input” is so fundamentally wrong I would fire you. Look at what I have done
with SQL and see what a criticism that is!
UPDATE Wrappers
SET ??
WHERE county_something =
'Cheyenne & Arapaho Tribal Court'
AND wrapper_id = '729';
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
How do i use PL/SQL function in filter operator
Hi,
i want to use one pl/sql function in filter operator. how do i use it in filter condition.
error i am getting is
" error occured during expression validatation.
my filter condition is
INOUTGRP1.LAST_UPDATE_DATE > "GET_LAST_UPDATE_DATE"()
can any one suggest me what is the problem for this error.
Regards,
JyothyI tried and getting the same error. don't know why!!
However, There is another way of accomplishing it.
You can add a "Mapping Input Parameter" to your mapping and in the default value field call the function "Get_Last_Update_date". Then add the output field from this operator to the filter operator. Then edit the filter condition to replace the function call with output value from the Input parameter operator.
This should work... -
How to distinguish built-in SQL functions of PL/SQL?
I m having a hard time to figure out which functions are used ONLY in SQL statements and which are used in regular expr(ie, variable assignment,). Can anyone show me a list of each or perhaps a URL to look for?
I have searched through either the developer's guide and reference but couldn't find any appropriate indication in one place that make it clear.
For instance, I thought I can use CAST function in a variable assginment like the following:
declare
cursor myCur is SELECT Value_varchar2(1) FROM table WHERE id = 1;
myRec myCur%ROWTYPE;
var_a NUMBER(1);
begin
OPEN myCur;
FETCH myCur INTO myRec;
CLOSE myCur;
var_a := CAST(myCur.Value_varchar2(1) AS NUMBER(1));
DBMS_OUTPUT.PUT_LINE('var_a = ' || TO_CHAR(var_a));
end;
. It seems like CAST function can ONLY be used in SQL statement, but no doc so far states that?!
Edited by: HappyJay on 2010/05/12 12:05Sorry to bother you, Bob!
I think I might already found the list. Is it the following list?
---------------------- QUOTED FROM Oracle® Database PL/SQL Language Reference 11g Release 2 (11.2)Part Number E10472-06
SQL Functions in PL/SQL Expressions
In PL/SQL expressions, you can use all SQL functions except:
Aggregate functions (such as AVG and COUNT)
Analytic functions (such as LAG and RATIO_TO_REPORT)
Data mining functions (such as CLUSTER_ID and FEATURE_VALUE)
Encoding and decoding functions (such as DECODE and DUMP)
Model functions (such as ITERATION_NUMBER and PREVIOUS)
Object reference functions (such as REF and VALUE)
XML functions (such as APPENDCHILDXML and EXISTSNODE)
These conversion functions:
BIN_TO_NUM
These miscellaneous functions:
CUBE_TABLE
DATAOBJ_TO_PARTITION
LNNVL
NVL2
SYS_CONNECT_BY_PATH
SYS_TYPEID
WIDTH_BUCKET
PL/SQL supports an overload of BITAND for which the arguments and result are BINARY_INTEGER.
When used in a PL/SQL expression, the RAWTOHEX function accepts an argument of data type RAW and returns a VARCHAR2 value with the hexadecimal representation of bytes that comprise the value of the argument. Arguments of types other than RAW can be specified only if they can be implicitly converted to RAW. This conversion is possible for CHAR, VARCHAR2, and LONG values that are valid arguments of the HEXTORAW function, and for LONG RAW and BLOB values of up to 16380 bytes.
---------------------- -
Execute this pl/sql function with some proper example & syntax
--program is compiled but how to run this function with some proper example please please help me
CREATE OR REPLACE
FUNCTION EMP_GENDER(
EMP_GEN CHAR)
RETURN CHAR
IS
CUST_GEN CHAR(1) ;
DTECH1 EXCEPTION;
BEGIN
CUST_GEN :=UPPER(EMP_GEN);
IF CUST_GEN !='M' OR CUST_GEN != 'F' THEN
RAISE DTECH1;
ELSE
RETURN CUST_GEN;
END IF;
EXCEPTION
WHEN DTECH1 THEN
DBMS_OUTPUT.PUT_LINE('INVALID GEN');
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;Or in pl/sql;-
declare
v_gender char(1) default 'M';--change M to whatever test scenario
begin
v_gender:= emp_gender(v_gender);
dbms_output.put_line(v_gender);
end;And remember to set your serveroutput on.... though your errors will be obvious enough... -
How can I order PL/SQL functions in "Called" a "Caller" order in function script file
Does anybody know how to create PL/SQL function script file
in "called" and "caller" (parent/child) order.
Thanks
SoheilDoes anybody know how to create PL/SQL function script file
in "called" and "caller" (parent/child) order.
Thanks
Soheil -
How to find out PL/SQL function usage in Discoverer workbooks?
We have to make changes to one PL/SQL function that has been registered in Administrator. Is it possible to find out in which reports the function is used? The function is called in calculations and it returns certain time information. We have to add one argument to the function and therefore have to change calculations where the function is called. We have too many workbooks to manually check them all.
I am aware how to find out which folders and items are used in workbooks but can't find the same information about functions. We are using Discoverer 10.1.2.2
Thanks in advance!Hi,
If you calculation is in the EUL you can look at the item dependencies, but if your calculation is in the workbook there is no way other than using the workbook dump (d51wkdmp.exe) utility or opening the workbook and manually checking.
You might want to consider overlaying the PL/SQL function definition so that there are 2 variants of the function. You can then add the extra parameter as an optional parameter in Discoverer. The correct variant will be called depending on how many parameters are used.
Hope that helps,
Rod West -
How do I call pl/sql function from Toplink
I can easily call a stored procedure from Toplink
====================================================
public Collection executeSelectingStoredProcedure(StoredProcedureCall storedProcedureCall) throws DAOException
Collection returnValue = null;
Session session = null;
session = this.getSession();
returnValue = session.executeSelectingCall(storedProcedureCall);
session.release();
return returnValue;
====================================================
The same does not work for pl/sql functions. Doesnt Toplink treat function calls as a callable statement as in JDBC?
"select <function_name>(<arguments>) from dual" seems to be a work around. If this or using expressions is the only solution can someone please tell me the reasoning behind this shift.
Regards
Aamir DehlaviI have the same problem.
I have a PL/SQL function that returns a number. This function receives 2 parameters. I use StoredProcedureCall plus ValueReadQuery.
Session aSession = SessionManager.getManager().getDefaultSession();
StoredProcedureCall call = new StoredProcedureCall();
call.setProcedureName("CIO_UTILS.COUNT_USER_ROLES_IN_MODULE");
call.addNamedArgument("p_persid");
call.addNamedArgument("p_module");
call.addUnamedOutputArgument("rolesnum", Integer.class);
ValueReadQuery query = new ValueReadQuery();
//query.bindAllParameters();
query.setCall(call);
query.addArgument("p_persid");
query.addArgument("p_module");
Vector parameters = new Vector();
parameters.addElement(persid);
parameters.addElement(theModule);
Integer rolesnum = (Integer) aSession.executeQuery(query,parameters);
aSession.release();
if(rolesnum.intValue()<=0)return false; else return true;
However, I receive the following error:
Exception [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)): oracle.toplink.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: ORA-06550: line 1, column 96:
PLS-00312: a positional parameter association may not follow a named association
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Error Code: 6550
Call:BEGIN CIO_UTILS.COUNT_USER_ROLES_IN_MODULE(p_persid=>'SANCRA2791', p_module=>'PSL_MONITORING', ?); END;
bind => [=> rolesnum]
If comment the line
"call.addUnamedOutputArgument("rolesnum", Integer.class);"
Toplink is trating it as a procedure, and I also receive an error from PL/SQL.
There should have to be a way of make it to receive the resoult somehow, but I do not know what.
Thanks in advance. -
m doing a quarterly report and my database only collects the year and month fields.
i currently have this condition in my periodic/monthly report
WHERE
period= '@Request.Period~' and
year = '@Request.Year~'
how do you do this so that when the user inputs quarter 1, the condition becomes "from period 1 to 3". when the user inputs quarter 2, the condition becomes "from period 4 to 6" etc?>well, the users input would only be 1,2,3,4 which stands for the quarter.
I misunderstood your original post. Please try;
old: with t as (
select to_date('01-JAN-2007','DD-MON-YYYY') dt from dual union all
select to_date('01-FEB-2007','DD-MON-YYYY') dt from dual union all
select to_date('28-FEB-2007','DD-MON-YYYY') dt from dual union all
select to_date('31-MAR-2007','DD-MON-YYYY') dt from dual union all
select to_date('01-APR-2007','DD-MON-YYYY') dt from dual union all
select to_date('30-APR-2007','DD-MON-YYYY') dt from dual)
select dt
from t
where trunc(dt,'Q')= add_months(trunc(to_date('&year','YYYY'),'y'),(&quarter-1)*3)
new: with t as (
select to_date('01-JAN-2007','DD-MON-YYYY') dt from dual union all
select to_date('01-FEB-2007','DD-MON-YYYY') dt from dual union all
select to_date('28-FEB-2007','DD-MON-YYYY') dt from dual union all
select to_date('31-MAR-2007','DD-MON-YYYY') dt from dual union all
select to_date('01-APR-2007','DD-MON-YYYY') dt from dual union all
select to_date('30-APR-2007','DD-MON-YYYY') dt from dual)
select dt
from t
where trunc(dt,'Q')= add_months(trunc(to_date('2007','YYYY'),'y'),(1-1)*3)
SQL> with t as (
select to_date('01-JAN-2007','DD-MON-YYYY') dt from dual union all
select to_date('01-FEB-2007','DD-MON-YYYY') dt from dual union all
select to_date('28-FEB-2007','DD-MON-YYYY') dt from dual union all
select to_date('31-MAR-2007','DD-MON-YYYY') dt from dual union all
select to_date('01-APR-2007','DD-MON-YYYY') dt from dual union all
select to_date('30-APR-2007','DD-MON-YYYY') dt from dual)
select dt
from t
where trunc(dt,'Q')= add_months(trunc(to_date('2007','YYYY'),'y'),(1-1)*3)
DT
01-JAN-07
01-FEB-07
28-FEB-07
31-MAR-07
4 rows selected. -
Hi All,
I am creting a Stored Procedure and when i run this sentence the SQL Plus requests my the value of the variable 'lolo' and the i want to compile the Procedure, without giving that value.
1 create procedure hh
2 as
3 begin
4 DBMS_OUTPUT.PUT_LINE('&lolo');
5* end;
SQL> /
Enter value for jhsdfsd: df
old 4: DBMS_OUTPUT.PUT_LINE('hshfdhs&jhsdfsd');
new 4: DBMS_OUTPUT.PUT_LINE('hshfdhsdf');
Nelson SolerAlthough V's solution (V, nice to see you back by the way), will allow you to compile the proc with the ampersand character, I suspect that the stored proc will not do what you expect.
If you are expecting it to prompt for a value of lolo when you run it, it won't.
SQL> SET DEFINE ^
SQL> CREATE PROCEDURE hh AS
2 BEGIN
3 DBMS_OUTPUT.Put_Line('&lolo');
4 END;
5 /
Procedure created.
SQL> SET SERVEROUTPUT ON
SQL> exec hh
&lolo
PL/SQL procedure successfully completed.You cannot prompt for values in PL/SQL.
TTFN
John
Maybe you are looking for
-
Memory upgrade on Satellite P205
Gents, is it possible to increase RAM memory to 6 or 8 GB Windows 7 in the Satellite P205-S6337? Can it use Windows 7 , operating in 64 bits ? Thank you
-
Creative Suite 5 and Acrobat 9 Pro Installation Question.
Hi We currently have a number of machines that have Acrobat 9 Pro installed as Standalone software along with Creative Suite 5, which is now showing up as two individual licenses, one for Acrobat 9 Pro and the other for Creative Suite Bundle. I have
-
Does my app need to work on 3.5" display?
So I have developed an application for the iPhone however before I release it/attempt to publish it, I would like to know whether it is a requirement that I also make 3.5" display support.Currently in the simulator the 3.5" display cuts the bottom of
-
Up for something new in Java - tabs and executables.
Hey again, Ive grown quite confident in my basics for JAVA and now want to try some new things. I want to make a piece of java that i could actually open like somekind of program, preferably (like) a .exe file, Are you aware of any way to acomplish t
-
Java 7 for mac os 10.8 won't work
I tried to play minecraft but it wont even open. some couple days ego i was uploading my app to the app store and i was having trouble so i found this comands on a website to solve the problem. cd /System/Library/Frameworks/JavaVM.framework/Versions