How can i write a Pl/sql Programme for a calender
hi all,
How can i write Pl/sql programme (may be function) for a calendar ,like after the programme is created if call the function at the prompt and give the year 2099 so on, it should display the result with all the 12 months (months and days.)
Please email the answer to
[email protected]
or send the link for the answers.
Thx
Well, you can start off by reviewing the SYSDATE command and the TO_DATE and TO_CHAR functions. Also, review addmonths etc.
http://www.unix.org.ua/orelly/oracle/prog2/ch14_01.htm
Cheers
Similar Messages
-
How can i write the below code using "For all entries"
Hi
How can we write the below code using "for all entries" and need to avoid joins...
Please help
SELECT aaufnr aobjnr aauart atxjcd a~pspel
agstrp awerks carbpl cwerks
INTO TABLE t_caufv
FROM caufv AS a
INNER JOIN afih AS b
ON aaufnr = baufnr
INNER JOIN crhd AS c
ON bgewrk = cobjid
AND c~objty = 'D'
WHERE ( a~pspel = space
OR a~txjcd = space
OR NOT a~objnr IN
( select OBJNR from COBRB AS e
WHERE objnr = a~objnr ) )
AND a~werks IN s_plant
AND a~auart IN s_wtype
AND NOT a~objnr IN
( select OBJNR from JEST AS d
WHERE objnr = a~objnr
AND ( dstat = 'A0081'OR dstat = 'A0018' )
AND d~inact 'X' ).
Reward points for all helpfull answers
Thanks
Ammi.Hi,
SELECT objnr objid aufnr
from afih
into table t_afih.
SELECT objnr
from JEST
into table t_JEST
where stat = 'A0045'
OR stat = 'A0046'
AND inact 'X'.
SELECT objnr
from COBRB
into table t_cobrb.
SELECT arbpl werks objid objty
from crhd
INTO table it_crhd
FOR ALL ENTRIES IN it_afih
WHERE objty eq 'D'
AND gewrk = it_afih-objid.
SELECT aufnr objnr auart txjcd pspel gstrp werks aufnr
FROM caufv
INTO table t_caufv
FOR ALL ENTRIES IN it_afih
WHERE aufnr = it_afih-aufnr
And pspel = ' '
AND txjcd = ' '
ANd objnr ne it_crhd-objnr
AND auart in s_wtype
AND werks in s_plant.
AND objnr ne it_jest-objnr.
dont use NE in the select statements, it may effect performance also. Instead use if statements inside
loops.
loop at t_caufv.
read table it_chrd............
if t_caufv-objnr ne it_chrd-objnr.
read table it_jest..........
if if t_caufv-objnr ne it_jest-objnr.
(proceed further).
endif.
endif.
endloop.
hope this helps.
Reward if useful.
Regards,
Anu -
How can get a database like ****.SQL file for test in sqlplus in oracle8i
How can get a database like ****.SQL file for test in sqlplus in oracle8i,I am a beginner,thanks
I'll give it a guess as to what it is you want but I'm afraid you'll have to give some more information to go on. I appreciate it's difficult for people who are beginners or who don't have English as their first language.
Are you trying to run a SQL file? From SQL*plus you can do either of these:
SQL> start my_file
or
SQL> @my_file
N.B.: if th efile has a .sql extension you don't need to include it, but you do for any other file extension e.g.
SQL> @myfile.run
Here is the page Vijay referred to:
Re: Physical storage Checks & adding disk on server. I hope you find it useful.
You will more helpful links (including links to the Oracle on-line manuals at this page:
Re: How to attach a java bean in forms6i
good luck, APC -
How can I extract the full SQL script for a schema?
Hi,
How can I extract the full SQL script for a schema?
I am looking for some method that needs jus SQL*Plus and preferably doesn’t need any extra tool.
Thank you,
AlanHow can I extract the full SQL script for a schema?What are you looking for? PL/SQL code? DDL for objects?
-
How can i make a pl/sql function for BLOB datatype
hi..anyone here who is very familiar about BLOB datatype. i have a COLUMN_ID, COLUMN_A in a certain TABLE_1. COLUMN_A is blob datatype that contains almost 250,000rows
SQL>select column_A from table_1 where column_id=1234567
column_A
00000001000000010000000606D4E833074B69EC06D4E91F074CO18406D50C58074C031E
how can i make a user-defined function to compute and convert this blob datatype into decimal length value. this hex value are points in the map.. the function must contain
1.get the length of a blob then
2.convert blob to variable hexadecimal characters by parsing it into 8
3.to_number function or other function used to convert haxadecimal characters to decimal numbers
4.phythagorean formula to compute length between two points. this is the formula i think LENGTH =
SQRT(power((coordinate_x-prev_coordinate_x),2)+power((coordinate_y-prev_y),2));
after this when i type this
SQL>select user_function(column_A) from table_1 where column_id=1234567
user_functions(column_A)
--output length will be in decimal value already
the function will goes like this
step1 is to get the blob length
00000001000000010000000606D4E833074B69EC06D4E91F074CO18406D50C58074C031E
step2 is parsing of data by eights
00000001 =>1
00000001 =>1
00000006 =>6 (number of coordinates)
06D4E833 => X1
074B69EC => Y1
06D4E91F => X2
074CO184 => Y2
06D50C58 => X3
074C031E => Y3
step3 to_number function used to convert hex char to decimal
step4 compute by phytagorean (NOTE ! when computing length the third parsed eight will tell how many coordinates are there..the number of coordinates is ranging from 2 up to E..above example shows 6 coordinates so it means
LENGTH1 =
SQRT(power((X2-X1),2)+power((Y2-Y1),2));
LENGTH2=
SQRT(power((X3-X2),2)+power((Y3-Y2),2));
TOTAL LENGTH=LENGTH1 + LENGTH2
thanksits my first time to use that.There's got to be a first tiem for anything. Be brave.
btw if theres more easy suggestion pls feel free..Well of course the easiest solution would be if the calling program passed in the parameters as separate arguments instead of glomming them together in a string that has to be parsed. This sort of kluj really ought not to have survived into C21.
Cheers, APC -
How can we write the code for opening the command prompt and closing the
how can we write the code in java for opening the command prompt and closing the cmd prompt from eclipse (cmd prompt should close when click on the turminate button in eclipse)
rakeshsikha wrote:
how can we write the code for opening the command prompt and closing theBy typing in Eclipse (which you seemingly have)? -
Q: how can i write PL/SQL block to check prerequisite?
Hello...
I designed an application using sql*plus statment for creating database and developer for creating forms, for on-line registration system for universties,
so I need to teach me how can I write pl/sql block to check the prerequisite, taken courses, and complete hours for the students who wants register the courses via Internet.
thanks alot in advance
kindly send the answers a.s.a.pplease repost this in the SQL & PL/SQL forum
thanks - OTN -
How can I write a SQL statement which checks if a table exists?
How can I write a SQL statement which tells me whether a table exists?
execute an sql query: select * from <tablename>
catch the exception n check whether the erroe code
matches the one that occurs for table doesn't exist
that's itHow is your answer any different from the one given in the first reply?
It isn't.
As WorkForFood says DatabaseMetaData has a bunch of methods for getting information about tables but this is more useful when you don't know the names of any of the tables.. it sounds like you do so I would concur SELECT from table is probably the quickest way to go. If it helps the Xopen error should be either S1000 or 42S01 (I think) but I would try and see if there is a specific vendor code for table not found/not exists error and check for that. -
How can I Write a sine wave in an Access-fil​e?
I measure a sine wave in LabView 6i. How can I write the datas automatically to an Acces-file, at the same time?
In my program, I managed it with Execute SQL.vi, I change a number in a SQL statement(String) -> after this I push start and then it writes the statement in the Access-file.
The problem is, it writes only one data per measurement in the file. How can I write all datas in the Access-file and measure the wave at the same time?
Thanks for help!
Attachments:
getwave.vi 49 KBOn the waveform palette, you will find a "to components" vi that you can break out the array of the waveform. You can then, using a for loop write all of the values from the waveform.
Better yet, there are examples in the database toolkit manual on pages 3-13 to 3-15 that deal with reading arrays (and even has a waveform example).
Good luck! -
How can I write into a table cell (row, column are given) in a databae?
How can I write into a table cell (row, column are given) in a database using LabVIEW Database Toolkit? I am using Ms Access. Suppose I have three columns in a table, I write 1st row of 1st column, then 1st row of 3rd column. The problem I am having is after writing the 1st row 1st column, the reference goes to second row and if I write into 3rd column, it goes to 2nd row 3rd column. Any suggestion?
Solved!
Go to Solution.When you do a SQL INSERT command, you create a new row. If you want to change an existing row, you have to use the UPDATE command (i.e. UPDATE tablename SET column = value WHERE some_column=some_value). The some_column could be the unique ID of each row, a date/time, etc.
I have no idea what function to use in the toolkit to execute a SQL command since I don't use the toolkit. I also don't understand why you just don't do a single INSERT. It would be much faster. -
How Can I get Interview Questions and answers for Oracle9i DBA and PL/SQL
How Can I get Interview Questions and answers for Oracle9i DBA and PL/SQL Programmer.
Please check the following link.
http://www.geekinterview.com/
-aijaz -
How can I write cursor which tell me no record exists
Hi Experts,
I want to know how can I write a cursor which told me no record exists before opening and running the loop.
So I want that if no record exist then I dont want to run loop and open the cursor.
Example: cursor c1 is select empno from scott.emp where empno=10
In procedure body, I want to check if there is no record against my cusor then I don't like to open it.
ThanksRizwan Ali Wahla wrote:
I want to know how can I write a cursor which told me no record exists before opening and running the loop.
So I want that if no record exist then I dont want to run loop and open the cursor.Not possible.
Example: cursor c1 is select empno from scott.emp where empno=10Single row? No need for an explicit cursor. No need for a loop. It can be done using an implicit cursor. E.g.
SQL> create or replace function GetEmployee( empID number ) return EMP%RowType is
2 empRow EMP%RowType;
3 begin
4 select
5 e.* into empRow
6 from emp e
7 where e.empno = empID;
8 return( empRow );
9 exception when NO_DATA_FOUND then
10 return( null );
11 end;
12 /
Function created.
SQL>
SQL> declare
2
3 procedure ProcessEmp( empID number ) is
4 empRow EMP%RowType;
5 begin
6 empRow := GetEmployee( empID );
7
8 if empRow.empno is null then
9 dbms_output.put_line( 'Employee '||empID||' does not exist.' );
10 else
11 dbms_output.put_line(
12 'Employee '||empID||' is '||empRow.ename ||
13 ' and employed as '||empRow.job
14 );
15 end if;
16 end;
17
18 begin
19 ProcessEmp( 7900 );
20 ProcessEmp( 7901 );
21 end;
22 /
Employee 7900 is JAMES and employed as CLERK
Employee 7901 does not exist.
PL/SQL procedure successfully completed.
SQL> All SQLs are cursors. Every single SQL passed to Oracle for parsing and execution is a cursor. So it does not make sense to use one SQL cursor for testing the existence of a specific row, and then another to return the row.
That kind of logic is PL/SQL logic and a single SQL cursor need to be used.
PS. Make sure that the SQL projection only includes the columns needed in PL/SQL. If the SQL is a pure exist row? check, then do not return any column and use a literal value as the projected column.
Edited by: Billy Verreynne on Feb 16, 2012 5:55 AM -
How can i write a XML file with oracle data ?
How can i write a XML file using PL/SQL.
Can i do as follows.
1.Open a file using UTL_FILE.FOPEN(LC_DIR_LOC,'abc.xml','W') ;
2.write all the required tag and value using UTL.put_line
that is enough. Is not, please guide me to write.
gkHaving Oracle 9i.
One more doubt. In the speck, some constand values are there, When i write the same into file, How can i write ?.
1. l_str := ' "E27" '
or
2. l_str := ' E27 '
UTL_FILE.PUT_LINE(L_FILE_POI,l_str,TRUE);
1 case : in XML file : "E27"
In 2 case : E27
When we write a XML file through editors , we have to define the constant within quote . is it?
Which one can i use ? Or any other way is there ..
Thanks and Regards
gopi -
How can I enable embedded pl/sql gateway to run on port 80
I have a new 11G install on OEL 4.0, database created. I would like to be
able to access the instance using the pl/sql gateway. Works fine with
port 8080, the default. How to I enable it to run on port 80?
I found this statement in the following docuementation:
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14259/xdb22pro.htm#ADXDB2500
Using HTTP(S) on Nonstandard Ports
By default, HTTP listens on a nonstandard, unprotected port: 8080. To use HTTP(S) on
the standard port, such as 80, your DBA must chown the TNS listener to setuid ROOT
rather than setuid ORACLE, and configure the port number in the Oracle XML DB
configuration file /xdbconfig.xml.I have root priviledges on the box.
I've tried setting the listener file permissions:
chown root:dba /u01/app/oracle/product/11.1.0/db_1/bin/tnslsnr
chmod 6775 /u01/app/oracle/product/11.1.0/db_1/bin/tnslsnr
Also put root in the dba group.
The permissions turn out like this:
-rwsr-sr-x 1 root dba 830854 Jun 17 21:04 /u01/app/oracle/product/11.1.0/db_1/bin/tnslsnr
I stopped the listener, bounced the database, and started the listener again.
But it still shows the process being owned by oracle:
oracle 29682 1 0 21:08 ? 00:00:00 /u01/app/oracle/product/11.1.0/db_1/bin/tnslsnr LISTENER -inherit
Changing the port is easy:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SYS>select dbms_xdb.gethttpport as "HTTP-Port" , dbms_xdb.getftpport as "FTP-Port" from dual;
HTTP-Port FTP-Port
8080 2100
At this point, I can access the apex home page with the following url:
http://hostname:8080/apex/f?p=4550:10:1454849288245548
I can than change it to port 80:
SYS>begin
dbms_xdb.sethttpport('80');
dbms_xdb.setftpport('2100');
end;
2 3 4 5
PL/SQL procedure successfully completed.
SYS>SYS>select dbms_xdb.gethttpport as "HTTP-Port" , dbms_xdb.getftpport as "FTP-Port" from dual;
HTTP-Port FTP-Port
80 2100
When I try to access apex with the following url:
http://rmdcopslnx1.us.oracle.com/apex/f?p=4550:10:1454849288245548
I get the following:
Failed to Connect
Firefox can't establish a connection to the server at hostname.com.
Though the site seems valid, the browser was unable to establish a connection.
* Could the site be temporarily unavailable? Try again later.
* Are you unable to browse other sites? Check the computer's network connection.
* Is your computer or network protected by a firewall or proxy? Incorrect settings
* can interfere with Web browsing.I can set the port. Just can't talk to it.
This is the entry from the listener log:
<msg time='2008-07-03T15:40:09.741-06:00' org_id='oracle' comp_id='tnslsnr'
type='UNKNOWN' level='16' host_id='hostname'
host_addr='xxx.xxx.xxx.xxx'>
<txt>TNS-12546: TNS:permission denied
TNS-12560: TNS:protocol adapter error
TNS-00516: Permission denied
Linux Error: 13: Permission denied
</txt>
</msg>
So this looks like an permissions problem. But where? I posted
this on the apex forum here:
Re: How can I enable embedded pl/sql gateway to run on port 80
They suggested asking here.No, that thread did not provide the information that I need. Some more data:
I have the port set to 8080:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SYS>select dbms_xdb.gethttpport as "HTTP-Port" , dbms_xdb.getftpport as "FTP-Port" from dual;
HTTP-Port FTP-Port
8080 2100
At this point, I can access the apex home page with the following url:
http://hostname:8080/apex/f?p=4550:10:1454849288245548
I can than change it to port 80:
SYS>begin
dbms_xdb.sethttpport('80');
dbms_xdb.setftpport('2100');
end;
2 3 4 5
PL/SQL procedure successfully completed.
SYS>SYS>select dbms_xdb.gethttpport as "HTTP-Port" , dbms_xdb.getftpport as "FTP-Port" from dual;
HTTP-Port FTP-Port
80 2100
When I try to access apex with the following url:
http://rmdcopslnx1.us.oracle.com/apex/f?p=4550:10:1454849288245548
I get the following:
Failed to Connect
Firefox can't establish a connection to the server at hostname.com.
Though the site seems valid, the browser was unable to establish a connection.
* Could the site be temporarily unavailable? Try again later.
* Are you unable to browse other sites? Check the computer's network connection.
* Is your computer or network protected by a firewall or proxy? Incorrect settings can interfere with Web browsing.
I can set the port. Just can't talk to it. -
How can I write a program that compiles without warnings?
I tried the following with the 1.5 beta-compiler (build 28; I think):
class Y {
public static final class Pair<X,Y> {
private X fst;
private Y snd;
public Pair(X fst, Y snd) {this.fst=fst; this.snd=snd;}
public X getFirst() { return fst; }
public Y getSecond() { return snd; }
public String toString() { return "("+fst+","+snd+")"; }
public static void main(String... args) {
Pair[] pairArr = new Pair[10]; // supposed to be an array of Pair<Integer,Integer>
for (int i=0; i<pairArr.length; i++)
pairArr[i] = new Pair<Integer,Integer>(i,i);
for (int i=0; i<pairArr.length; i++) {
Pair<Integer,Integer> p = pairArr; // unchecked warning
System.out.println(p);
Integer first = p.getFirst();
Integer second = p.getSecond();
// ... more stuff ...
It turns out that I get an unchecked warning when I extract an element from the array of pairs. Okay, that's fine. How can I avoid the warning? I had expected that an explicit cast would help.
Pair<Integer,Integer> p = (Pair<Integer,Integer> )pairArr;
With a cast I'm telling the compiler: "I _know_ what I'm doing; please trust me." But the compiler still issues a warning.
How can I write a warning-free program in this case? The only thing I can think of, is not using the parameterized type Pair in its parameterized form. But it's not the idea of Java Generics that I refrain from using parameterized types. What am I missing?It turns out that I get an unchecked warning when I
extract an element from the array of pairs. Okay,
that's fine. How can I avoid the warning? I had
expected that an explicit cast would help.
Pair<Integer,Integer> p = (Pair<Integer,Integer>
)pairArr;
With a cast I'm telling the compiler: "I _know_ what
I'm doing; please trust me." But the compiler still
issues a warning. Yes, but at least you were able to change the warning from "unchecked assignment" to "unchecked cast" which is a little shorter ;-)
Seriously , since arrays of generic types are disallowed, there is probably no way to get rid of these warnings - which makes a strong point for eliminating "unchecked" warnings altogether (see the other thread "selectively suppressing compiler warnings")
Cheerio,
Gernot
Maybe you are looking for
-
Eclipse open project wizard - OUAF SDK 4.1 install
After installing it for the 4th time, I give up. Please help me. (I start over with a saved image in case you wonder.) I follow the install guide word for word: http://www.box.net/shared/z86acgmb57oi9lo8f312 When I finally get Eclipse to come up to o
-
5630 Nokia XpressMusic Problem after Hard Reset in...
Hi Sir, i have had a problem in my phone 5630 my phone was going to be restarting again and again then i apply hard Reset to it by Pressing *, 3 and Green button it has done smoothly but know when i see in my phone menu the INTERNET folder has not "F
-
1 Analog Input using a DAQ card and would like to save the data into an excel file
As you may have realized, I am very new at using Labview 6.1. I have an analog voltage input that I would like to save in an Excel file as a 2D array (time, voltage). I was wondering if anyone knew a very simple way of doing this and could help me ou
-
ClassCastException with PortableRemoteObject.narrow call
I want to call an ejb component located on a different machine and I can not get it to work. So I tried to deploy it under my version of jboss and try to invoke it. I was able to call it but when I added Context.PROVIDER_URL to my properties I get a
-
I backed up my iPhone onto iCloud, and now any new pictures I take don't save in my camera roll. And when I try to open the photo app it turns white and eventually it closes out of the app.