SQL and case structure
Listers: I've used SAS's version of SQL and it allows the coding of conditional logic in the SELECT statement: proc sql; select acct_no, case substr(acct_no,16,1) when '1' then 'one' when '2' then 'two' else 'other' end as desc from star.kills; quit; The same syntax does not work in SQL*Plus for Oracle 8. Can someone point me to the correct syntax? Secondly, any URLs for this kind of information would be most appreciated. Regards, Harry -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Droogendyk, Harry INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
RE: SQL and case structure
Jesse: Can I also use the value of another column rather than a literal like my example coded? e.g. select acct_no, decode(substr(acct_no,16,1),'1',field1 '2',field2 field3 ) as descr from star.kills ; TIA -Original Message- Sent: Monday, October 07, 2002 5:28 PM To: Multiple recipients of list ORACLE-L "CASE" in PL/SQL serves a slightly different function, but DECODE should do the trick. Try: select acct_no, DECODE(substr(acct_no,16,1), '1','one', '2','two', 'other') as DESCR from star.kills; I also changed "desc" to "descr", since "desc" is a reserved word. HTH! GL! :) Rich Jesse System/Database Administrator [EMAIL PROTECTED] Quad/Tech International, Sussex, WI USA > -Original Message- > From: Droogendyk, Harry [mailto:[EMAIL PROTECTED]] > Sent: Monday, October 07, 2002 3:39 PM > To: Multiple recipients of list ORACLE-L > Subject: SQL and case structure > > > Listers: > > I've used SAS's version of SQL and it allows the coding of > conditional logic > in the SELECT statement: > > proc sql; > select acct_no, > case substr(acct_no,16,1) >when '1' then 'one' >when '2' then 'two' >else 'other' > end as desc > from star.kills; > quit; > > The same syntax does not work in SQL*Plus for Oracle 8. Can > someone point > me to the correct syntax? > > Secondly, any URLs for this kind of information would be most > appreciated. > > Regards, > Harry -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Jesse, Rich INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Droogendyk, Harry INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
RE: ORA-472 DBWR terminated
Listers: I've been a subscriber of this Oracle list for three days now. Am I correct in concluding that most of the participants / questions are at the DBA level? If I'm correct, is there an Oracle list more suited to a developer ( been in the business for 20 years, but 2 weeks with Oracle )? TIA -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Droogendyk, Harry INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Oracle list more suited to a developer?
Listers: Sorry for the duplicate posting, the first was with an incorrect subject line. I've been a subscriber of this Oracle list for three days now. Am I correct in concluding that most of the participants / questions are at the DBA level? If I'm correct, is there an Oracle list more suited to a developer ( been in the business for 20 years, but 2 weeks with Oracle )? TIA -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Droogendyk, Harry INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
RE: SQL and case structure
Thanks to everyone who answered this question. The paper noted below is excellent! -Original Message- From: Robson, Peter [mailto:[EMAIL PROTECTED]] Sent: Tuesday, October 08, 2002 10:39 AM To: Multiple recipients of list ORACLE-L Subject:RE: SQL and case structure Doug Burns wrote a very informative paper on Decode, presented at an earlier UK-OUG meeting. Its available from his web site: http://doug.burns.tripod.com/decode.html And the answer to the question posed below is 'yes'. peter edinburgh > -Original Message- > From: Droogendyk, Harry [mailto:[EMAIL PROTECTED]] > Sent: 07 October 2002 23:59 > To: Multiple recipients of list ORACLE-L > Subject: RE: SQL and case structure > > > Jesse: > > Can I also use the value of another column rather than a > literal like my > example coded? > > e.g. > > select acct_no, >decode(substr(acct_no,16,1),'1',field1 >'2',field2 >field3 ) as descr > from star.kills > ; > > > TIA > > > -Original Message- > Sent: Monday, October 07, 2002 5:28 PM > To: Multiple recipients of list ORACLE-L > > > "CASE" in PL/SQL serves a slightly different function, but > DECODE should do > the trick. Try: > > select acct_no, > DECODE(substr(acct_no,16,1), >'1','one', >'2','two', > 'other') as DESCR > from star.kills; > > I also changed "desc" to "descr", since "desc" is a reserved word. > > HTH! GL! :) > > Rich Jesse System/Database Administrator > [EMAIL PROTECTED] Quad/Tech International, > Sussex, WI USA > > > -Original Message- > > From: Droogendyk, Harry [mailto:[EMAIL PROTECTED]] > > Sent: Monday, October 07, 2002 3:39 PM > > To: Multiple recipients of list ORACLE-L > > Subject: SQL and case structure > > > > > > Listers: > > > > I've used SAS's version of SQL and it allows the coding of > > conditional logic > > in the SELECT statement: > > > > proc sql; > > select acct_no, > > case substr(acct_no,16,1) > >when '1' then 'one' > >when '2' then 'two' > >else 'other' > > end as desc > > from star.kills; > > quit; > > > > The same syntax does not work in SQL*Plus for Oracle 8. Can > > someone point > > me to the correct syntax? > > > > Secondly, any URLs for this kind of information would be most > > appreciated. > > > > Regards, > > Harry > -- > Please see the official ORACLE-L FAQ: http://www.orafaq.com > -- > Author: Jesse, Rich > INET: [EMAIL PROTECTED] > > Fat City Network Services-- 858-538-5051 http://www.fatcity.com > San Diego, California-- Mailing list and web hosting services > -
Oracle list for developers ??
Listers: While I certainly appreciate the great range of experience and knowledge by the subscribers on this list, if my rudimentary knowledge is to be trusted, I think 95% of the postings are DBA type stuff. Since I'm interested in developer questions / answers I'm asking, again!!, if an Oracle list exists that is developer oriented rather than DBA oriented. TIA for your answers. -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Droogendyk, Harry INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Thanks - Oracle list for developers ??
Thanks to all who responded helpfully. SY. -Original Message- From: [EMAIL PROTECTED] [mailto:Jared.Still@;radisys.com] Sent: Thursday, October 10, 2002 7:08 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject:Re: Oracle list for developers ?? Importance: High Harry, Check into ODTUG. http://www.odtug.com/web_members/mbrsonly_signup.asp Jared "Droogendyk, Harry" <[EMAIL PROTECTED]> Sent by: [EMAIL PROTECTED] 10/10/2002 03:43 PM Please respond to ORACLE-L To: Multiple recipients of list ORACLE-L <[EMAIL PROTECTED]> cc: Subject:Oracle list for developers ?? Listers: While I certainly appreciate the great range of experience and knowledge by the subscribers on this list, if my rudimentary knowledge is to be trusted, I think 95% of the postings are DBA type stuff. Since I'm interested in developer questions / answers I'm asking, again!!, if an Oracle list exists that is developer oriented rather than DBA oriented. TIA for your answers. -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Droogendyk, Harry INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Droogendyk, Harry INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
RE: internal date value
Thomas: I'm a SAS guy who must pull Oracle data from the back-end DB. SAS stores dates internally as elapsed days since Jan 1, 1960. If I request an Oracle date field, SAS creates a datetime variable, number of seconds since midnight Jan 1, 1960. Rather than use SAS functions to extract the date ( e.g. datepart function ), I'd like to push that back to Oracle if possible and create a simple date field on SAS. I can accomplish the desired effect with: select date_fld - to_date('01Jan1960','ddmon') as sas_date but I was hoping there was an Oracle function to surface the internal value ( appears to be days since Jan 1, 1968 ). Presumably such a function would be more efficient. Thanks for your help. -Original Message- Sent: January 23, 2004 2:50 PM To: Multiple recipients of list ORACLE-L Harry, Can you explain why you need to raw internal value? Just curious. Tom Mercadante Oracle Certified Professional -Original Message- Sent: Friday, January 23, 2004 1:40 PM To: Multiple recipients of list ORACLE-L You gather it wrong :) Oracle stores date in 8 bytes, one for each: year, month, day, hour, min, ... etc. Igor Neyman, OCP DBA [EMAIL PROTECTED] -Original Message- Droogendyk, Harry Sent: Friday, January 23, 2004 12:40 PM To: Multiple recipients of list ORACLE-L Folks: >From what I gather, Oracle stores dates as the number of elapsed days since Jan 1, 1968. When I query a column of type 'DATE', it returns me the default format, dd-mon-yy. I know I can use to_char(date_col,'MMDD') etc... to define many output formats. What can I do to get the raw internal value of the date? i.e. today is 13172. Thanks. -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Droogendyk, Harry INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Igor Neyman INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Mercadante, Thomas F INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Droogendyk, Harry INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
RE: internal date value
Thomas: I'm aware of the to_char function and the various options. However as you alluded to, that lands in SAS as a character literal, e.g. '22/01/2004' requiring me to convert it to internal format before I can use it in SAS. I think I have to use my work around: select date_fld - to_date('01Jan1960','ddmon') as sas_date Thanks for your time and help. -Original Message- Sent: January 23, 2004 3:32 PM To: '[EMAIL PROTECTED]' Cc: Droogendyk, Harry Harry, Look at the to_char function in Oracle. It will convert a date field to *any* format you want. for example: select to_char(date_field,'mm/dd/ hh24miss') will return a date in the format as noted. You have about as many options as you probably need. You can combine as many format and functions as you think you need. to_char translates dates to chars and to_date does the opposite - but both use the same format statements. This should work fine for you. And for you info - Oracle dates are stored internally based on a date going back many centuries - not just to 1968! Good Luck Tom Mercadante Oracle Certified Professional -Original Message- Sent: Friday, January 23, 2004 3:09 PM To: Multiple recipients of list ORACLE-L Thomas: I'm a SAS guy who must pull Oracle data from the back-end DB. SAS stores dates internally as elapsed days since Jan 1, 1960. If I request an Oracle date field, SAS creates a datetime variable, number of seconds since midnight Jan 1, 1960. Rather than use SAS functions to extract the date ( e.g. datepart function ), I'd like to push that back to Oracle if possible and create a simple date field on SAS. I can accomplish the desired effect with: select date_fld - to_date('01Jan1960','ddmon') as sas_date but I was hoping there was an Oracle function to surface the internal value ( appears to be days since Jan 1, 1968 ). Presumably such a function would be more efficient. Thanks for your help. -Original Message- Sent: January 23, 2004 2:50 PM To: Multiple recipients of list ORACLE-L Harry, Can you explain why you need to raw internal value? Just curious. Tom Mercadante Oracle Certified Professional -Original Message- Sent: Friday, January 23, 2004 1:40 PM To: Multiple recipients of list ORACLE-L You gather it wrong :) Oracle stores date in 8 bytes, one for each: year, month, day, hour, min, ... etc. Igor Neyman, OCP DBA [EMAIL PROTECTED] -Original Message- Droogendyk, Harry Sent: Friday, January 23, 2004 12:40 PM To: Multiple recipients of list ORACLE-L Folks: >From what I gather, Oracle stores dates as the number of elapsed days since Jan 1, 1968. When I query a column of type 'DATE', it returns me the default format, dd-mon-yy. I know I can use to_char(date_col,'MMDD') etc... to define many output formats. What can I do to get the raw internal value of the date? i.e. today is 13172. Thanks. -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Droogendyk, Harry INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Igor Neyman INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Mercadante, Thomas F INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for
RE: internal date value
Thanks to all who replied with helpful comments, pointers, links etc... -Original Message- Sent: January 23, 2004 3:24 PM To: Multiple recipients of list ORACLE-L Harry This list is moving to freelists, but I'll assume you knew that. Actually the base value for the standard Oracle dates is Jan 1, 4712 BC. There is a Julian function that will return the number of days since the base. To return the Julian, select to_char(sysdate,'J') from dual; Also, Oracle9i has some new date types and you may find one that works better for your purposes: http://otn.oracle.com/products/oracle9i/daily/may02.html Dennis Williams DBA Lifetouch, Inc. [EMAIL PROTECTED] -Original Message- Sent: Friday, January 23, 2004 11:40 AM To: Multiple recipients of list ORACLE-L Folks: >From what I gather, Oracle stores dates as the number of elapsed days since Jan 1, 1968. When I query a column of type 'DATE', it returns me the default format, dd-mon-yy. I know I can use to_char(date_col,'MMDD') etc... to define many output formats. What can I do to get the raw internal value of the date? i.e. today is 13172. Thanks. -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Droogendyk, Harry INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: DENNIS WILLIAMS INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Droogendyk, Harry INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
internal date value
Folks: >From what I gather, Oracle stores dates as the number of elapsed days since Jan 1, 1968. When I query a column of type 'DATE', it returns me the default format, dd-mon-yy. I know I can use to_char(date_col,'MMDD') etc... to define many output formats. What can I do to get the raw internal value of the date? i.e. today is 13172. Thanks. -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Droogendyk, Harry INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
internal date format
Folks: >From what I gather, Oracle stores dates as the number of elapsed days since Jan 1, 1968. When I query a column of type 'DATE', it returns me the default format, dd-mon-yy. I know I can use to_char(date_col,'MMDD') etc... to define many output formats. What can I do to get the raw internal value of the date? i.e. today is 13172. There is a real kludge I can use: select date_field - to_date('01Jan1968','ddmon') as internal_date from table; Is there something built into Oracle to give me this internal format? Thanks. -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Droogendyk, Harry INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).