Logic Implementation
Hi All,
I have a cube having Doc No, Clearing Doc No, Doc type and amount with some other fields. Suppose my sample data is as given below:
Requirement is that in Bex I have to select sum of amount as:
Capture Claering Doc No in front of Doc No. Lets say for first record for Doc No 110318, Clearing Doc No is 110330.
Now search in Doc No for 110330 for Doc type DH. Sum of this filtered records' amount will be the result of column in Bex.
Now, please suggest how and where (Bex or BI )to achieve this.
Regards,
Iira
Hello Lira,
Infoset can be used to achieve this. The existing data can be loaded in one DSO and the DH document type data can be loaded in another DSO. Join these 2 DSO by joining Clearing Doc of first DSO to Accounting doc of second DSO.
Let me know your feedback
Regards
Gajesh
Similar Messages
-
Can we use WHO columns in Business Logic implementation
Hi,
Can we use WHO columns for business logic implementation..?
From one table I need to pick up the latest record. I have a ActionDate column in the table which stores the date of the action.
But on the same day there can be multiple action records. ie Multiple records have same ActionDate.
Select * from action_table where action_date=(maximum action_date)
The above query will return more than 1 record.
Now can I use the Creation_Date which is a WHO column to identify the latest record..?
Will it introduce any issues if I use creation_date WHO column?
Usage of WHO column in application logic, Is it against the Standards ?
Thanks a lot.I guess you are talking about populating the value using the history column creation_dt from EO.
If so, you can use then. We are using them in all our applications to populate WHO columns of our table.
Infact as far as I know, even Oracle application uses them.
They generally populate the timestamp, so you may need to format them when doing date comparisons.
Hope that helps.
Amit -
UCES Business logic / Implementation question
Hello,
I hope this is the right forum for this, I found nothing relevant about it with the search...
I hope you can help me or perhaps at least point me in the right direction or give me some links.
It's really hard to find anything substantial about UCES on the net, so ANY help is greatly appreciated!!!
Okay here we go:
I have a requirement for a client who wants a Web 2.0 Portal with the Business logic implemented with UCES (Utility Customer E-Services)
What I now (for a start) need to know is:
1.
How is business functionality in UCES implemented? With Java or with ABAP? Does anyone know this? Are both approaches possible?
2.
How does a possible interface between UCES business logic and the frontend look like?
- JSP -> EJB -> Java Connector -> ABAP?
- JSP -> EJB ?
- JSP -> EJB -> ABAP over Web Services ?
- or other ?
Like you see, I'm really just trying to get a grip on the basics, a starting point from which to find further information. So really, anyone who has experience with this, please answer, it's greatly appreciated.
Thanks
RalfHello Ralf,
This seems to be the wrong forum but a quick check and I found
Re: SAP Utilities Customers E-Services (SAP-UCES) - Documentation?
Maybe this can help.
Regards
Mark -
Need help in OBIEE BMM layer logic implementation
Hi All,
I have a requirement in my RPD development.
I have two tables account and site.
Table_Name:*Account*
Column_Name:
AccountID Store_Name Site Data_1_Name Site_Data_2_Name Site_Data_3_Name
264364 Wegmans_ Food_Markets GSF Floor_Type BSC
999999 Walmart Floor_Type BSC
999998 Walgreens BSC Avg_Cust_Count GSF
Table_Name:*Site*
Column_Name:
Site_ID Store_Name Account_ID Account_Name Site_Name Site Data_1_Value Site Data_2_Value Site Data_3_Value
264367 Wegmans_Food_Markets 264364 Wegmans_Food_Markets Alberta_Drive_#82 96114 Vinyl Kellermeyer
264368 Wegmans_Food_Markets 264364 Wegmans_Food_Markets Alberta_Drive_#83 96109 Poly_Vinly ABC
123 Walmart 999999 Walmart Alberta_Drive#1000 Vinly XYZ
1678 Walgreens 999998 Walgreens Calgary_ Drive#9009 ABC 10000 56565
Site Logical/ Presentation Table in OBIEE
Site_ID Store_Name Account_ID Account_Name Site_Name GSF Floor_Type BSC
264367 Wegmans_Food_Markets 264364 Wegmans_Food_Markets Alberta_Drive_#82 96114 Vinyl Kellermeyer
264368 Wegmans_Food_Markets 264364 Wegmans_Food_Markets Alberta_Drive_#83 96109 Poly Vinly ABC
123 Walmart 999999 Walmart Alberta_Drive#1000 Vinly XYZ
1678 Walgreens 999998 Walgreens Calgary_ Drive#9009 56565 ABC
for account table we have the Site Data_1_Name ..Site Data_3_Name columns values which is the column name for the values in Site table(i.e the values in the columns "Site Data_1_Value..Site Data_1_Value") . this values change dynamically based on the column name(Site Data_1_Name ..Site Data_3_Name ) in Account Table . how do i map this column values in RPD level ? or do we have any logic to implement this. PLEASE HELP ME TO SOLVE THIS ...
Thanks in advance ,
Mohan ManoHI mohan the information you provided holding some sensitive data please delete some of them otherwise you might be in trouble.
Make join between the account_ID and the SITE_ID based on the inner join columns which match in both tables will retrieved in the report. If you want to see the null values as well you can use outer join.
Thanks,
chak -
How to get Custom Time Correction business logic implement for ESS in R/3?
Hi Experts,
I am in trouble of implementing the custom requirement of correcting the time in ESS. I have to implement the time corrections as per business logic.
Can any body tell me where to do this?
What I need is suppose employee DWS is from 9:30 AM to 6:00 PM and suppose he forgot to punch the In time and then corects the entry for 9:30 AM in ESS then it get inserted into the R/3 data but now requirement is if support the employee has punched but at 10:00 AM and then corrects to 9:30 AM then it does not change the 10:00 AM and we wanna deleted these 10 AM entry.
Thanks in advance.I have solved by created enhancement spot in PT_COR_REQ
for method IF_EX_PT_COR_REQ~POST_VIA_BLOP
Regards,
Gaurav Patwari -
Table name: nsv_stage
-- Create table
create table nsv_stage
prod_code VARCHAR2(10) not null,
attrib_value VARCHAR2(50) not null
Sample data,
MANHAT_001 10112000000000000000000000000000000000000000000000
MANHAT_001 10112001000000000000000000000000000000000000000000
MANHAT_001 10112002000000000000000000000000000000000000000000
MANHAT_001 10121000000000000000000000000000000000000000000000
MANHAT_001 10121001000000000000000000000000000000000000000000
MANHAT_001 10121002000000000000000000000000000000000000000000
MANHAT_001 10127000000000000000000000000000000000000000000000
MANHAT_001 10128000000000000000000000000000000000000000000000
MANHAT_001 10129000000000000000000000000000000000000000000000
MANHAT_001 10130000000000000000000000000000000000000000000000
MANHAT_002 10112000000000000000000000000000000000000000000000
MANHAT_002 10112001000000000000000000000000000000000000000000
MANHAT_002 10112002000000000000000000000000000000000000000000
MANHAT_002 10121000000000000000000000000000000000000000000000
MANHAT_002 10121001000000000000000000000000000000000000000000
MANHAT_002 10121002000000000000000000000000000000000000000000
MANHAT_002 10127000000000000000000000000000000000000000000000
MANHAT_002 10128000000000000000000000000000000000000000000000
MANHAT_002 10129000000000000000000000000000000000000000000000
MANHAT_002 10130000000000000000000000000000000000000000000000
Here, the column attrib_value contains and each position represent as below
1 - 3 represent attrib1
4 - 5 represent attrib2
6 - 7 represent attrib3
8 - 8 represent attrib4
9 - End represent Other_attribs
Now, I need to write a query to display the illegal pair list (record list), only if more than one <string_1> and the cloumn attrib4 cannot be both 0 and 1 for the same attrib1 to attrib4 and product to the left of it
Here, <string_1> = prod_code||substr(attrib_value,1,3)||substr(attrib_value,4,2)||substr(attrib_value,6,2)||substr(attrib_value,8,1)
in the other way we can say the <string_1> = prod_code||attrib_value1||attrib_value2||attrib_value3||attrib_value4
I dont know how to write/implement this logic, would you please help me ...Sorry to troble you again... In addition to that, I have tried using the analatical qry and its not returning the qry also have tried the other one and its retriving with other records (excluding 0 or only 0 also), then I have tried using the below qry & its not giving any row. Please guide me. Thanks!
SELECT distinct prod_code, attrib_value
FROM nsv_stage
WHERE (substr(attrib_value,8,1) = '0' and substr(attrib_value,8,1) in ('1', '2', '3', '4', '5', '6', '7', '8', '9'))
AND (prod_code, substr(attrib_value,1,7)) in (
SELECT prod_code,
substr(sub,1,3)||
substr(sub,4,2)||
substr(sub,6,2)
FROM (
SELECT prod_code, substr(attrib_value, 1, 7) sub,
max(CASE WHEN substr(attrib_value, 8, 1) = 0 THEN 'YES' ELSE NULL END) flag0,
max(CASE WHEN substr(attrib_value, 8, 1) = 1 THEN 'YES' ELSE NULL END) flag1,
max(CASE WHEN substr(attrib_value, 8, 1) = 2 THEN 'YES' ELSE NULL END) flag2,
max(CASE WHEN substr(attrib_value, 8, 1) = 3 THEN 'YES' ELSE NULL END) flag3,
max(CASE WHEN substr(attrib_value, 8, 1) = 4 THEN 'YES' ELSE NULL END) flag4,
max(CASE WHEN substr(attrib_value, 8, 1) = 5 THEN 'YES' ELSE NULL END) flag5,
max(CASE WHEN substr(attrib_value, 8, 1) = 6 THEN 'YES' ELSE NULL END) flag6,
max(CASE WHEN substr(attrib_value, 8, 1) = 7 THEN 'YES' ELSE NULL END) flag7,
max(CASE WHEN substr(attrib_value, 8, 1) = 8 THEN 'YES' ELSE NULL END) flag8,
max(CASE WHEN substr(attrib_value, 8, 1) = 9 THEN 'YES' ELSE NULL END) flag9
FROM nsv_stage
GROUP BY prod_code, substr(attrib_value, 1, 7))
WHERE flag0 = 'YES'
AND (flag1 = 'YES' OR flag2 = 'YES' OR flag3 = 'YES' OR flag4 = 'YES' OR flag5 = 'YES' OR flag6 = 'YES' OR flag7 = 'YES' OR flag8 = 'YES' OR flag9 = 'YES'))
ORDER BY prod_code, attrib_value;
Here, I need to retrive the records (prod_code, attrib_value), only if substr(attrib_value, 8, 1)= '0' and (substr(attrib_value, 8, 1) = '1' or substr(attrib_value, 8, 1) = '2'
or substr(attrib_value, 8, 1) = '3' or substr(attrib_value, 8, 1) = '4' or substr(attrib_value, 8, 1) = '5' or substr(attrib_value, 8, 1) = '6' or substr(attrib_value, 8, 1) = '7' or substr(attrib_value, 8, 1) = '8' or substr(attrib_value, 8, 1) = '9') for the same cobination of prod_code || substr(attrib_value,1,7). -
Date logic implementation in store proc
Monthly – 5<sup>th</sup> day of each month including on holidays or weekends
Hmm..do you mean excluding holidays and weekends? Otherwise 5th day of month is always having date as 5 :-)
If you meant excluding you can use this logic based on calendartable
SELECT MAX(Date) AS [5thDay]
FROM
SELECT TOP 5 [Date]
FROM CalendarTable
WHERE WeekDay = 1
ORDER BY [Date]
)t
If holiday info is in seperate table then use this
SELECT MAX(Date) AS [5thDay]
FROM
SELECT TOP 5 [Date]
FROM CalendarTable c
WHERE WeekDay = 1
AND NOT EXISTS (
SELECT 1
FROM HolidayTable
WHERE [Date] = c.[Date]
ORDER BY [Date]
)t
if you want this to be returned for every month use this
SELECT [Date] AS [5thDay]
FROM
SELECT ROW_NUMBER() OVER (PARTITION BY DATEDIFF(mm,0,[Date]) ORDER BY [Date]) AS Rn,
[Date]
FROM CalendarTable
AND NOT EXISTS (
SELECT 1
FROM HolidayTable
WHERE [Date] = c.[Date]
WHERE WeekDay = 1
ORDER BY [Date]
)t
WHERE Rn = 5
If you dont have a calendartable already you can use this UDF instead
http://visakhm.blogspot.in/2010/02/generating-calendar-table.html
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Essbase Integration Services Error Logic Implementation
Hi All,
We are using EIS for Member Load activity and populating the outline to Essbase for the cubes.
As part of this process we have the cbs file and bat script and we initiate the bat script for this activity.
Now, i want to see the Failure and Success of the Member Load into some other file and send a message for Success or Failure..
Moreover, i see the word 'synchronously' as part of success in general.
Did anyone implemented this anytime? If so kindly let me know how i need to check for the failures or Success
and will try to implement the same
Any help would be deeply appreciated...
Thanks...This is a known issue in the EIS Version 11.1.1.3 and is fixed in EIS 11.1.2.1
-
Implementation DLL Name (Linking business logic implementation)
Dear Sirs,
The 'User-Defined Object Registration Wizard' requires the "Implementation DLL Name" file.
Would appreciate it very much if someone could kindly advice where I can find relevant information or provide me with how-to generate the DLL file.
Best Regards,
Kunitomo - TokyoHi Kunimoto,
Do you have access to the SDK Help Center now?
It is also available on the SDN for download under:
> SAP Business One > Versions > SAP Business One 2007
> [SAP Business One 2007 SDK Help Center|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/9039f9c0-b9f1-2a10-27bd-b08d4bd9d48c]
Notice that this is not the latest version available at the moment it should be updated soon. From there you all the information required as Niall said under
> Customization Tools > User-Defined Objects (UDOs) > Creating a UDO
Should you have any more specific questions let us know.
Kind Regards,
Friederike Mundt
SAP Business One Forums Team -
NEED INPUT on this logic implementation .
Hi i have a req where in which .
a set of codes should process if the value of a variable is intitial or if it equal to the 1st value thats its populated with else its should give me an error message .
It like this
IF XYZ EQ INITIAL OR FIRST VALUE ITS POPULATED WITH
fuhgaofhf
ELSE
ERROR MEssage .
ENDIF .
Can u please suggest how to do this implementation.Hi,
You can do like this
IF XYZ IS INITIAL OR XYZ EQ FIRST_VAL.
-do something-
ELSE
MESSAGE EXXX(msg_class).
ENDIF.
XXX must be your error number.
Hope this helps.
Regards,
Deepthi. -
AXI4 memory mapped slave user logic implementation
hi, I'm using a Spartan6 and the EDK.
I'm trying to write data via PCIe/AXI to a third party IP core, and read data of this IP core. The connection looks like this:
PCIe/AXI MM bridge <> AXI Interconnect <> AXI_MM_Slave <> two instances of the 3rd_party_IP_core
I want to read/write 128 bits. I created an AXI4 memory mapped slave with two address spaces with the CIP Wizard.
Now I'd like this AXI slave to read the data from the bus, and forward it to an output : std_logic_vector(127 downto 0), and read data of an input : std_logic_vector(127 downto 0) and write this data to the AXI bus.
I don't know how to use the IPIC signals the CIP Wizard created, to do this. As I want to read/write 128 bits while the Bus2IP_data and IP2Bus_data is only 32 bits wide, I don't know how to manage this. Could anyone please help me with some VHDL-code?
Thanks and regards,
FabianAs per my understanding
It may be possible If one person manages all service desk operations and that person have windows user id with userid "SERVICEDESK ".
It is not possible for several users to have same userid in Active directory
Integration of portal with windows userid possible whith same userid.
we can see some other inputs also
Koti Reddy -
Hi All,
Could anyone please help me in providing BARCODE logic/implementation in SAP SCRIPT?Hi Gurmeet,
There is no specific logic invlolved in it.
You just need to create a character format and chose a font fmaily which supports barcodes.
Finally you need to use it in text elements.
like if you want the bar code for a matnr,
do like this:
<bc>&matnr&</bc>.
note that you have defined a character format called bc already.
Regards,
Ravi -
Web Logic Optimize the User-defined typed values
I'm using Together Soft 6.0.1 and Web Logic 7.0 as apps. server. I'm writing
the web service using the user defined type as input parameter and return status.
I'm experience the following probem
1. On the web service, the return status is an array user-defined data type.
Some of the data has the same values.
2. When I looked at the SOAP/XML message as the returned status, the fields/tags
that have the same data got mapped to a href=#ID_x and on the bottom of the SOAP/XML
message the ID_x is mapped to the correct data value.
3. However, when the SOAP/XML message is mapped to the client's object, the data
did not get mapped correctly to the object's attribute. The attributes, that
got mapped to href=#ID_x, are set to empty value.
I wrote the serialize/deserialize code for the User-Defined type, and that works
ok. However, when I return an array of User-Defined type, and only have the serialize/deserialize
code for the User-Defined type but no code for the array, it throws an exception
(Array out of bound).
It looks like Weblogic creates a reference table appended to the message with
duplicate values indexed. Is it some kind of performance option you can turn
off?
Or is there some interface to retrieve the references?
Or is there a work around or a fix to this problem?
Or do I have to write the serialize/deserialize codes for the user-defined type
and array of user-defined type?
Thanks for your help,
MichelleScott,
Thanks for your response.
So you're saying the href "optimization" is a feature of soap encoding. Is it
the Web Logic implementation of soap encoding optimize the values?
If we write xxxCodec.java for the array of user-defined type, will it work?
If it does, could you send me sample code? The example in the document is for
a single class. The array seems to be more complicated.
Thanks for your help,
Michelle
[email protected] (Scott Ziegler) wrote:
I would suggest using a document-literal style webservice. The
literal part avoids soap encoding which is responsible for the href
"optimization".
--Scott
In article <[email protected]>,
Michelle Hoang <[email protected]> wrote:
I'm using Together Soft 6.0.1 and Web Logic 7.0 as apps. server.
I'm writing the web service using the user defined type as input
parameter and return status. I'm experience the following probem
1. On the web service, the return status is an array user-defined
data type. Some of the data has the same values.
2. When I looked at the SOAP/XML message as the returned status, the
fields/tags that have the same data got mapped to a href=#ID_x and on
the bottom of the SOAP/XML message the ID_x is mapped to the correct
data value.
3. However, when the SOAP/XML message is mapped to the client's
object, the data did not get mapped correctly to the object's
attribute. The attributes, that got mapped to href=#ID_x, are set to
empty value.
I wrote the serialize/deserialize code for the User-Defined type, and
that works ok. However, when I return an array of User-Defined type,
and only have the serialize/deserialize code for the User-Defined
type but no code for the array, it throws an exception (Array out of
bound).
It looks like Weblogic creates a reference table appended to the
message with duplicate values indexed. Is it some kind of
performance option you can turn off? Or is there some interface to
retrieve the references? Or is there a work around or a fix to this
problem? Or do I have to write the serialize/deserialize codes for
the user-defined type and array of user-defined type?
Thanks for your help,
Michelle -
Combining multiple records into a single record (View)
Okay so here is my scenerio:
There is a table I have made that details SQL jobs and the various details about them. What i wan't to do is make a view with specific logic implemented. Fields that will be taken across to this view will be: LastRunDate, LastRunTime and Step_Status.
JobName will also be used to define the logic but will not be a column in itself.
What i wan't is an additional column using this logic, called 'DataSet'. For each Dataset there are multiple jobs that are unique to it, so there are multiple records being brought over from the table to view for one particular dataset. For example,
for 'ExampleDataSet' there are three jobs, i wan't it so these jobs are combined and named as 'ExampleDataSet' under a calculated column called 'Dataset'. For the following fields i would like it so that LastRunDate and LastRunTime are the time in whichever
job was last to be intitiated is the date and time set. For Step_Status, there are three possible results, 'Running', 'Failed' or 'Succeeded'. If any of the three jobs are 'Running', then 'Running'. If neither are running yet one has failed then 'Failed'.
Only when all three have succeeded should it then be set to 'Succeeded'.
I hope i have made that clear enough, please feel free to ask any questions if not. I am relatively new to SQL but i thought to at least try least try (I knew it wouldn't work) and it didn't work. But it may give you a better idea of
what i wan't:
CREATE VIEW [dbo].[vw_DataAvailabilityAnalysts] AS
SELECT CASE
WHEN JobName in ('Job1','Job2','Job3') and step_status='Running' THEN 'Running'
WHEN JobName in ('Job1','Job2','Job3') and step_status='Failed' THEN 'Failed'
WHEN JobName in ('Job1','Job2','Job3) and step_status='Succeeded' THEN 'Succeeded'
END as StatusCheck,
CASE WHEN JobName in ('Job1','Job2','Job3') THEN 'ExampleDataSet'
END as DATASET,
LastRunDate,
lastruntime,
step_status,
FROM [CDS_Common].[dbo].[DataAvailability]
Many Thanks,
Plain_Clueless
Plain_CluelessOkay so here is what my table looks like (Simplified). There are four columns and the data within is extracted via a Stored Procedure.
JobName
LastRunDate
LastRunTime
Step_Status
Job1
11/06/2014
09:30:00
Succeeded
Job1
10/06/2014
09:37:20
Succeeded
Job2
11/06/2014
04:05:00
Succeeded
Job1
09/06/2014
02:17:41
Succeeded
As you can see there are 3 jobs which are all 'Job1'. This jobs are obviously different within the table however this represents that they are jobs which all update the same DataSet within our local warehouse. Whereas Job2 updates a different dataset alltogether.
I wan't to create a view which will alagmate the jobs that are of the same DataSet, which will disclude the column JobName but would create a whole new column that looks like this:
DataSet
LastRunDate
LastRunTime
Step_Status
DataSet2
11/06/2014
04:05:00
Succeeded
DataSet1
11/06/2014
09:30:00
Succeeded
Bascically what this shows you is all the Job 1's combined so they are one record, Amaglamated. The last time any of these jobs were run is the LastRunDate & LastRunTime, which was the first record in the first table provided. Again for Step_Status,
there are three possible results, 'Running', 'Failed' or 'Succeeded'. If any of the three jobs are 'Running', then 'Running' (Absolute). If none of the three jobs are running yet one has failed then 'Failed'. If one has failed yet another is also running then
'Running'.Only when all three have succeeded should it then be set to 'Succeeded'. (This last bit isn't as important).
Hope this clears it up a bit,
Plain_Clueless
Plain_Clueless -
On the use of VARCHAR2 vs. CHAR
I'm posting an e-mail thread that has been moving around in my organization, whith guidance from an Oracle representative.
The basic issue concerns the use of CHAR vs. VARCHAR2 when defining a table in Oracle.
I would like to get some comments from the community at large.
1. Business semantics should be represented in every aspect of a database, application, and design as far as I am concerned. Noteably, if the business rule at a corporate entity is clearly stated that when using Oracle the use of CHAR should be limited to those attribute implementations which have the following characteristics; a) The attribute may not be null, b) The attribute must have a character in each of the declared positions.
2. When the Visual Basic application began writing data to the CHAR columns in your application someone should have had a discussion with the developer to find out why this was happening. If the business semantics changed then the logical implemention of the business semantics should have changed as well. That the two were disconnected is not a problem with the CHAR type, it is a problem with the designer or the developer. The bottom line on this instance is that the column should have been defined as a VARCHAR2 data type since the business semantics no longer complied with the criteria set forth in the previous paragraph.
3. I think Oracle trys to load as much of the data from a table or index into shared memory, in this case the database block buffers, as it can in order to facilitate query operations. If Oracle has enough memory and can load a table or index into memory, it will do so. At the same time the database engine will move previously cached data out of memory to accommodate the new requirement.
-----Original Message-----
Thank you for the detail information on CHAR and VARCHAR2. It got me thinking with a DBA hat. I worked as a DBA before and I did use the CHAR type and I will share my experience/thought on CHAR.
I don't like to use the char type like Tom has advised because Oracle does not check to see if the value being inserted fills up the column or not which can lead to a problem. And there is no performance gain or save space in Oracle.
I worked as a DBA before, I used char type on the "must fill/always filled" column (pre DMDC). The application was written in VB with Oracle back end. At some point, VB started inserting values that are short of the column width and created a minor problem (it was supposed to be filled column). The problem was quickly identified and fixed, but it caused an issue.
I realize that I don’t want to define it as a "must fill/always filled" column if you can't enforce it by simply defining the char data type on a table and prevent possible issue in the future.
For a manager, in order to use the char properly, you have to hire client developers with Oracle experience or provide a basic Oracle training in order to avoid the problem I mentioned above in order to use the char type correctly.
I think you, Tom and I are saying the same thing really. Only difference is that Tom and I can not think of a good reason why anyone would like to indicate the business semantics using column type on the database, when it can lead to more work/issues.
In regards to wasted 25 million byes, why would Oracle load the table with 25 million rows? Shouldn't it use an index? Don't you have a serious problem if Oracle is loading table with the 25 million rows?
Just my two cents... : )
-----Original Message-----
May I beg to differ?
CHAR plays a vital role in the intuitive interpretation of a database schema. If designed correctly, the use of CHAR tells anyone who is in the know that this is a must fill column. Thus if a column is defined as CHAR(3) everyone should know that the column will always contain three characters. Defining the column as VARCHAR2(3) does not tell you anything about the data other than that the column may contain 0-3 characters.
Also, If a column is defined as CHAR the column should always be populated. One of the nice features of VARCHAR2 is that if the column is defined at the end of a table, there is no storage overhead until that column is actually populated. Thus if you have a table that has an identifier that is nine characters in length and will always be populated with nine characters, an attribute which describes the type of identifier which is contained in the first column and which must always be populated and is a must fill attribute, and another column which is descriptive and may vary in length or not be populated at time of insert; the following definition does not express the business semantics of the entity:
COL_CD VARCHAR2(9)
COL_TYP_TXT VARCHAR2(26)
COL_TYP_CD VARCHAR2(2)
The above definition also does not take advantage of inherent storage features of Oracle; notably there is a wasted place holder between COL_CD and COL_TYP_TXT and between COL_TYP_TXT and COL_TYP_CD. The next definition does take advantage of the storage features but does not represent the business semantics of the entity:
COL_CD VARCHAR2(9)
COL_TYP_CD VARCHAR2(2)
COL_TYP_TXT VARCHAR2(26)
The above definition does not waste space storing a place holder between COL_TYP_CD and COL_TYP_TXT if the COL_TYP_TXT may be null. The column separator will only be used when the column contains data. The below definition satisfies both the storage and business semantics issues:
COL_CD CHAR(9)
COL_TYP_CD CHAR(2)
COL_TYP_TXT VARCHAR2(26)
This may seem pedantic in nature until you consider the situation where there are 25 million rows in the table represented by the above entity. If each row has a NULL COL_TYP_TXT value then the first example wasted 25 million bytes of storage and 25 million bytes of memory if the full table is loaded into memory. This is an issue which cannot be ignored in high volume databases.
You may wish to know why it is important to define a must fill/always fill column as a CHAR to express the business semantics of an attribute. I can't give a definitive answer to that other than to say that it is just good database manners.
So please, continue to use CHAR when the shoe fits. Don't throw something away that has use just because it is not popular or in the mode.
Also, if I am mistaken in any of the above, please feel free to educate me.
Thanks.
-----Original Message-----
Subject: RE: Oracle on the use of VARCHAR2 vs. CHAR
Ignore if you already got this. This is just FYI.
-----Original Message-----
Below is a detailed answer to your VARCHAR2 or CHAR questions from our Database expert Tom Kyte. The short answer is VARCHAR2 is what you want to use. If you have any questions or want to discuss this in more detail let me know.
A CHAR datatype and VARCHAR2 datatype are stored identically (eg: the word 'WORD' stored in a CHAR(4) and a varchar2(4) consume exactly the same amount of space on disk, both have leading byte counts).
The difference between a CHAR and a VARCHAR is that a CHAR(n) will ALWAYS be N bytes long, it will be blank padded upon insert to ensure this. A varchar2(n) on the other hand will be 1 to N bytes long, it will NOT be blank padded.
Using a CHAR on a varying width field can be a pain due to the search semantics of CHAR.
Consider the following examples:
ops$tkyte@8i> create table t ( x char(10) ); Table created.
ops$tkyte@8i> insert into t values ( 'Hello' );
1 row created.
ops$tkyte@8i> select * from t where x = 'Hello';
X
Hello
ops$tkyte@8i> variable y varchar2(25)
ops$tkyte@8i> exec :y := 'Hello'
PL/SQL procedure successfully completed.
ops$tkyte@8i> select * from t where x = :y; no rows selected
ops$tkyte@8i> select * from t where x = rpad(:y,10);
X
Hello
Notice how when doing the search with a varchar2 variable (almost every tool in the world uses this type), we have to rpad() it to get a hit.
If the field is in fact ALWAYS 10 bytes long, using a CHAR will not hurt -- HOWEVER, it will not help either.
The only time I personally use a CHAR type is for CHAR(1). And that is only because its faster to type char(1) then varchar2(1) -- it offers no advantages.
If you just use varchar2 everywhere, no problem
My advice is, has been, will be very loudly stated as:
IGNORE THE EXISTENCE OF CHAR.
period. If you never use char, you never compare char to varchar2, problem solved.
And if you use char and compare a char(n) to a char(m) they will never compare either.
Just say NO TO CHAR.
**************************************************Hi,
>>A CHAR datatype and VARCHAR2 datatype are stored identically (eg: the word 'WORD' stored in a CHAR(4) and a varchar2(4) consume exactly the same amount of space on disk, both have leading byte counts).
Ok, but on the other hands:
SGMS@ORACLE10> create table x (name char(10), name2 varchar2(10));
Table created.
SGMS@ORACLE10> insert into x values ('hello','hello');
1 row created.
SGMS@ORACLE10> commit;
Commit complete.
SGMS@ORACLE10> select vsize(name),vsize(name2) from x;
VSIZE(NAME) VSIZE(NAME2)
10 5
SGMS@ORACLE10> select dump(name),dump(name2) from x;
DUMP(NAME) DUMP(NAME2)
Typ=96 Len=10: 104,101,108,108,111,32,32,32,32,32 Typ=1 Len=5: 104,101,108,108,111Cheers
Maybe you are looking for
-
How many user accounts on one computer?
I did search but found nothing directly relevant. We have one laptop with one administrator account. How many user accounts besides mine am I allowed? Thanks in advance :o)
-
How can I get the tab key to select text fields only?
Since upgrading to Firefox 4 on Windows, the tab key functions differently. How do I change it so that it only selects text input fields?
-
On what computer configuration is Ultiboard running at its best?
Hi, I will soon upgrade to the latest Multisim Ultiboar Power pro version 10.1 And I wondered if I'd better upgrade my PC as well, it is 4 years old now, and the current Ultiboar version (10.0, full edition) blocks from time to time, even crashes a f
-
Quick question about Subversion
Just wondering, whether after installing an app via subversion and afterwards using the svn up command, would I need to again do ./configure, make, make install? Re-install over the older installation? Or make uninstall and then make install the ne
-
Display and Tower are hot the to touch
Now that Summer is upon us, I've noticed the temperatures of both my monitor and Tower are higher than usual. The actual internal temp of the G5 is 130 F, which I understand is around normal. The display (20" Aluminum Apple Cinema) is physically too