Help with Select Replace
hi
I m trying to replace a number
Select replace(2222505.30321,2222505,'0000000') item from dual
it works fine for this but i want it to replace all the items with the segment#1 between 2222500 and 2222509
Thanks
aston
test@XE> --
test@XE> with t as (
2 select 2222497.30321 + rownum as x
3 from all_objects
4 where rownum < 15
5 )
6 --
7 select
8 x,
9 to_char(case when trunc(x) between 2222500 and 2222509
10 then x - trunc(x)
11 else x
12 end,'0000000.00000') as modx
13 from t;
X MODX
2222498.30321 2222498.30321
2222499.30321 2222499.30321
2222500.30321 0000000.30321
2222501.30321 0000000.30321
2222502.30321 0000000.30321
2222503.30321 0000000.30321
2222504.30321 0000000.30321
2222505.30321 0000000.30321
2222506.30321 0000000.30321
2222507.30321 0000000.30321
2222508.30321 0000000.30321
2222509.30321 0000000.30321
2222510.30321 2222510.30321
2222511.30321 2222511.30321
14 rows selected.
test@XE>
test@XE>
test@XE> HTH
isotope
Similar Messages
-
Help with SELECT - selecting range of numbers
Hi,
I need a help with SELECT statement. I want to select Dates starting from today and ending 30 days back. So the result would be like:
TRUNC(SYSDATE)
TRUNC(SYSDATE) - 1
TRUNC(SYSDATE) - 2
TRUNC(SYSDATE) - 3
TRUNC(SYSDATE) - 30I was thinking to simply select truncated SYSDATE in first column, and in second column numbers 0, 1, 2, ... 30. Then I would simply do a difference first column - second column. But how to select such sequence of numbers? I don't want to select each number (date) in separate select statement and then unioning them.
Does anybody have an idea?
Thanks for help, DanSQL> select trunc(sysdate) - level + 1 as dt
2 from dual
3 connect by level <= 31
4 ;
DT
07/01/2013
06/01/2013
05/01/2013
04/01/2013
03/01/2013
02/01/2013
01/01/2013
31/12/2012
30/12/2012
29/12/2012
28/12/2012
27/12/2012
26/12/2012
25/12/2012
24/12/2012
23/12/2012
22/12/2012
21/12/2012
20/12/2012
19/12/2012
DT
18/12/2012
17/12/2012
16/12/2012
15/12/2012
14/12/2012
13/12/2012
12/12/2012
11/12/2012
10/12/2012
09/12/2012
08/12/2012
31 rows selected -
Help with selecting chuncks of data from a table
Hi all,
I need help with a query that should do the following.
I have a table with vessel messages, and I need to get the last "NumMsgs" messages from a group of vessels.
The problem I have is that if I order the table by Vessel_ID, MessageDate DESC, I can´t do ROWNUM < NumMsgs (<-- Then number of messages to be shown is a user parameter)
I know it should be something like:
select * from (
select *
from Messages m
where TRIM(m.V_ID) = '11597' /* I was trying for a single vessel atm */
order by m.V_ID, m.MESSAGEDATE desc
where rownum < :NumMsgs
Any ideas?
Thanks in advance !Hi,
What about :
select *
from (
select m.*, row_number() (order by m.V_ID, m.MESSAGEDATE desc) rn
from Messages m
where TRIM(m.V_ID) = '11597' /* I was trying for a single vessel atm */
where rn < :NumMsgsAnyway, I don't very well understand your problem, your query work fine, see for example :
SQL> ed
Wrote file afiedt.buf
1 select object_name, object_id
2 from
3 (select object_name, object_id, row_number() over (order by object_id desc) as rn
4 from dba_objects)
5* where rn < 4
SQL> /
PS_TL_MTCHD_118 71763
PS_TL_MTCHD_117 71762
PS_TL_MTCHD_116 71761
SQL> ed
Wrote file afiedt.buf
1 select object_name, object_id
2 from
3 (select object_name, object_id
4 from dba_objects
5 order by object_id desc)
6* where rownum < 4
SQL> /
PS_TL_MTCHD_118 71763
PS_TL_MTCHD_117 71762
PS_TL_MTCHD_116 71761
SQL> Nicolas.
Message was edited by:
N. Gasparotto -
Help with Find / Replace button title tag contents (text)
Hi there,
I designed my site with Sitegrinder (Medialab) –
Currently all the title tags generated for buttons are the same as
the actual html page name.
The problem with this is that the tooltip which appears in
browsers when you hover over the button with the mouse gives you
the page name. Instead I want to use these tooltips to give the
user an indication of what the function of the button is.
An example: A zoom button above an image: Currenty the
tootlip says “zoom imagename pagename” – Instead
it should say “click here to zoom”.
I need help to get the Dreamweaver Find and Replace tool to
batch replace these tags for me for about a 100 pages.
Here is an example of the code:
<body>
<div id="id1zoomimpastooilweddingbutton"><a
href="zoomimpastooilwedding.html"
title="zoomimpastooilwedding"></a></div>
I only want to replace the text in the title tag - Since the
text “zoom” appears several times in the body, I
can’t get the Find tool to pick up and Replace the occurrence
of “zoom” in the title only…….
Options I’ve tried:
Search Current document: Search for: “specific
tag”: “title”, “containing”:
“text” = zoom (I’ve tried this with
“zoomimpastooilwedding” and zoom[^”]* with no
results
I’ve also tried: Search for: “specific
tag”: “body”, “containing”:
“specific tag” “title”
“containing”: “text” = zoom
etc……………..
I need help with what parameters to enter in order to find
and replace all the text within the title tag with my own text
Thanks very much!
AntonYou have ~ 100 pages, each of which has images with title
attributes (not
tags), all of which BEGIN with the letters "zoom"?
What do you want to replace that text with? Wouldn't it be
different for
each button? Or do you mean that you would do multiple
sitewide searches,
one for each button? This illustrates how wrong it is to not
use DW
Templates or server-side includes to simplify the management
of your
navigation elements....
Did you ask Medialabs if it would be possible to specify this
before
generating the HTML?
How did you like working with SiteGrinder? It looks like a
nice product to
me, although I'm not fond of the final results code-wise....
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
==================
"unison123" <[email protected]> wrote in
message
news:[email protected]...
> Hi there,
>
> I designed my site with Sitegrinder (Medialab) ?
Currently all the title
> tags
> generated for buttons are the same as the actual html
page name.
>
> The problem with this is that the tooltip which appears
in browsers when
> you
> hover over the button with the mouse gives you the page
name. Instead I
> want to
> use these tooltips to give the user an indication of
what the function of
> the
> button is.
>
> An example: A zoom button above an image: Currenty the
tootlip says ?zoom
> imagename pagename? ? Instead it should say ?click here
to zoom?.
>
> I need help to get the Dreamweaver Find and Replace tool
to batch replace
> these tags for me for about a 100 pages.
>
> Here is an example of the code:
>
> <body>
> <div id="id1zoomimpastooilweddingbutton"><a
> href="zoomimpastooilwedding.html"
> title="zoomimpastooilwedding"></a></div>
>
> I only want to replace the text in the title tag - Since
the text ?zoom?
> appears several times in the body, I can?t get the Find
tool to pick up
> and
> Replace the occurrence of ?zoom? in the title only??.
>
> Options I?ve tried:
>
> Search Current document: Search for: ?specific tag?:
?title?,
> ?containing?:
> ?text? = zoom (I?ve tried this with
?zoomimpastooilwedding? and zoom[^?]*
> with
> no results
>
> I?ve also tried: Search for: ?specific tag?: ?body?,
?containing?:
> ?specific
> tag? ?title? ?containing?: ?text? = zoom etc?????..
>
> I need help with what parameters to enter in order to
find and replace all
> the
> text within the title tag with my own text
>
> Thanks very much!
>
> Anton
>
> -
Need help with select that month range with flexible first date
Hello everyone,
I am trying to create a selection of month range (will be in a WITH clause) for a report to display monthly data. But the first month start date can be any date. (Not necessarily the first date of the month)
Examples:
Report input parameters:
Start Date: 08/10/12
End Month: Dec 2012
I was trying to build a with select that will list
Month_Start, Month_End
08/10/12, 31/10/12
01/11/12, 30/11/12
01/12/12, 31/12/12
OR
Month_Start, Next_Month
08/10/12, 01/11/12
01/11/12, 01/12/12
01/12/12, 01/01/13
End month is optional, so if no value the select will list only
08/10/12, 01/11/12
Oracle Database Details is
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
My code so far is
VARIABLE P50_START_DATE VARCHAR2 (10)
VARIABLE P50_END_MONTH VARCHAR2 (10)
EXEC :P50_START_DATE := '10/10/2012';
EXEC :P50_END_MONTH := '31/12/2012';
SELECT to_char(:P50_START_DATE) AS start_date
, ADD_MONTHS( TRUNC(to_date(:P50_START_DATE,'DD/MM/YYYY'),'MONTH'), 1) AS next_month
FROM dual
union
SELECT to_char(ADD_MONTHS( TRUNC(to_date(:P50_START_DATE,'DD/MM/YYYY'),'MONTH'), ROWNUM-1)) AS start_date
, ADD_MONTHS( TRUNC(to_date(:P50_START_DATE,'DD/MM/YYYY'),'MONTH'), ROWNUM) AS next_month
--, rownum
from all_objects
where
rownum <= months_between(to_date(NVL(:P50_END_MONTH, :P50_START_DATE),'DD/MM/YYYY'), add_months(to_date(:P50_START_DATE,'DD/MM/YYYY'), -1))
and rownum > 1If I put comment – on line and rownum > 1, as
-- and rownum > 1The result I get is
START_DATE NEXT_MONTH
01/10/12 01/10/12
01/11/12 01/11/12
01/12/12 01/01/13
10/10/2012 01/11/12 But when I try to remove the duplicate period (of the first month) out by restrict rownum, it do not return any rows for the second select at all. The result I get is:
START_DATE NEXT_MONTH
10/10/2012 01/11/12 Can anyone advise what wrong with the select statement ?
Thanks a lot in advance,
AnnHi,
Here's one way:
WITH params AS
SELECT TO_DATE (:p50_start_date, 'DD/MM/YYYY') AS start_date
, TO_DATE (:p50_end_month, 'DD/MM/YYYY') AS end_date
FROM dual
SELECT GREATEST ( start_date
, ADD_MONTHS ( TRUNC (start_date, 'MONTH')
, LEVEL - 1
) AS month_start
, LEAST ( end_date
, ADD_MONTHS ( TRUNC (start_date, 'MONTH')
, LEVEL
) - 1
) AS month_end
FROM params
CONNECT BY LEVEL <= 1 + MONTHS_BETWEEN ( end_date
, TRUNC (start_date, 'MONTH')
;:p50_end_month doesn't have to be the last day of the month; any day will work.
If you want to generate a Counter Table containing the integers 1 througn x in SQL, you could say
SELECT ROWNUM AS n
FROM all_objects
WHERE ROWNUM <= x
;but, starting in Oracle 9.1, it's much faster to say
SELECT LEVEL AS n
FROM dual -- or any table containing exactly 1 row
CONNECT BY LEVEL <= x
;Also, x can be greater than the number of rows in all_objects. -
Good morning everyone,
I have a problem with my function. I need to do the dynamic select with the SELECT INTO
create or replace function prueba (p_param IN VARCHAR2) RETURN VARCHAR2
IS
v_aux1 VARCHAR2(200);
v_aux2 VARCHAR2(200);
BEGIN
SELECT col1
INTO v_aux1
FROM my_table
WHERE col2 = p_param; --UNION SELECT '1233' FROM DUAL;
RETURN v_aux1;
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR(-20000,SQLERRM );
--RETURN v_aux2;
END;
When I try to call my function with the golden as follows:
select (prueba('''MON'' UNION SELECT '||chr(039)||'12'||chr(039)||' FROM DUAL')) from dual
OR
select (prueba(chr(039)||'MON'||chr(039)||' UNION SELECT '||chr(039)||'12'||chr(039)||' FROM DUAL')) from dual
I get the error: no data found
If I use the sentence in Golden or SQLPLUS as follows:
SELECT col1
-- INTO aux1
FROM my_table
WHERE despaise = 'MON' UNION SELECT '12' FROM DUAL
It ´s correct, and it return '1233'
The value 'MON' no exists in my_table.
If uncommented the sentence "UNION SELECT '1233' FROM DUAL" in my function an I use 'MON' as parameter it´s correct.
How I can do this using the parameter with the UNION?.
Thank you very much to all and sorry for my englishHi,
welcome to the forum.
Please read SQL and PL/SQL FAQ
When you put some code or output please enclose it between two lines starting with {noformat}{noformat}
i.e.:
{noformat}{noformat}
SELECT ...
{noformat}{noformat}
you cannot pass static SQL as part of the string.
When you call the procedure in either wayselect (prueba('''MON'' UNION SELECT '||chr(039)||'12'||chr(039)||' FROM DUAL')) from dual
select (prueba(chr(039)||'MON'||chr(039)||' UNION SELECT '||chr(039)||'12'||chr(039)||' FROM DUAL')) from dual
This result in passing a whole string to your function as'MON' UNION SELECT '12' FROM DUAL
which translates in your code asSELECT col1
INTO v_aux1
FROM my_table
WHERE col2 = '''MON'' UNION SELECT ''12'' FROM DUAL'
So it is searching a rows having col2 with value '''MON'' UNION SELECT ''12'' FROM DUAL'
Please try to explain what you are trying to achieve and we may help you.
You could use dynamic SQL to do that but it is not clear what are your business requirement and the approach that you are using does not seem to be correct.
Regards.
Al -
Hello, Oracle community. I'm a new developer fresh out of school and I'm working on an issue tracker project on Apex 2.1. I have a page where we create cases that involve various issues called in by our clients through our support center. This app is supposed to replace what the support center currently has.
My main problem is functionality. I have several select lists that redirect to the case creation page. I have conditions that allow several hidden fields to appear when certain values are chosen. We also have a couple of text areas for details and resolutions. The problem is that when we enter data into the text areas (CASE_DETAIL and CASE_RES) and escalate the case to a higher tier of support via redirecting select list, all text that was typed is cleared away when it redirects back to the page. All other select list values remain because they've already been redirected. How do I keep my text fields populated while preserving my select lists? The text areas are set to "Only when current..."
If there's any links that you guys can provide with detailed info on how to handle these types or problems (the documentation is a bit general) I'd greatly appreciate it. I'm still learning this stuff. :)
DennisWow, thanks.
We had tried this before, but since we had email shooting off to our clients whenever the page was submitted, we went with the redirect. My brother (we're both working on this project) found the following topic while looking for this one:
Select list with Redirect => other page items are reseted
We had used the process to only send email when the CREATE button was pressed but completely missed the fact that we could do the same with the process row. The solution now is to switch all select lists to submit and make the process row conditional to only fire when the CREATE button is pressed. Now the page submits as much as it wants to, the text fields stay populated, and we don't get redundant emails and entries into the CASE table.
Thanks for the help. I hope to return the favor some day. :) -
Help with missing/replaced library
I recently upgraded to iphoto 08. I had all my 07pics so I wanted to save them in my external harddrive to free up space so I made a copy of my iphoto library and saved it to my external hard drive.
I was recently traveling and did not have my external hard drive with me. I had some new pics I wanted to upload so when I did it said it could not find my library and asked me if I wanted to create one. I said yes and it put all my new pics in my iphoto. When I got back home and hooked up my external hard drive I didnt get any new edits... when I went to look in my external harddrive for my 07 pics...my iphoto library there had been replaced with the new content as well and my 07 pics are missing..?
Any Idea where my other pictures are and how I can access them.
I dont think they are gone because I made an imovie using some of those pics and the pics are still availabe in my imovie (but not my library).
Any help is appreciated... Barbi..Barbi:
It appears that you currently have two libraries, one on your laptop with the most recent photos and the original one on the external HD. To open one or the other launch iPhoto with the Option key depressed, and when asked, select the option to Choose Library. Navigate to the library you want to open and select it. Or you can use the free version of iPhoto Library Manager to quickly move between libraries.
If you want to copy your photos from the laptop library to the external HD library you can use the paid version of iPLM to do that and that will preserve any keywords, title changes or comments.
TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
I've created an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 08 libraries and Leopard. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file. -
Help with selecting files from script menu or drag and drop
I found this scale images applescript online. It works great when a bunch of files is dragged on top of the script but I would like it to also work when a folder or group of files is selected in the Finder and I activate it from the scripts menu.
I can't get my on run statement to work. I'm not really an Applescript guy so I'm really just asking if someone can help finish what I started in this on run.
-- save in Script Editor as Application
-- drag files to its icon in Finder
property target_width : 120
property save_folder : ""
on run
tell application "Finder"
activate
set folder_path to quoted form of (POSIX path of (the selection as alias))
set theItems to every file of folder_path
end tell
end run
on open some_items
-- do some set up
tell application "Finder"
-- get the target width, the default answer is the property target_width
set new_width to text returned of ¬
(display dialog "Target width:" default answer target_width ¬
buttons {"OK"} default button "OK")
if new_width as integer > 0 then
set target_width to new_width
end if
-- if the save_folder property has not been set,
-- set it to the folder containing the original image
if save_folder is "" then
set save_folder to ¬
(container of file (item 1 of some_items) as string)
end if
-- get the folder to save the scaled images in,
-- default folder is the property save_folder
set temp_folder to ¬
choose folder with prompt ¬
"Save scaled images in:" default location alias save_folder
set save_folder to temp_folder as string
end tell
-- loop through the images, scale them and save them
repeat with this_item in some_items
try
rescaleand_save(thisitem)
end try
end repeat
tell application "Image Events" to quit
end open
on rescaleand_save(thisitem)
tell application "Finder"
set new_item to save_folder & "scaled." & (name of this_item)
end tell
tell application "Image Events"
launch
-- open the image file
set this_image to open this_item
set typ to this_image's file type
copy dimensions of this_image to {current_width, current_height}
scale this_image by factor (target_width / current_width)
save this_image in new_item as typ
end tell
end rescaleandsaveWhen items are dragged to your script's icon they are passed in to the on open handler, so this triggers:
on open some_items
and the dragged items are passed in as some_items
In contrast, when you double-click on the script, or invoke it via the Script menu, this runs the on run handler:
on run
tell application "Finder"
activate
folder_path to quoted form of (POSIX path of (the selection as alias))
set theItems to every file of folder_path
end tell
end run
However, there's nothing in this block that actually does anything with the selection - you (dangerously) assume that the selection is a folder (you really should check first), and just set theItems to every file in that folder then you exit.
So to do what you want you'll need to edit your run handler to filter the selection and pass files over to the code that does the hard work.
You already have the basis for this - your rescaleandsave() handler, so it's just a matter of identifying the files in the selection and passing those over to that handler:
on run
tell application "Finder"
set cur_selection to (get selection) -- get the selection
repeat with each_item in cur_selection -- iterate through
if class of each_item is folder then -- do we have a folder?
set theFiles to every file of each_item -- if so, get its contents
repeat with each_file in theFiles -- iterate through them
my rescaleand_save(eachfile) -- and process them
end repeat
else if class of each_item is document file then -- do we have a file selected?
my rescaleand_save(eachitem) -- if so, process it
end if
end repeat
end tell
end run
So the idea here is that the run handler gets the selection and works through the (potentially-numerous) items. For each selected item it checks whether its a folder or a file, if its a folder it gets all the files within and passes them to the rescaleandsave handler.
Note that this is not recursive - it won't catch files within folders within folders - since it only looks at the top level of selected folders, but it wouldn't be hard to rework the script to handle that if that's what you need. -
Help with select code??
I have a calendar program in jsp. The users can enter description for the dates. These dates are stored in the database. I need to provide colors to those dates,which have a value 'N' in the weekender field. Am able to write the query, but am not able to provide the color. how can i do it? please help..
<%@ page import="java.util.List"%>
<%@page import="java.sql.*, java.util.*, java.text.*" %>
<%@page import="java.sql.Connection, java.sql.DriverManager,java.sql.ResultSet,java.sql.SQLException" %>
<html>
<head>
<title>Print a month page.</title>
<meta name="version">
<script>
var lastId = "";
var curId = "";
function selectDate(f)
if(document.forms[0].lastDateId != null)
lastId = document.forms[0].lastDateId.value;
if(lastId != document.forms[0].todayId.value)
if(document.getElementById(lastId).title == "")
document.getElementById(lastId).style.backgroundColor='white';
if(f.id != document.forms[0].todayId.value)
document.getElementById(f.id).style.backgroundColor='blue';
document.forms[0].lastDateId.value=f.id;
curId = f.id;
document.getElementById("descr").style.visibility='visible';
document.forms[0].descText.value = f.title;
function setTitle()
document.getElementById(curId).title=document.forms[0].descText.value;
if(document.forms[0].descText.value == "" && curId != document.forms[0].todayId.value)
document.getElementById(curId).style.backgroundColor='white';
else
if(document.forms[0].list.value == "" )
document.forms[0].list.value = curId+":"+document.getElementById(curId).title;
else
list = replaceList(document.forms[0].list.value,curId);
list = list+","+curId+":"+document.getElementById(curId).title;
document.forms[0].list.value = list;
document.getElementById("descr").style.visibility='hidden';
function replaceList(list,id)
arr = list.split(",");
newlist = "";
for(i in arr)
if(arr.match(id) == null)
if(newlist == "")
newlist = arr[i];
else
newlist += ","+arr[i]+",";
return newlist
function showCalendar()
location.href="CalendarPage.jsp?year="+document.forms[0].year.value;
</script>
</head>
<body bgcolor="#c6d9e4">
<%
Connection con = null;
response.setContentType("text/html");
try
String driverName = "com.mysql.jdbc.Driver";
Class.forName(driverName);
String serverName = "192.168.10.5";
String mydatabase = "Trainees";
String url = "jdbc:mysql://" + serverName + "/" + mydatabase;
String username = "venkat";
String password = "venkat";
con = DriverManager.getConnection(url, username, password);
Statement stmt = null;
ResultSet rset = null;
PreparedStatement PREPstmt1;
stmt = con.createStatement();
String year = request.getParameter("year");
out.println("year value is : "+year);
String date="",descr="";
String list = request.getParameter("list");
if(list != null)
String dateDescrList[] = list.split(",");
for(int i=0;i<dateDescrList.length;i++)
String listObj = dateDescrList[i];
if(!listObj.equals("") || !listObj.trim().equals(""))
date= year+"-"+listObj.substring(0,listObj.indexOf(":"));
descr = listObj.substring(listObj.indexOf(":")+1);
out.println("date is : "+date);
out.println("description is : "+descr);
String query = "insert into Holiday(HolidayDate, Description, Weekender) VALUES (?, ?, 'N')";
PREPstmt1=con.prepareStatement(query);
PREPstmt1.setString(1,date);
PREPstmt1.setString(2,descr);
PREPstmt1.executeUpdate();
catch(Exception e)
System.err.println("Exception: " + e.getMessage());
finally
try
if(con != null)
con.close();
catch(SQLException e)
%>
<%
Calendar c = Calendar.getInstance( );
boolean yyok = false;
int yy = 0, mm = 0;
String yyString = String.valueOf(c.get(Calendar.YEAR)); //setting calendar with current year
String STyear = request.getParameter("year"); //to get selected year
if(STyear != null) //If an year is selected, then set that year. Else Current Year
yyString=STyear;
if (yyString != null && yyString.length() > 0)
try
yy = Integer.parseInt(yyString);
yyok = true;
catch (NumberFormatException e)
out.println("Year " + yyString + " invalid");
if (!yyok)yy = c.get(Calendar.YEAR);
mm = c.get(Calendar.MONTH);
String todayId = "";
%>
<form method=get action="CalendarPage.jsp">
Enter Year : <select name="year">
<%
for(int i=2000;i<=2015;i++)
if(i==Integer.parseInt(yyString))
%>
<OPTION SELECTED= <%=i%> > <%=i%> </option>
<%
else
%>
<OPTION VALUE= <%=i%> > <%=i%> </option>
%>
<%
%>
</select>
<input type="button" value="Display" onClick="showCalendar()">
<br><br>
<div id="descr" style="visibility:hidden">Enter Description : <input type="text" name="descText" value=""> </div>
<br>
<%
String driverName = "com.mysql.jdbc.Driver";
Class.forName(driverName);
String serverName = "192.168.10.5";
String mydatabase = "Trainees";
String url = "jdbc:mysql://" + serverName + "/" + mydatabase;
String username = "venkat";
String password = "venkat";
con = DriverManager.getConnection(url, username, password);
Statement stmt = null;
ResultSet rset = null;
PreparedStatement PREPstmt1;
stmt = con.createStatement();
rset=stmt.executeQuery("select count(*) from Holiday where YEAR(HolidayDate)='"+yyString+"'");
int cnt=0;
boolean ALflag=false;
while(rset.next())
cnt= rset.getInt(1);
out.println("count is : "+cnt);
if(cnt>1)
ALflag=true;
%>
<%
rset=stmt.executeQuery("select count(*) from Holiday where Weekender='N'");
int cnte=0;
boolean SELflag=false;
while(rset.next())
cnte = rset.getInt(1);
out.println("count is : "+cnte);
if(cnte>1)
SELflag=true;
%>
<%!
String[] months = {
"January", "February", "March",
"April","May", "June",
"July", "August","September",
"October", "November", "December"
int dom[] = {
31, 28, 31, 30,
31, 30, 31, 31,
30, 31, 30, 31
%>
<%
int leadGap = 0;
%>
<table border="0" width="100%" align="Left">
<%
GregorianCalendar calendar =null;
for(int j=0;j<12;j++)
calendar = new GregorianCalendar(yy, j, 1);
if(j==0 || j%3==0)
%>
<tr>
<%
%>
<td halign="top" >
<table border="1" width="33%" align="Left"><tr align="right">
<th colspan=7>
<%= months[j] %>
<%= yy %>
</th>
</tr>
<tr>
<td>Sun<td>Mon<td>Tue<td>Wed<td>Thu<td>Fri<td>Sat
</tr>
<%
leadGap = calendar.get(Calendar.DAY_OF_WEEK)-1;
int daysInMonth = dom[j];
if (calendar.isLeapYear(calendar.get(Calendar.YEAR)) && j == 1)
++daysInMonth;
out.println("<tr>");
out.println(" ");
for (int i = 0; i < leadGap; i++)
out.print("<td> </td>");
for (int iday = 1; iday <= daysInMonth; iday++)
out.println("<td>");
int dayOfWeek = (leadGap + iday) % 7;
GregorianCalendar today = new GregorianCalendar();
if(today.get(Calendar.DATE) == iday && today.get(Calendar.MONTH) == j)
todayId = iday+"-"+(j+1);
%>
<div id="<%=((j+1)+"-"+iday)%>" onClick="selectDate(this)" style="background-color:#cccc00" title="" ><%=iday %></div>
<%
else
if(dayOfWeek <= 1)
String str = yyString+"-"+(j+1)+ "-"+ iday;
if((dayOfWeek == 0) && (ALflag==false))
String query = "insert into Holiday VALUES ('" + str + "','Saturday','Y')";
stmt=con.createStatement();
stmt.executeUpdate(query);
else if ((dayOfWeek == 1) && (ALflag==false))
String query = "insert into Holiday VALUES ('" + str + "','Sunday','Y')";
stmt=con.createStatement();
stmt.executeUpdate(query);
%>
<div id="<%=((j+1)+"-"+iday)%>" onClick="selectDate(this)" style="background-color:#cccccc" title=""> <%=iday %></div>
<%
else
%>
<div id="<%=((j+1)+"-"+iday)%>" onClick="selectDate(this)" style="background-color:white" title="" ><%=iday %></div>
<%
out.println("</td>");
if(calendar.getActualMaximum(Calendar.DAY_OF_MONTH) == iday)
out.println("</td></tr></table>");
else if ((leadGap + iday) % 7 == 0)
out.println("</tr>");
out.println("<tr>");
%>
</td>
<%
if((j+1)%3==0)
%>
</tr>
<%
%>
<input type="hidden" name="lastDateId" value="<%=todayId%>">
<input type="hidden" name="todayId" value="<%=todayId%>">
<input type="hidden" name="list" value="">
<input type="submit" value="Submit" onClick="setTitle()">
</form>
</body>
</table>
</html>
This is the extract of the above code. This is how i have provided the query. In which part of my above code should i provide the coloring aspect. If the (SELflag==false), then i want to provide the color. where should i give? please help
<%
rset=stmt.executeQuery("select count(*) from Holiday where Weekender='N'");
int cnte=0;
boolean SELflag=false;
while(rset.next())
cnte = rset.getInt(1);
out.println("count is : "+cnte);
if(cnte>1)
SELflag=true;
%>Here is the calendar code, which i have used. Where should i use the code to check . i am able to get the count of user inputted days. i want to use the code,
if(SELflag==false)
give color.
where can i give this if code, to get the color?
<%
rset=stmt.executeQuery("select count(*) from Holiday where Weekender='N'");
int cnte=0;
boolean SELflag=false;
while(rset.next())
cnte = rset.getInt(1);
out.println("count is : "+cnte);
if(cnte>1)
SELflag=true;
%>
<%!
String[] months = {
"January", "February", "March",
"April","May", "June",
"July", "August","September",
"October", "November", "December"
int dom[] = {
31, 28, 31, 30,
31, 30, 31, 31,
30, 31, 30, 31
%>
<%
int leadGap = 0;
%>
<table border="0" width="100%" align="Left">
<%
GregorianCalendar calendar =null;
for(int j=0;j<12;j++)
calendar = new GregorianCalendar(yy, j, 1);
if(j==0 || j%3==0)
%>
<tr>
<%
%>
<td halign="top" >
<table border="1" width="33%" align="Left"><tr align="right">
<th colspan=7>
<%= months[j] %>
<%= yy %>
</th>
</tr>
<tr>
<td>Sun<td>Mon<td>Tue<td>Wed<td>Thu<td>Fri<td>Sat
</tr>
<%
leadGap = calendar.get(Calendar.DAY_OF_WEEK)-1;
int daysInMonth = dom[j];
if (calendar.isLeapYear(calendar.get(Calendar.YEAR)) && j == 1)
++daysInMonth;
out.println("<tr>");
out.println(" ");
for (int i = 0; i < leadGap; i++)
out.print("<td> </td>");
for (int iday = 1; iday <= daysInMonth; iday++)
out.println("<td>");
int dayOfWeek = (leadGap + iday) % 7;
GregorianCalendar today = new GregorianCalendar();
if(today.get(Calendar.DATE) == iday && today.get(Calendar.MONTH) == j)
todayId = iday+"-"+(j+1);
%>
<div id="<%=((j+1)+"-"+iday)%>" onClick="selectDate(this)" style="background-color:#cccc00" title="" ><a href="#" style="text-decoration:none;color:808080"><%=iday %> </a></div>
<%
else
if(dayOfWeek <= 1)
String str = yyString+"-"+(j+1)+ "-"+ iday;
if((dayOfWeek == 0) && (ALflag==false))
String query = "insert into Holiday VALUES ('" + str + "','Saturday','Y')";
stmt=con.createStatement();
stmt.executeUpdate(query);
else if ((dayOfWeek == 1) && (ALflag==false))
String query = "insert into Holiday VALUES ('" + str + "','Sunday','Y')";
stmt=con.createStatement();
stmt.executeUpdate(query);
%>
<div id="<%=((j+1)+"-"+iday)%>" onClick="selectDate(this)" style="background-color:#cccccc" title=""> <a href="#" style="text-decoration:none;color:808080"><%=iday %> </a></div>
<%
else
%>
<div id="<%=((j+1)+"-"+iday)%>" onClick="selectDate(this)" style="background-color:white" title="" ><a href="#" style="text-decoration:none;color:808080"><%=iday %> </a></div>
<%
out.println("</td>");
if(calendar.getActualMaximum(Calendar.DAY_OF_MONTH) == iday)
out.println("</td></tr></table>");
else if ((leadGap + iday) % 7 == 0)
out.println("</tr>");
out.println("<tr>");
%>
</td>
<%
if((j+1)%3==0)
%>
</tr>
<%
%>
<input type="hidden" name="lastDateId" value="<%=todayId%>">
<input type="hidden" name="todayId" value="<%=todayId%>">
<input type="hidden" name="list" value="">
<input type="submit" value="Submit" onClick="setTitle()">
</form>
</body>
</table>
</html> -
Hi, If anyone could help me with this. I need to round all these numbers in the DECODE but without repeating ROUND.
This way works:
SELECT title "Title", category "Category",retail "Current Price",
DECODE(category,
'COMPUTER',(ROUND(retail * 1.1,2)),
'FITNESS', (ROUND(retail * 1.15,2)),
'SELF HELP', (ROUND(retail * 1.25,2)),
(ROUND(retail * 1.03,2)))"Revised Price"
FROM books
ORDER BY category, title;
But I need something more like this:
SELECT title "Title", category "Category",retail "Current Price",
DECODE (ROUND((category,
'COMPUTER',retail * 1.1,
'FITNESS', retail * 1.15,
'SELF HELP', retail * 1.25,
retail * 1.03)"Revised Price"),2)
FROM books
ORDER BY category, title;
so that ROUND is not repeated more than once..they all need to be rounded to two decimal places.
any help would be great. Thanksyour second is close. You need to round the decode statement. like this:
SELECT title "Title", category "Category",retail "Current Price",
ROUND(DECODE(category, 'COMPUTER',retail * 1.1,
'FITNESS', retail * 1.15,
'SELF HELP', retail * 1.25,
retail * 1.03),2) "Revised Price"
FROM books
ORDER BY category, title;Note that the alias (I assume) revised Proce needs to go outside of both the decode and the round.
John -
Need help with select within select - daterange
I use Crystal Reports v12.3.0.601 - I am a beginner.
Problem:
TABLE: ACCOUNTBILLFEE
Columns are
FOLDERRSN
STAMPDATE
BILLNUMBER
PAYMENTAMOUNT
There are over 500,000 rows/ records...
And I need to report the FOLDERRSN which has at least one {ACCOUNTBILLFEE.STAMPDATE} in DateTime
(2014, 05, 01, 00, 00, 01) to DateTime (2014, 05, 31, 23, 59, 59)
Out-put required is:
FOLDERSN | STAMPDATE | BILLNUMBER | PAYMENTAMOUNT
Group by FOLDERRSN
1010234 May01,2014 1111 25000
May25, 2014 1112 5000
Jan 05, 2013 998 500
1034567 May5, 2014 11325 5000
1033999 May15, 2014 6752 15000
Dec5 , 2011 1132 25000
Please help -
The critical part for me, is to display payments not within the date range in 'select expert' statement.
Currenlty my report reflects only payments for FOLDERRSN, where {ACCOUNTBILLFEE.STAMPDATE} in DateTime
(2014, 05, 01, 00, 00, 01) to DateTime (2014, 05, 31, 23, 59, 59) and not other payments outside the date range specified.
Thank you for your time.Hi Abilash,
This worked !!!
My brother helped me with it here....ofcourse you have intiated the intial idea.
It worked when i used the following SQL at 'Add Command'
Select * from DATABASE_NAME.ACCOUNTBILLFEE A
Where A.FOLDERSN = any ( select B.FOLDERSN from DATABASE_NAME.ACCOUNTBILLFEE B
where B.STAMPDATE >= TO_DATE('20140501', 'YYYYMMDD')
AND B.STAMPDATE <= TO_DATE('20140531', 'YYYYMMDD'))
Excellent support - Thank you so much for your immediate attention and response.
I know, how hard it is to understand someones requirement and suggest solutions.
You are the best and most helpful I have ever come across in my life.
Thank you for your kind heart and extending help to me.
Regs,
Sridhar Lam -
Well guys, I have a problem here and I didn't find any solutions
So maybe someone of you, can help me!
My problem is:
I have 2 numbers (100 and -200) and I have to plot the greater value.
The problem is for me the signal of -(minus) doesn't means nothing....
For the program I'm making, the -200 is greater than 100
So I tryed put bouth as absolute value, but when I have the "answer" only appears the "200"
and I need it appears -200
So I thought about something like that:
I use a select function and maybe do something like that:
So I have to make something at True or False value at S to make this work!
If true I receive 100, if is false I receive -200
Thanks!I dont know why is in this section. I posted it on LabVIEW part!
Well Dennis I make it like that:
But now I have a problem
I do the same calc for 3 differents variables like A, B, C
and after that I have to calc which value is the "greater"
But my problem is, If I have the values "-350 300 -400"
the greater will be "300" but for me the "minus" don't mean anything
so I need the greater value is "400"
For all positive values, its works fine!
I compare A and B, after that the greater is compared with C and have a result!
but When I have negative values and positive values... I got that problem...
and When I have only negative values I have a problem too.
"-300 -400 -500" for me the greater value have to be "-500" but labview shows "-300"
because -300 is greater than -500 in algebriac.
And If I use absolute values I will always have a positive value... but I need to know if the value is negative or positive
Anyone, can help me with that?
Thanks
Message Edited by EduU on 10-29-2009 11:06 AM -
Hello,
My table looks similar to this, I have removed a few columns:
table1:
Forecast_id Forecast_name Freeze Enabled
100 Q12009 N Y
101 Q22009 N Y
table2:
forecast_id parameter_name parameter_value
100 StartDate 01/01/2009
100 EndDate 03/31/2009
100 Growth % 20
100 Retailer Walmart
101 StartDate 04/01/2009
101 EndDate 06/30/2009
101 Growth % 20
101 Retailer Walmart
What i need to do is
select from table 1, forecast name & freeze
where in table2 parameter = Retailer, Parameter value = Walmart and
Start Date = 01/01/2009 and End Date = 03/31/2009
here is my query is there a easy way this can be done. I have used decode function in the past for similar situation for counting and grouping.
SELECT i.FORECAST_ID,
i.FORECAST_NAME,
i.FREEZE_FLAG
FROM (
SELECT x.FORECAST_ID,
x.FORECAST_NAME,
x.FREEZE_FLAG
FROM (
SELECT A.FORECAST_ID,
A.FORECAST_NAME,
A.FREEZE_FLAG
FROM GC_FORECAST A, GC_FORECAST_PARAMETERS B
WHERE A.FORECAST_ID = B.FORECAST_ID
AND B.PARAMETER_NAME = 'Retailer'
AND B.PARAMETER_VALUE = 'Walmart'
) x, GC_FORECAST_PARAMETERS y
WHERE x.FORECAST_ID = y.FORECAST_ID
AND y.PARAMETER_NAME = 'StartDate'
AND y.PARAMETER_VALUE = '01/01/2009'
) i, GC_FORECAST_PARAMETERS j
WHERE i.FORECAST_ID = j.FORECAST_ID
AND j.PARAMETER_NAME = 'EndDate'
AND j.PARAMETER_VALUE = '03/31/2009';
Thank you for your time and help.
Vidhya
Edited by: snaraya9 on Dec 5, 2008 12:03 PM
Edited by: snaraya9 on Dec 5, 2008 12:06 PMSolution
SELECT gc_forecast.forecast_id, gc_forecast.forecast_name, gc_forecast.freeze,
gc_forecast.enabled
FROM gc_forecast,
(SELECT forecast_id,
MAX (CASE
WHEN parameter_name = 'StartDate'
AND parameter_value = '01/01/2009'
THEN 1
ELSE 0
END
) cond1,
MAX (CASE
WHEN parameter_name = 'EndDate'
AND parameter_value = '03/31/2009'
THEN 1
ELSE 0
END
) cond2,
MAX (CASE
WHEN parameter_name = 'Retailer'
AND parameter_value = 'Walmart'
THEN 1
ELSE 0
END
) cond3
FROM gc_forecast_parameters
GROUP BY forecast_id) gf
WHERE gc_forecast.forecast_id = gf.forecast_id
AND gf.cond1 = 1
AND gf.cond2 = 1
AND gf.cond3 = 1
Demo
SQL*Plus: Release 10.1.0.4.2 - Production on Ven. Déc. 5 15:34:14 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connecté à :
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
SQL> /* Formatted on 2008/12/05 15:33 (Formatter Plus v4.8.8) */
SQL> WITH gc_forecast_parameters AS
2 (SELECT 100 forecast_id, 'StartDate' parameter_name,
3 '01/01/2009' parameter_value
4 FROM DUAL
5 UNION ALL
6 SELECT 100, 'EndDate', '03/31/2009'
7 FROM DUAL
8 UNION ALL
9 SELECT 100, 'Growth', '% 20'
10 FROM DUAL
11 UNION ALL
12 SELECT 100, 'Retailer', 'Walmart'
13 FROM DUAL
14 UNION ALL
15 SELECT 101, 'StartDate', '04/01/2009'
16 FROM DUAL
17 UNION ALL
18 SELECT 101, 'EndDate', '06/30/2009'
19 FROM DUAL
20 UNION ALL
21 SELECT 101, 'Growth', '% 20'
22 FROM DUAL
23 UNION ALL
24 SELECT 101, 'Retailer', 'Walmart'
25 FROM DUAL),
26 gc_forecast AS
27 (SELECT 100 forecast_id, 'Q12009' forecast_name, 'N' freeze, 'Y' enabled
28 FROM DUAL
29 UNION ALL
30 SELECT 101, 'Q22009', 'N', 'Y'
31 FROM DUAL)
32 SELECT gc_forecast.forecast_id, gc_forecast.forecast_name, gc_forecast.freeze,
33 gc_forecast.enabled
34 FROM gc_forecast,
35 (SELECT forecast_id,
36 MAX (CASE
37 WHEN parameter_name = 'StartDate'
38 AND parameter_value = '01/01/2009'
39 THEN 1
40 ELSE 0
41 END
42 ) cond1,
43 MAX (CASE
44 WHEN parameter_name = 'EndDate'
45 AND parameter_value = '03/31/2009'
46 THEN 1
47 ELSE 0
48 END
49 ) cond2,
50 MAX (CASE
51 WHEN parameter_name = 'Retailer'
52 AND parameter_value = 'Walmart'
53 THEN 1
54 ELSE 0
55 END
56 ) cond3
57 FROM gc_forecast_parameters
58 GROUP BY forecast_id) gf
59 WHERE gc_forecast.forecast_id = gf.forecast_id
60 AND gf.cond1 = 1
61 AND gf.cond2 = 1
62 AND gf.cond3 = 1;
FORECAST_ID FORECA F E
100 Q12009 N Y
SQL> -
Help with select list item and dynamics action
G'Day Apex Gurus,
I having problems trying to achieve to trigger the help window of a select item automatically. A help window is triggered when the select item label is clicked but my client would like to be triguered automatically as soon as the user click to see the options in the select list.
I think that I should be able to do it with dynamic actions but I can not get it to work.
I know when someone click on the label of the select list item trigger this JavaScript
javascript:popupFieldHelp('277938589795252851','1545903379570909')
So I want to trigger the javascript also when the user click of the select list item and pull down the options and for that I think that Dynamic actions is the way to go but I can't get it right.
This is what I a doing:
I created a Dynamic option as follow:
Name : test
Sequence: 30
Even: Click
Selection type: Item(s)
Item(s): P1_RATING <- a selection list item
Condtion: - No Condition -
True Actions
Sequence: 10
Action : Execute JavaScript Code
Fire when event result is :True
Fire on page load: ticked
Code: javascript:popupFieldHelp('277938589795252851','1545903379570909')
I appreciate any one who can tell me what i am doing wrong here or provide a solution to my problem of achieving to trigger the help window of a select item automatically.
Kind regards
CarlosHi Carlos,
I set up a test case in exactly the same way and it worked fine for me. I created a page item called P1_DA_DEMO and added some static select list values then added some help text. The settings I used are below, I suggest you try again but also make sure you have no other Javascript errors on the page. Use a tool like firebug to check.
Name : Dynamic Action Demo
Sequence: 10
Even: Click
Selection type: Item(s)
Item(s): P1_DA_DEMO <- a selection list item
Condtion: - No Condition -
True Actions
Sequence: 10
Action : Execute JavaScript Code
Fire when event result is :True
Fire on page load: Not Ticked
Code: javascript:popupFieldHelp('277938589795252851','1545903379570909')
Event Scope set a s Bind.
Thanks
Paul
Maybe you are looking for
-
hi i am getting following , when i am try to execute second bapi. the first babi working fine. i want execute 2 bapi. at com.sap.tc.webdynpro.modelimpl.dynamicrfc.DynamicRFCModelClassExecutable.execute(DynamicRFCModelClassExecutable.java. all jco are
-
In OpenScript, is there anyway to have an XML post pass if a 500 error is returned?
Hello, We're using OpenScript 9.3.1.0 and are automating some Web Service tests. One of the scenarios is to test when data is sent to the service where no valid session exists, we expect a 500 Interval Server error to be returned. I have created a
-
What's the keyboard shortcut to command to go to specific page number in iPages
I am using Yosemite 10.10.1 Cannot find a short cut for 'go to page number.....' I am writing a book and it is very frustrating having to do find a word instead of a page number. Help
-
Hi , My requirement is to update some field values (like AWART,MEINH and ALLDF etc....) in CATSDB table. is there any function module to update the CATSDB table like we have Function Module HR_INFOTYPE_OPERATION for infotypes. Regards, Soujanya
-
Keychains has lock up computer
keychains ask for password after login. keychain will not acept paswords.