Selecting certain columns in oracle
i have a table with n columns, of which in 2 columns each may have similar values for certain number of rows
i want to find if one of the entries in a column has same value in the next few rows
if so i have to display a message
else i have to display another message
can anybody send the query
Something like below ?
SCOTT@demo102> l
1 select deptno, job
2 from emp
3* order by 1, 2
SCOTT@demo102> /
DEPTNO JOB
10 CLERK
10 MANAGER
10 PRESIDENT
20 ANALYST
20 ANALYST
20 CLERK
20 CLERK
20 MANAGER
30 CLERK
30 MANAGER
30 SALESMAN
30 SALESMAN
30 SALESMAN
30 SALESMAN
14 rows selected.
SCOTT@demo102> ed
Wrote file afiedt.buf
1 select deptno, job, decode(count(*),1,'b','a') Multiple
2 from emp
3 group by deptno, job
4* order by deptno, job
SCOTT@demo102> /
DEPTNO JOB M
10 CLERK b
10 MANAGER b
10 PRESIDENT b
20 ANALYST a
20 CLERK a
20 MANAGER b
30 CLERK b
30 MANAGER b
30 SALESMAN a
9 rows selected.
SCOTT@demo102> Nicolas.
Similar Messages
-
Selecting all columns makes oracle use more indexes than only selectng one?
I have 3 queries here that differ only slightly, conceptually, but the plans are massively different. What I cant work out is that the difference is only in the select list.. The fields referenced in the where clause are properly indexed for this purpose
SELECT
scc.expiry_date
FROM
bw3.int_file_log_details ifld
INNER JOIN
bw3.svc_card_status_change scsc
USING
(institution_number, file_number)
INNER JOIN bw3.svc_client_cards scc
USING
(card_number)
WHERE
institution_number = '00000001' AND
file_number = '00002504'This one above does a full table scan of SCC, over 3.5 million records
SELECT
card_number
FROM
bw3.int_file_log_details ifld
INNER JOIN
bw3.svc_card_status_change scsc
USING
(institution_number, file_number)
INNER JOIN bw3.svc_client_cards scc
USING
(card_number)
WHERE
institution_number = '00000001' AND
file_number = '00002504'This one above does an index fast full scan of SCC's pk (which is cardnumber), as does doing a "SELECT null as dummy FROM..."
SELECT
FROM
bw3.int_file_log_details ifld
INNER JOIN
bw3.svc_card_status_change scsc
USING
(institution_number, file_number)
INNER JOIN bw3.svc_client_cards scc
USING
(card_number)
WHERE
institution_number = '00000001' AND
file_number = '00002504'This one above does the index range scan of the columns mentioned in the where clause and two index unique scans to link in IFLD and SCC (because they are joined on their PKs)
I would expect all queries to run this way and completes in ~0.01 seconds
Now, I get that oracle will sometimes use only an index instead of a table access when the requested data can be got from the index, but the actual query is pulling data from some columns not in indexes, so must be accessed in the table:
SELECT
scsc.card_prod_data as "Field1",
substr(card_number,1,4)||' '||
substr(card_number,5,4)||' '||
substr(card_number,9,4)||' '||
substr(card_number,13,4)||' '||
substr(card_number,17) as "Field2",
' ' as "Field3",
scc.emboss_line_1 as "Field4",
scc.emboss_line_2 as "Field5",
TO_CHAR(TO_DATE(scc.last_issued_date, 'YYYYMMDD'), 'MM/YY ')||
TO_CHAR(TO_DATE(scc.expiry_date, 'YYYYMMDD'), 'MM/YY ')||
' ' as "Field6",
'B'||
card_number||
'^'||
RPAD('0', 27, ' ')||
'^'||
to_char(to_date(scc.expiry_date, 'YYYYMMDD'), 'YYMM')||
service_category_code||
'000000000000' as "Field7",
card_number||
'='||
to_char(to_date(scc.expiry_date, 'YYYYMMDD'), 'YYMM')||
service_category_code||
'000000000000' as "Field8",
card_number as "Field9",
scsc.cvv_cvc2 as "Field10"
FROM
bw3.int_file_log_details ifld
INNER JOIN
bw3.svc_card_status_change scsc
USING
(institution_number, file_number)
INNER JOIN bw3.svc_client_cards scc
USING
(card_number)
WHERE
institution_number = '00000001' AND
file_number = '00002504'This query above, which uses some data from all tables, does a table full scan of SCC, yet if I SELECT * FROM.. I get the expected index usage and table access by index rowid for all tables..
Why is oracle doing an FTS when I choose only some columns, yet doing index access when I select * ?
Edited by: charred on Oct 5, 2010 11:37 AMSelectivity of indexes?
For a query linking these tables:
int_file_log_details <-> svc_card_status_change <-> svc_client_cards
I'm expecting Oracle to:
Use an index range scan of the index on svc_card_status_change that is a nonunique index of institution_number and file number. Selectivity of this index is:
1 institution number in the entire table
59 distinct file numbers in the entire table
4.1million records in the entire table
From there, with the records it found, to use index unique scan of the PKs of int_file_log_details (file_number: 1 record required) and PK of svc_client_cards (card_number: poetntially thousands of records required)
I can understand if oracle might decide it can get 69k records out of 4.1 million faster by FTS the cards table rather than having the indirection of the index... what I cannot understand is:
If I select all the data from the query (SELECT *) it does unique index scans for the 2 records
If I select say, only one non-indexed non-joined column from each table, oracle prefers a FTS of the cards table..
Is oracle not realising that there are only 2 records I need out of cards? Why would select * differ? Is it that oracle thinks "select * is a large amount of data, so it'll be faster to use the index and target certain rows" vs "select one_column can be garnered more quickly by scanning the table and generating a lower overall memory load" ? -
Issue while selecting XMLType column in Oracle 10G
HI All.
We are trying to get some value from XML Type column and it works fine with Oracle 11g, we are trying the same with Oracle 10g but it fails with below stack Trace . looking at the stack Trace we feel it is the issue with ODP.net ,
we have below oracle Versions installed in our Server .
Oracle Data Access Components --- 10.2.0.2.21
Oracle Database 10g Release 2 Patch Set 3 --- 10.2.0.4.0
Kindly let us know if it is specific to any ODP.net issue, or anyone has some sought of work around to resolve this issue .
-----------Stack Trace --------------------------------------------------------
Message: Exception has been thrown by the target of an invocation.
StackTrace: at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Web.Services.Protocols.LogicalMethodInfo.Invoke(Object target, Object[] values)
at System.Web.Services.Protocols.WebServiceHandler.Invoke()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
at System.Web.Services.Protocols.SyncSessionlessHandler.ProcessRequest(HttpContext context)
at System.Web.Script.Services.ScriptHandlerFactory.HandlerWrapper.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(Exception error)
at System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
at System.Web.HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
at System.Web.Hosting.ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
InnerException: System.AccessViolationException
Message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
StackTrace: at Oracle.DataAccess.Types.OpsXmlStream.GetValueBuffer(IntPtr opsConCtx, IntPtr opsErrCtx, IntPtr opsXmlTypeCtx, IntPtr& opsXmlStreamValueBuffer, Int32& numCharsInBuffer)
at Oracle.DataAccess.Client.OracleDataReader.GetString(Int32 i)
at Oracle.DataAccess.Client.OracleDataReader.GetValue(Int32 i)
at Oracle.DataAccess.Client.OracleCommand.ExecuteScalar()
at ProVation.DataAccess.CProvDatabase.GetScalar(SQLText& sql, Object& returnval, String& user)
at ProVation.DataAccess.CProvDatabase.GetScalar(SQLText& sql, String& returnval, String defaultvalue, String& user)
at ProVation.BusinessRules.ConfigsBR.GetDocumentXML(String specialty, Boolean isProvationXML, Boolean isEdit)
at ProVation.BusinessRules.ConfigsBR.GetTreeXML(String terminal, String site, String speciality, DataSet& ds, DataSet& dsXML)
at WKOSAWS.GetTreeXML(String terminal, String key, String strSpeciality, String strSite, DataSet& dsSpeciality) in c:\inetpub\wwwroot\WKOSAWS\App_Code\WKOSAWS.cs:line 207
Thanks in Advance
SurenThanks Alex .
We will try to Install ODP.NET 11.2 Release 5 and proceed further .
Thanks,
Suren -
How to select few columns based on certain conditions
i have a table with n columns, of which in 2 columns each may have similar values for certain number of rows
i want to find if one of the entries in a column has same value in the next few rows
For example the two columns are
supplier_name supplier_code
hll 013
hll 013
hll 013
hll 013
if i first encounter hll with 013 i have to check whether hll with 013 record is further available
if it is so i have to display the columns for which multiple entries is available
can anyone send the queryDuplicate thread?
selecting certain columns in oracle -
Shading certain columns depending on start day of week.
Good Afternoon,
I have reason to edit the calendar wizard to make it completely automated. And before anyone says that this isn't used anymore, we've received 2 separate calendar files over the last made from our Finance departments, each making them with Word calendar
wizard highlighting year end dates. So believe me, the calendar wizard is still very much in use!
Last September, I finally figured out how to automate the first day of the week, though. I have 2 templates now, one for Monday as first day and one for Sunday being the first day of the week.
The only thing missing is to automate the shading so that the columns for Saturday and Sunday are shaded with light grey, and since it's automation we're talking about, only those cells in the columns with a number in them.
I know it's do-able, I'm just not a vb expert, only being able to handle editing simple macros.
But I understand that since I had some help with the macros and they might have changed from the original to some degree, that I should post the code. Is this correct? I hope that it is.
' WORD 97 WIZARD
' Calendar Wizard Specific Code
Option Explicit
' CONSTANT DECLARATIONS
'=============================== LOCALIZATION BLOCK ===============================
' Localization Note: iWeekStartDay is the starting day of the week (Sun = 0, Mon = 1, ...Sat = 6)
Public Const iWeekStartDay As Integer = 1
' Banter strings
Public Const strWarnYearReq As String = "Both starting and ending years are required."
Public Const strWarnMinExceeded As String = "The year can not be before 1900."
Public Const strWarnMaxExceeded As String = "The year can not be after 4095."
Public Const strWarnRangeExceeded As String = "The calendar is limited to 120 months (10 years)."
Public Const strAppCaptionPart1 As String = "Calendar: "
Public Const strAppCaptionPart1b As String = ""
Public Const strAppCaptionPart2 As String = ", "
Public Const strAppCaptionPart3 As String = " to "
Public Const strAppCaptionPart4 As String = ", "
' Status messages
Public Const strStatusIntro As String = "Creating Calendar..."
Public Const strStatusPart1 As String = "Creating "
Public Const strStatusPart2 As String = ", "
Public Const strStatusPart3 As String = "..."
' Assistant
Public Const strCallBackHeading As String = "Do more with the calendar?"
'Margins for A4 size (if wizard changes pagesize to A4)
Public Const sA4_SHORT_MARGIN As Single = 28.8
Public Const sA4_LONG_MARGIN As Single = 57.6
'Margins for Letter size (if wizard changes pagesize to Letter) in pts
Public Const sLETTER_SHORT_MARGIN As Single = 36
Public Const sLETTER_LONG_MARGIN As Single = 36
'========== END LOCALIZATION BLOCK - DO NOT MAKE CHANGES BELOW THIS LINE ==========
Public Const iYearMin As Integer = 1900
Public Const iYearMax As Integer = 4095
' Bookmark Names - DO NOT LOCALIZE
' Note: No spaces allowed in bookmark names
Public Const strBkMkMonth As String = "Month"
Public Const strBkMkDays As String = "Days"
Public Const strBkMkDayNames As String = "DayNames"
Public Const strBkMkYear As String = "Year"
' Calendar Style Names and Constants
Public Const wzBOXES As Integer = 0
Public Const wzBANNER As Integer = 1
Public Const wzJAZZY As Integer = 2
' Form Control
Public Const wzPAGE_START As Integer = 0
Public Const wzPAGE_STYLE As Integer = 1
Public Const wzPAGE_DIRECTION As Integer = 2
Public Const wzPAGE_MONTHS As Integer = 3
Public Const wzPAGE_FINISH As Integer = 4
'orientation
Public Const iORTN_PORTRAIT As Integer = 0
Public Const iORTN_LANDSCAPE As Integer = 1
' Assistant
Public Const iMAX_PANEL As Integer = 4 ' Number of last panel in MultiPage (First=0)
Public Const iCALL_BACK_COUNT As Integer = 3 ' Number of items in CallBackBalloon (First=1)
'postwizard balloon document variable
Public Const strPOST_WIZ_BLN As String = "Calendar post wizard balloon"
' VARIABLE DECLARATIONS
' General
Public rgstrMonthName(11) As String
Public rgstrDayName(6) As String
Public rgiDaysInMonth(11) As String
Public fDateError As Boolean
Public fCheckValidity As Boolean 'if set then the dates are checked for validity
'variables used in doc. creation
Public str1_TO_28 As String
Public rgsDaysHeight(2, 1, 1) As Single
Public rgsMonthNamesHeight(2, 1, 1) As Single
Public rgstrDaysStyle(2) As String
Public rgstrMonthNamesStyle(2) As String
Public strSTY_BANNER_HDG3 As String
' Assistant
Public rgstrAssistantMsg(iMAX_PANEL + 1) As String
Public rgstrCallBackMsg(iCALL_BACK_COUNT) As String
Public rgstrCallBackTip(iCALL_BACK_COUNT) As String
' Page 1
Public iCalendarStyle As Integer
Public iSavedStyle As Integer
' Page 2
' Page 3
' Page 4
Public Sub InitWizardName(fDummy As Boolean)
strWizName = "Calendar Wizard"
strWizLongName = strWizName
strWizShortName = "Calendar"
End Sub
Public Sub InitWizardStrings(fDummy As Boolean)
Dim i As Integer
On Error GoTo FatalError
'=============================== LOCALIZATION BLOCK ===============================
' Note: this list is indexed 0 - iMAX_PANEL
rgstrAssistantMsg(0) = "The Calendar Wizard helps you create a monthly calendar that you can customize with pictures and events. If you want to track and be reminded of events, you should probably use Microsoft Outlook, Microsoft Schedule+, or Microsoft Exchange."
rgstrAssistantMsg(1) = "Select the look you want for your calendar. The Jazzy style uses the Algerian font. If it is not installed on your system, copy alger.ttf from the Valupack folder on the Microsoft Office CD to your hard drive."
rgstrAssistantMsg(2) = "If you leave room for a picture, Word will insert a placeholder picture that you can replace with any picture you want."
rgstrAssistantMsg(3) = "Your calendar can start on any month, and you can make your calendar shorter than or longer than 12 months. Each month will appear on a different page."
rgstrAssistantMsg(4) = "To change any settings, click Back."
' Note: change constant iCALL_BACK_COUNT if number of items in list changes
rgstrCallBackMsg(0) = "Add, remove, or replace a picture"
rgstrCallBackMsg(1) = "Enter information into the calendar"
rgstrCallBackMsg(2) = "Get Help on Something Else..."
rgstrCallBackTip(0) = "To remove a picture, click on it and then press Delete. To add a picture, click where you want to insert the picture, point to Picture on the Insert menu, and then click From File."
rgstrCallBackTip(1) = "To enter information, click where you want to insert the text and start typing. To move between different dates in the calendar, press Tab to move forward or press Shift+Tab to move to the previous date."
'Load Month Name array
rgstrMonthName(0) = "January"
rgstrMonthName(1) = "February"
rgstrMonthName(2) = "March"
rgstrMonthName(3) = "April"
rgstrMonthName(4) = "May"
rgstrMonthName(5) = "June"
rgstrMonthName(6) = "July"
rgstrMonthName(7) = "August"
rgstrMonthName(8) = "September"
rgstrMonthName(9) = "October"
rgstrMonthName(10) = "November"
rgstrMonthName(11) = "December"
'Load Day Name array LOCALIZATION NOTE: DO NOT CHANGE THE ORDER IN WHICH THESE APPEAR!
' TO CHANGE THE WEEK START DAY, CHANGE THE CONSTANT iWeekStartDay
rgstrDayName(0) = "Sun"
rgstrDayName(1) = "Mon"
rgstrDayName(2) = "Tue"
rgstrDayName(3) = "Wed"
rgstrDayName(4) = "Thu"
rgstrDayName(5) = "Fri"
rgstrDayName(6) = "Sat"
'Load Days In Month array
rgiDaysInMonth(0) = 31
rgiDaysInMonth(1) = 28 'Will not be used - must be calculated for leap year accuracy
rgiDaysInMonth(2) = 31
rgiDaysInMonth(3) = 30
rgiDaysInMonth(4) = 31
rgiDaysInMonth(5) = 30
rgiDaysInMonth(6) = 31
rgiDaysInMonth(7) = 31
rgiDaysInMonth(8) = 30
rgiDaysInMonth(9) = 31
rgiDaysInMonth(10) = 30
rgiDaysInMonth(11) = 31
rgstrDaysStyle(wzBOXES) = "Boxes"
rgstrDaysStyle(wzBANNER) = "Banner"
rgstrDaysStyle(wzJAZZY) = "Jazzy"
rgstrMonthNamesStyle(wzBOXES) = "Boxes Heading2"
rgstrMonthNamesStyle(wzBANNER) = "Banner Heading2"
'we dont set the style for month names in Jazzy style
'the Banner style landscape calendar with picture uses Banner Heading3 style for month names
strSTY_BANNER_HDG3 = "Banner Heading3"
rgsMonthNamesHeight(wzBOXES, iORTN_PORTRAIT, 0) = 55
rgsMonthNamesHeight(wzBOXES, iORTN_PORTRAIT, 1) = 55
rgsMonthNamesHeight(wzBOXES, iORTN_LANDSCAPE, 0) = 36
rgsMonthNamesHeight(wzBOXES, iORTN_LANDSCAPE, 1) = 36
rgsDaysHeight(wzBOXES, iORTN_PORTRAIT, 0) = 56
rgsDaysHeight(wzBOXES, iORTN_PORTRAIT, 1) = 102
rgsDaysHeight(wzBOXES, iORTN_LANDSCAPE, 0) = 72
rgsDaysHeight(wzBOXES, iORTN_LANDSCAPE, 1) = 71
rgsMonthNamesHeight(wzBANNER, iORTN_PORTRAIT, 0) = 60
rgsMonthNamesHeight(wzBANNER, iORTN_PORTRAIT, 1) = 60
rgsMonthNamesHeight(wzBANNER, iORTN_LANDSCAPE, 0) = 55
rgsMonthNamesHeight(wzBANNER, iORTN_LANDSCAPE, 1) = 51
rgsDaysHeight(wzBANNER, iORTN_PORTRAIT, 0) = 64
rgsDaysHeight(wzBANNER, iORTN_PORTRAIT, 1) = 110
rgsDaysHeight(wzBANNER, iORTN_LANDSCAPE, 0) = 81
rgsDaysHeight(wzBANNER, iORTN_LANDSCAPE, 1) = 81
rgsMonthNamesHeight(wzJAZZY, iORTN_PORTRAIT, 0) = 73
rgsMonthNamesHeight(wzJAZZY, iORTN_PORTRAIT, 1) = 73
rgsMonthNamesHeight(wzJAZZY, iORTN_LANDSCAPE, 0) = 62
rgsMonthNamesHeight(wzJAZZY, iORTN_LANDSCAPE, 1) = 59
rgsDaysHeight(wzJAZZY, iORTN_PORTRAIT, 0) = 40.5
rgsDaysHeight(wzJAZZY, iORTN_PORTRAIT, 1) = 81.8
rgsDaysHeight(wzJAZZY, iORTN_LANDSCAPE, 0) = 58.2
rgsDaysHeight(wzJAZZY, iORTN_LANDSCAPE, 1) = 57.5
str1_TO_28 = ""
For i = 1 To 28
str1_TO_28 = str1_TO_28 & CStr(i) & vbTab
Next i
'strip off last tab
str1_TO_28 = Left$(str1_TO_28, Len(str1_TO_28) - 1)
' Location in registry DO NOT LOCALIZE
strRegSettingsKey = strREG_SETTINGS_BASE_KEY & "Calendar Wizard"
Exit Sub
FatalError:
ReportError Err
End Sub ' InitWizardStrings
Public Sub InitWizard(fDummy As Boolean)
' Global Vars
fWizardCallBack = False
fDateError = False
iCurrentPanel = 0
' Initialize strings
InitWizardStrings (True)
' Create a new instance of the form
Set formWizard = New formWizDlg
If formWizard Is Nothing Then GoTo FatalError
formWizard.lblWizName1.Caption = " " & strWizLongName & " "
Exit Sub
FatalError:
DisplayErrorMsg strERR_INIT_FORM
ReportError Err
End Sub
' fDummy prevents sub from appearing in Word Tools/Macro list
Public Sub SaveDialogValues(fDummy As Boolean)
On Error GoTo FatalError
' Display status
Application.ScreenUpdating = False
System.Cursor = wdCursorWait
StatusBar = strSAVE_SETTINGS
' Assistant
System.PrivateProfileString("", strREG_SETTINGS_BASE_KEY, strREG_ASSISTANT_TIME_STAMP) = Format$(Now, "General Date")
StoreValPref strREG_ASSISTANT_HELP, iLocalState
' Page 1
StoreValPref "iCalendarStyle", iCalendarStyle
' Page 2
StoreValPref "optPortrait", formWizard.optPortrait.Value
StoreValPref "optPictureYes", formWizard.optPictureYes.Value
' Page 3
StatusBar = ""
System.Cursor = wdCursorNormal
fSettingsSaved = True
Application.ScreenUpdating = True
Exit Sub
FatalError:
ReportError Err
End Sub
Public Sub RestoreDialogValues(fDummy As Boolean)
Dim i As Integer
On Error GoTo FatalError
' Display status
Application.ScreenUpdating = False
StatusBar = strRST_SETTINGS
System.Cursor = wdCursorWait
' Page 1
iCalendarStyle = IRestorePref("iCalendarStyle", 0)
Select Case iCalendarStyle
Case wzBOXES
formWizard.optBoxes.Value = True
formWizard.shpShadowBoxes.Visible = True
Case wzBANNER
formWizard.optBanner.Value = True
formWizard.shpShadowBanner.Visible = True
Case wzJAZZY
formWizard.optJazzy.Value = True
formWizard.shpShadowJazzy.Visible = True
Case Else
iCalendarStyle = wzBOXES
formWizard.optBoxes.Value = True
formWizard.shpShadowBoxes.Visible = True
End Select
' Page 2
If FRestorePref("optPortrait", False) Then
formWizard.optPortrait.Value = True
formWizard.shpPortraitShadow.Visible = True
formWizard.shpLandscapeShadow.Visible = False
Else
formWizard.optLandscape.Value = True
formWizard.shpPortraitShadow.Visible = False
formWizard.shpLandscapeShadow.Visible = True
End If
formWizard.optPictureYes.Value = FRestorePref("optPictureYes", False)
' Page 3
formWizard.cboMonthStart.ListIndex = Month(Date) - 1
formWizard.cboMonthEnd.ListIndex = Month(Date) - 1
formWizard.txtYearStart = Year(Date)
formWizard.txtYearEnd = Year(Date)
fCheckValidity = False
StatusBar = ""
System.Cursor = wdCursorNormal
fSettingsRestored = True
Application.ScreenUpdating = True
Exit Sub
FatalError:
ReportError Err
Exit Sub
End Sub ' RestoreDialogValues
' fDummy prevents sub from appearing in Word Tools/Macro list
Public Sub CreateNewDoc(fDummy As Boolean)
Dim iMonthCurr As Integer
Dim iYearCurr As Integer
Dim lYearMonthCurr As Long
Dim lYearMonthEnd As Long
Dim iDaysCnt As Integer
Dim iDaysInMonth As Integer
Dim iCnt As Integer
Dim strAutoTextName As String
Dim objTableDays As Table
Dim iRow As Integer
Dim iCol As Integer
Dim ocboMonthStart As ComboBox
Dim ocboMonthEnd As ComboBox
Dim otxtYearStart As TextBox
Dim otxtYearEnd As TextBox
Dim strJazzyDayNames As String
Dim objFps As PageSetup
Dim objRng As Range
Dim sShortMargin As Single
Dim sLongMargin As Single
Dim strCaptionTxt As String
Dim iOrientation As Integer
Dim iNoPicture As Integer
Dim i As Integer
Dim strDays As String
On Error GoTo CreateNewDoc_Error
System.Cursor = wdCursorWait
Set ocboMonthStart = formWizard.cboMonthStart
Set ocboMonthEnd = formWizard.cboMonthEnd
Set otxtYearStart = formWizard.txtYearStart
Set otxtYearEnd = formWizard.txtYearEnd
With Application
.ScreenUpdating = False
.StatusBar = strStatusIntro
End With
Set objActiveRange = ActiveDocument.Content
objActiveRange.Collapse wdCollapseEnd
If (formWizard.optPortrait) Then
iOrientation = iORTN_PORTRAIT
Else
iOrientation = iORTN_LANDSCAPE
End If
iNoPicture = Abs(formWizard.optPictureNo.Value)
'the margins have to be changed if papersize was changed in Common
If (fChangeToA4 Or fChangeToLetter) Then
Set objFps = ActiveDocument.PageSetup
If iOrientation = iORTN_LANDSCAPE Then
objFps.Orientation = wdOrientLandscape 'setting paper size in common
'resets orientation to Portrait
If fChangeToA4 Then
sShortMargin = sA4_SHORT_MARGIN
sLongMargin = sA4_LONG_MARGIN
Else
sShortMargin = sLETTER_SHORT_MARGIN
sLongMargin = sLETTER_LONG_MARGIN
End If
Else
If fChangeToA4 Then
sShortMargin = sA4_LONG_MARGIN
sLongMargin = sA4_SHORT_MARGIN
Else
sShortMargin = sLETTER_LONG_MARGIN
sLongMargin = sLETTER_SHORT_MARGIN
End If
End If
With objFps
.TopMargin = sShortMargin
.BottomMargin = sShortMargin
.LeftMargin = sLongMargin
.RightMargin = sLongMargin
End With
End If
strAutoTextName = StrBuildAutoTextName(True)
objWizTemplate.AutoTextEntries(strAutoTextName).Insert objActiveRange, True
If iCalendarStyle <> wzJAZZY Then
Set objActiveRange = ActiveDocument.Bookmarks(strBkMkDays).Range
Else
Set objActiveRange = ActiveDocument.Bookmarks(strBkMkDayNames).Range
End If
strJazzyDayNames = ""
For iCnt = iWeekStartDay To 6
strJazzyDayNames = strJazzyDayNames & rgstrDayName(iCnt) & vbTab
Next
For iCnt = 0 To (iWeekStartDay - 1)
strJazzyDayNames = strJazzyDayNames & rgstrDayName(iCnt) & vbTab
Next
'Strip trailing Tab
strJazzyDayNames = Left$(strJazzyDayNames, Len(strJazzyDayNames) - 1)
objActiveRange.Text = strJazzyDayNames
If iCalendarStyle <> wzJAZZY Then
If (iCalendarStyle = wzBANNER) And (iOrientation = iORTN_LANDSCAPE) And (iNoPicture = 0) Then
objActiveRange.Style = strSTY_BANNER_HDG3
Else
objActiveRange.Style = rgstrMonthNamesStyle(iCalendarStyle)
End If
objActiveRange.Select
Selection.ConvertToTable wdSeparateByTabs, 1, 7
End If
Set objActiveRange = ActiveDocument.Content
objActiveRange.Copy
iMonthCurr = CInt(ocboMonthStart.ListIndex) + 1
iYearCurr = CInt(otxtYearStart.Text)
lYearMonthCurr = (CLng(iYearCurr) * 100) + CLng(iMonthCurr)
lYearMonthEnd = (CLng(otxtYearEnd.Text) * 100) + (CLng(ocboMonthEnd.ListIndex) + 1)
'Create each month of the calendar
Do Until lYearMonthCurr > lYearMonthEnd
Application.StatusBar = strStatusPart1 & rgstrMonthName(iMonthCurr - 1) & strStatusPart2 & CStr(iYearCurr) & strStatusPart3
'Set month
If iCalendarStyle = wzJAZZY Then
ActiveDocument.Bookmarks(strBkMkMonth).Range.Text = CStr(iMonthCurr)
Else
ActiveDocument.Bookmarks(strBkMkMonth).Range.Text = rgstrMonthName(iMonthCurr - 1)
End If
'Set year
ActiveDocument.Bookmarks(strBkMkYear).Range.Text = CStr(iYearCurr)
'Determine number of days in month
If iMonthCurr = 2 Then
iDaysInMonth = DateSerial(iYearCurr, 3, 1) - DateSerial(iYearCurr, 2, 1)
Else
iDaysInMonth = rgiDaysInMonth(iMonthCurr - 1)
End If
'Set Column of First Day Of Month by using Weekday function. The 8th
'is used (to start with) instead of the 1st to allow for offsetting (via
'iWeekStartDay) for localization since the 8th will always fall on the
'same day (of the week) as the 1st.
iCol = WeekDay(DateSerial(iYearCurr, iMonthCurr, 8 - iWeekStartDay))
ActiveDocument.Bookmarks(strBkMkDays).Select
If iCalendarStyle <> wzJAZZY Then _
Selection.MoveDown wdLine 'the bookmark is now in the first cell of the table
strDays = ""
For i = 1 To iCol - 1
strDays = strDays & vbTab
Next i
strDays = strDays & str1_TO_28
For i = 29 To iDaysInMonth
strDays = strDays & vbTab & CStr(i)
Next i
'to get a 6 * 7 table always
For i = iDaysInMonth + iCol - 1 To 41
strDays = strDays & vbTab
Next i
Set objActiveRange = Selection.Range
objActiveRange.Text = strDays
objActiveRange.Style = rgstrDaysStyle(iCalendarStyle) & iOrientation & iNoPicture
objActiveRange.Select
Selection.ConvertToTable wdSeparateByTabs, 6, 7
Selection.Cells.Height = rgsDaysHeight(iCalendarStyle, iOrientation, iNoPicture)
Selection.Tables(1).Rows(1).Height = rgsMonthNamesHeight(iCalendarStyle, iOrientation, iNoPicture)
'========================================================
' Mn.Sept.01.2014; 08h21
' TABLE GRIDLINES CODE: Automatically creates printable gridlines in the table.
With Selection.Tables(1).Borders
.InsideLineStyle = wdLineStyleSingle
.InsideLineWidth = wdLineWidth100pt
.InsideColorIndex = wdAuto
.OutsideLineStyle = wdLineStyleSingle
.OutsideLineWidth = wdLineWidth100pt
End With
'========================================================
ActiveDocument.Bookmarks(strBkMkDays).Delete
'Advance the current month
If iMonthCurr = 12 Then
iMonthCurr = 1
iYearCurr = iYearCurr + 1
Else
iMonthCurr = iMonthCurr + 1
End If
lYearMonthCurr = (CLng(iYearCurr) * 100) + CLng(iMonthCurr)
If lYearMonthCurr <= lYearMonthEnd Then
Set objActiveRange = ActiveDocument.Content
objActiveRange.Collapse wdCollapseEnd
'Insert Page Break
objActiveRange.InsertBreak wdPageBreak
Set objActiveRange = ActiveDocument.Content
objActiveRange.Collapse wdCollapseEnd
objActiveRange.Paste
End If
Loop
Application.StatusBar = ""
strCaptionTxt = ""
'Set Application caption
strCaptionTxt = " - " & strAppCaptionPart1 & strAppCaptionPart1b & ocboMonthStart.Text & strAppCaptionPart2 & otxtYearStart.Text & strAppCaptionPart3 & ocboMonthEnd.Text & strAppCaptionPart4 & otxtYearEnd.Text
ActiveDocument.UndoClear
With ActiveWindow
.Caption = .Caption & strCaptionTxt
With .View
.TableGridlines = False
.ShowDrawings = True
End With
End With
'Position cursor at the top
Selection.HomeKey wdStory
CreateNewDoc_Exit:
Exit Sub
CreateNewDoc_Error:
ReportError Err
GoTo CreateNewDoc_Exit
End Sub ' CreateNewDoc
Public Sub InitCallBack(fDummy As Boolean)
Dim i As Integer
Dim objCallBackLabels As BalloonLabels
On Error GoTo ErrorCallBack
If Not (fBlnInitialized) Then
Set objPostWizBln = Assistant.NewBalloon
fBlnInitialized = True
With objPostWizBln
.Heading = strCallBackHeading
.Mode = msoModeModeless
.Button = msoButtonSetCancel
.BalloonType = msoBalloonTypeButtons
.Callback = "Calendar.fnCallBack"
End With
Set objCallBackLabels = objPostWizBln.Labels
objCallBackLabels.Count = iCALL_BACK_COUNT
For i = 1 To iCALL_BACK_COUNT
objCallBackLabels.Item(i).Text = rgstrCallBackMsg(i - 1)
Next i
End If
objPostWizBln.Show
If (Assistant.BalloonError) Then GoTo ErrorCallBack
fPostWizBlnOpen = True
Set objDocBln = ActiveDocument
Set clsBln.app = Application
ActiveDocument.Variables.Add strPOST_WIZ_BLN, "1"
Exit Sub
ErrorCallBack:
DisplayErrorMsg strERR_INIT_CALL_BACK
fPostWizBlnOpen = False
Set objDocBln = ActiveDocument
Set clsBln.app = Application
ActiveDocument.Variables.Add strPOST_WIZ_BLN, "0"
End Sub
Public Function fnCallBack(objBln As Balloon, iBtn As Integer, lPrivate As Long)
On Error GoTo ErrorCallBack
Select Case iBtn
Case Is < 1 'Exit
objBln.Close
fPostWizBlnOpen = False
ActiveDocument.Variables(strPOST_WIZ_BLN).Value = "0"
RestoreAssistant (True)
Case 1 'Remove existing picture
DisplayTip rgstrCallBackTip(0)
Case 2 'Enter information into calendar
DisplayTip rgstrCallBackTip(1)
Case 3 ' Get help
Assistant.Help
End Select
Exit Function
ErrorCallBack:
DisplayErrorMsg Err.Description
End Function
Private Function StrBuildAutoTextName(fDummy As Boolean) As String
Dim strATName As String
On Error GoTo BuildAutoTextName_Error
'Select base AutoText Name NOTE: DO NOT LOCALIZE
Select Case iCalendarStyle
Case wzBOXES
strATName = "Boxes"
Case wzBANNER
strATName = "Banner"
Case wzJAZZY
strATName = "Jazzy"
End Select
strATName = strATName & CStr(Abs(formWizard.optLandscape.Value))
strATName = strATName & CStr(Abs(formWizard.optPictureNo.Value))
StrBuildAutoTextName = strATName
BuildAutoTextName_Exit:
Exit Function
BuildAutoTextName_Error:
StrBuildAutoTextName = ""
Resume BuildAutoTextName_Exit
End Function
'displays a tip during post-wizard options
'assumes that Assistant is present since it is called from post-wizard balloon
Private Sub DisplayTip(strTip As String)
Dim objBlnTip As Balloon
On Error GoTo FatalError
Set objBlnTip = Assistant.NewBalloon
With objBlnTip
.Mode = msoModeModal
.Heading = strWizName
.Text = strTip
.Button = msoButtonSetOK
End With
objBlnTip.Show
If Assistant.BalloonError <> msoBalloonErrorNone Then GoTo FatalError
Exit Sub
FatalError:
Err.Clear
End Sub
The above is from the module labelled "Calendar". I don't believe anything was altered in the module labelled "Common", but please let me know that I should post it.
To recap, in this wizard file, the first day of the week is set for Monday. So the Saturday and Sunday columns always fall as the last 2 columns in the calendar table (Sunday as first day has the 1st and last column as the ones that would need shading).
How can that syntax be added to shade the last 2 columns in the Monday calendar wizard, and the 1st and last column for the Sunday calendar wizard and hopefully shading just those particular cells in either with numbers in them?
Thank you! Very much appreciated.Thanks, Doug! Works beautifully. I tried them again this morning, really incredible!
I'm going to keep the Monday and Sunday wizard files as separate files because I realized that I don't have the skills (or the time) to try to figure out how to modify it so the user is requested the starting day. It'll be beyond my meager skills,
I'm sure, especially since there are all those dialogue boxes to contend with at the wizard's start. I was forgetting about those. So leaving these as 2 separate files where one chooses the starting day as per the title, the Monday one for Monday
and the other, the Sunday one, for a Sunday start day.
However, the only difference between them at this point is that one has a "0" for Sunday and the other a "1" for Monday, at the appropriate spots in the code. being the starting week day and the other a "1" for Monday.
That's it. They're beautifully the same in the rest of the code. And a further benefit is that only one module was touched at all for all of this, the Calendar module (leaving the one labelled "Common" untouched.
So anyone with a calendar wizard file can just change the piece of code below (begging the group's indulgence, if I may, in posting the modified code (??):
' WORD 97 WIZARD
' Calendar Wizard Specific Code
Option Explicit
' CONSTANT DECLARATIONS
'=============================== LOCALIZATION BLOCK ===============================
' Localization Note: iWeekStartDay is the starting day of the week (Sun = 0, Mon = 1, ...Sat = 6)
Public Const iWeekStartDay As Integer = 1
' Banter strings
Public Const strWarnYearReq As String = "Both starting and ending years are required."
Public Const strWarnMinExceeded As String = "The year can not be before 1900."
Public Const strWarnMaxExceeded As String = "The year can not be after 4095."
Public Const strWarnRangeExceeded As String = "The calendar is limited to 120 months (10 years)."
Public Const strAppCaptionPart1 As String = "Calendar: "
Public Const strAppCaptionPart1b As String = ""
Public Const strAppCaptionPart2 As String = ", "
Public Const strAppCaptionPart3 As String = " to "
Public Const strAppCaptionPart4 As String = ", "
' Status messages
Public Const strStatusIntro As String = "Creating Calendar..."
Public Const strStatusPart1 As String = "Creating "
Public Const strStatusPart2 As String = ", "
Public Const strStatusPart3 As String = "..."
' Assistant
Public Const strCallBackHeading As String = "Do more with the calendar?"
'Margins for A4 size (if wizard changes pagesize to A4)
Public Const sA4_SHORT_MARGIN As Single = 28.8
Public Const sA4_LONG_MARGIN As Single = 57.6
'Margins for Letter size (if wizard changes pagesize to Letter) in pts
Public Const sLETTER_SHORT_MARGIN As Single = 36
Public Const sLETTER_LONG_MARGIN As Single = 36
'========== END LOCALIZATION BLOCK - DO NOT MAKE CHANGES BELOW THIS LINE ==========
Public Const iYearMin As Integer = 1900
Public Const iYearMax As Integer = 4095
' Bookmark Names - DO NOT LOCALIZE
' Note: No spaces allowed in bookmark names
Public Const strBkMkMonth As String = "Month"
Public Const strBkMkDays As String = "Days"
Public Const strBkMkDayNames As String = "DayNames"
Public Const strBkMkYear As String = "Year"
' Calendar Style Names and Constants
Public Const wzBOXES As Integer = 0
Public Const wzBANNER As Integer = 1
Public Const wzJAZZY As Integer = 2
' Form Control
Public Const wzPAGE_START As Integer = 0
Public Const wzPAGE_STYLE As Integer = 1
Public Const wzPAGE_DIRECTION As Integer = 2
Public Const wzPAGE_MONTHS As Integer = 3
Public Const wzPAGE_FINISH As Integer = 4
'orientation
Public Const iORTN_PORTRAIT As Integer = 0
Public Const iORTN_LANDSCAPE As Integer = 1
' Assistant
Public Const iMAX_PANEL As Integer = 4 ' Number of last panel in MultiPage (First=0)
Public Const iCALL_BACK_COUNT As Integer = 3 ' Number of items in CallBackBalloon (First=1)
'postwizard balloon document variable
Public Const strPOST_WIZ_BLN As String = "Calendar post wizard balloon"
' VARIABLE DECLARATIONS
' General
Public rgstrMonthName(11) As String
Public rgstrDayName(6) As String
Public rgiDaysInMonth(11) As String
Public fDateError As Boolean
Public fCheckValidity As Boolean 'if set then the dates are checked for validity
'variables used in doc. creation
Public str1_TO_28 As String
Public rgsDaysHeight(2, 1, 1) As Single
Public rgsMonthNamesHeight(2, 1, 1) As Single
Public rgstrDaysStyle(2) As String
Public rgstrMonthNamesStyle(2) As String
Public strSTY_BANNER_HDG3 As String
' Assistant
Public rgstrAssistantMsg(iMAX_PANEL + 1) As String
Public rgstrCallBackMsg(iCALL_BACK_COUNT) As String
Public rgstrCallBackTip(iCALL_BACK_COUNT) As String
' Page 1
Public iCalendarStyle As Integer
Public iSavedStyle As Integer
' Page 2
' Page 3
' Page 4
Public Sub InitWizardName(fDummy As Boolean)
strWizName = "Calendar Wizard"
strWizLongName = strWizName
strWizShortName = "Calendar"
End Sub
Public Sub InitWizardStrings(fDummy As Boolean)
Dim i As Integer
On Error GoTo FatalError
'=============================== LOCALIZATION BLOCK ===============================
' Note: this list is indexed 0 - iMAX_PANEL
rgstrAssistantMsg(0) = "The Calendar Wizard helps you create a monthly calendar that you can customize with pictures and events. If you want to track and be reminded of events, you should probably use Microsoft Outlook, Microsoft Schedule+, or Microsoft Exchange."
rgstrAssistantMsg(1) = "Select the look you want for your calendar. The Jazzy style uses the Algerian font. If it is not installed on your system, copy alger.ttf from the Valupack folder on the Microsoft Office CD to your hard drive."
rgstrAssistantMsg(2) = "If you leave room for a picture, Word will insert a placeholder picture that you can replace with any picture you want."
rgstrAssistantMsg(3) = "Your calendar can start on any month, and you can make your calendar shorter than or longer than 12 months. Each month will appear on a different page."
rgstrAssistantMsg(4) = "To change any settings, click Back."
' Note: change constant iCALL_BACK_COUNT if number of items in list changes
rgstrCallBackMsg(0) = "Add, remove, or replace a picture"
rgstrCallBackMsg(1) = "Enter information into the calendar"
rgstrCallBackMsg(2) = "Get Help on Something Else..."
rgstrCallBackTip(0) = "To remove a picture, click on it and then press Delete. To add a picture, click where you want to insert the picture, point to Picture on the Insert menu, and then click From File."
rgstrCallBackTip(1) = "To enter information, click where you want to insert the text and start typing. To move between different dates in the calendar, press Tab to move forward or press Shift+Tab to move to the previous date."
'Load Month Name array
rgstrMonthName(0) = "January"
rgstrMonthName(1) = "February"
rgstrMonthName(2) = "March"
rgstrMonthName(3) = "April"
rgstrMonthName(4) = "May"
rgstrMonthName(5) = "June"
rgstrMonthName(6) = "July"
rgstrMonthName(7) = "August"
rgstrMonthName(8) = "September"
rgstrMonthName(9) = "October"
rgstrMonthName(10) = "November"
rgstrMonthName(11) = "December"
'Load Day Name array LOCALIZATION NOTE: DO NOT CHANGE THE ORDER IN WHICH THESE APPEAR!
' TO CHANGE THE WEEK START DAY, CHANGE THE CONSTANT iWeekStartDay
rgstrDayName(0) = "Sun"
rgstrDayName(1) = "Mon"
rgstrDayName(2) = "Tue"
rgstrDayName(3) = "Wed"
rgstrDayName(4) = "Thu"
rgstrDayName(5) = "Fri"
rgstrDayName(6) = "Sat"
'Load Days In Month array
rgiDaysInMonth(0) = 31
rgiDaysInMonth(1) = 28 'Will not be used - must be calculated for leap year accuracy
rgiDaysInMonth(2) = 31
rgiDaysInMonth(3) = 30
rgiDaysInMonth(4) = 31
rgiDaysInMonth(5) = 30
rgiDaysInMonth(6) = 31
rgiDaysInMonth(7) = 31
rgiDaysInMonth(8) = 30
rgiDaysInMonth(9) = 31
rgiDaysInMonth(10) = 30
rgiDaysInMonth(11) = 31
rgstrDaysStyle(wzBOXES) = "Boxes"
rgstrDaysStyle(wzBANNER) = "Banner"
rgstrDaysStyle(wzJAZZY) = "Jazzy"
rgstrMonthNamesStyle(wzBOXES) = "Boxes Heading2"
rgstrMonthNamesStyle(wzBANNER) = "Banner Heading2"
'we dont set the style for month names in Jazzy style
'the Banner style landscape calendar with picture uses Banner Heading3 style for month names
strSTY_BANNER_HDG3 = "Banner Heading3"
rgsMonthNamesHeight(wzBOXES, iORTN_PORTRAIT, 0) = 55
rgsMonthNamesHeight(wzBOXES, iORTN_PORTRAIT, 1) = 55
rgsMonthNamesHeight(wzBOXES, iORTN_LANDSCAPE, 0) = 36
rgsMonthNamesHeight(wzBOXES, iORTN_LANDSCAPE, 1) = 36
rgsDaysHeight(wzBOXES, iORTN_PORTRAIT, 0) = 56
rgsDaysHeight(wzBOXES, iORTN_PORTRAIT, 1) = 102
rgsDaysHeight(wzBOXES, iORTN_LANDSCAPE, 0) = 72
rgsDaysHeight(wzBOXES, iORTN_LANDSCAPE, 1) = 71
rgsMonthNamesHeight(wzBANNER, iORTN_PORTRAIT, 0) = 60
rgsMonthNamesHeight(wzBANNER, iORTN_PORTRAIT, 1) = 60
rgsMonthNamesHeight(wzBANNER, iORTN_LANDSCAPE, 0) = 55
rgsMonthNamesHeight(wzBANNER, iORTN_LANDSCAPE, 1) = 51
rgsDaysHeight(wzBANNER, iORTN_PORTRAIT, 0) = 64
rgsDaysHeight(wzBANNER, iORTN_PORTRAIT, 1) = 110
rgsDaysHeight(wzBANNER, iORTN_LANDSCAPE, 0) = 81
rgsDaysHeight(wzBANNER, iORTN_LANDSCAPE, 1) = 81
rgsMonthNamesHeight(wzJAZZY, iORTN_PORTRAIT, 0) = 73
rgsMonthNamesHeight(wzJAZZY, iORTN_PORTRAIT, 1) = 73
rgsMonthNamesHeight(wzJAZZY, iORTN_LANDSCAPE, 0) = 62
rgsMonthNamesHeight(wzJAZZY, iORTN_LANDSCAPE, 1) = 59
rgsDaysHeight(wzJAZZY, iORTN_PORTRAIT, 0) = 40.5
rgsDaysHeight(wzJAZZY, iORTN_PORTRAIT, 1) = 81.8
rgsDaysHeight(wzJAZZY, iORTN_LANDSCAPE, 0) = 58.2
rgsDaysHeight(wzJAZZY, iORTN_LANDSCAPE, 1) = 57.5
str1_TO_28 = ""
For i = 1 To 28
str1_TO_28 = str1_TO_28 & CStr(i) & vbTab
Next i
'strip off last tab
str1_TO_28 = Left$(str1_TO_28, Len(str1_TO_28) - 1)
' Location in registry DO NOT LOCALIZE
strRegSettingsKey = strREG_SETTINGS_BASE_KEY & "Calendar Wizard"
Exit Sub
FatalError:
ReportError Err
End Sub ' InitWizardStrings
Public Sub InitWizard(fDummy As Boolean)
' Global Vars
fWizardCallBack = False
fDateError = False
iCurrentPanel = 0
' Initialize strings
InitWizardStrings (True)
' Create a new instance of the form
Set formWizard = New formWizDlg
If formWizard Is Nothing Then GoTo FatalError
formWizard.lblWizName1.Caption = " " & strWizLongName & " "
Exit Sub
FatalError:
DisplayErrorMsg strERR_INIT_FORM
ReportError Err
End Sub
' fDummy prevents sub from appearing in Word Tools/Macro list
Public Sub SaveDialogValues(fDummy As Boolean)
On Error GoTo FatalError
' Display status
Application.ScreenUpdating = False
System.Cursor = wdCursorWait
StatusBar = strSAVE_SETTINGS
' Assistant
System.PrivateProfileString("", strREG_SETTINGS_BASE_KEY, strREG_ASSISTANT_TIME_STAMP) = Format$(Now, "General Date")
StoreValPref strREG_ASSISTANT_HELP, iLocalState
' Page 1
StoreValPref "iCalendarStyle", iCalendarStyle
' Page 2
StoreValPref "optPortrait", formWizard.optPortrait.Value
StoreValPref "optPictureYes", formWizard.optPictureYes.Value
' Page 3
StatusBar = ""
System.Cursor = wdCursorNormal
fSettingsSaved = True
Application.ScreenUpdating = True
Exit Sub
FatalError:
ReportError Err
End Sub
Public Sub RestoreDialogValues(fDummy As Boolean)
Dim i As Integer
On Error GoTo FatalError
' Display status
Application.ScreenUpdating = False
StatusBar = strRST_SETTINGS
System.Cursor = wdCursorWait
' Page 1
iCalendarStyle = IRestorePref("iCalendarStyle", 0)
Select Case iCalendarStyle
Case wzBOXES
formWizard.optBoxes.Value = True
formWizard.shpShadowBoxes.Visible = True
Case wzBANNER
formWizard.optBanner.Value = True
formWizard.shpShadowBanner.Visible = True
Case wzJAZZY
formWizard.optJazzy.Value = True
formWizard.shpShadowJazzy.Visible = True
Case Else
iCalendarStyle = wzBOXES
formWizard.optBoxes.Value = True
formWizard.shpShadowBoxes.Visible = True
End Select
' Page 2
If FRestorePref("optPortrait", False) Then
formWizard.optPortrait.Value = True
formWizard.shpPortraitShadow.Visible = True
formWizard.shpLandscapeShadow.Visible = False
Else
formWizard.optLandscape.Value = True
formWizard.shpPortraitShadow.Visible = False
formWizard.shpLandscapeShadow.Visible = True
End If
formWizard.optPictureYes.Value = FRestorePref("optPictureYes", False)
' Page 3
formWizard.cboMonthStart.ListIndex = Month(Date) - 1
formWizard.cboMonthEnd.ListIndex = Month(Date) - 1
formWizard.txtYearStart = Year(Date)
formWizard.txtYearEnd = Year(Date)
fCheckValidity = False
StatusBar = ""
System.Cursor = wdCursorNormal
fSettingsRestored = True
Application.ScreenUpdating = True
Exit Sub
FatalError:
ReportError Err
Exit Sub
End Sub ' RestoreDialogValues
' fDummy prevents sub from appearing in Word Tools/Macro list
Public Sub CreateNewDoc(fDummy As Boolean)
Dim iMonthCurr As Integer
Dim iYearCurr As Integer
Dim lYearMonthCurr As Long
Dim lYearMonthEnd As Long
Dim iDaysCnt As Integer
Dim iDaysInMonth As Integer
Dim iCnt As Integer
Dim strAutoTextName As String
Dim objTableDays As Table
Dim iRow As Integer
Dim iCol As Integer
Dim ocboMonthStart As ComboBox
Dim ocboMonthEnd As ComboBox
Dim otxtYearStart As TextBox
Dim otxtYearEnd As TextBox
Dim strJazzyDayNames As String
Dim objFps As PageSetup
Dim objRng As Range
Dim sShortMargin As Single
Dim sLongMargin As Single
Dim strCaptionTxt As String
Dim iOrientation As Integer
Dim iNoPicture As Integer
Dim i As Integer
Dim strDays As String
On Error GoTo CreateNewDoc_Error
System.Cursor = wdCursorWait
Set ocboMonthStart = formWizard.cboMonthStart
Set ocboMonthEnd = formWizard.cboMonthEnd
Set otxtYearStart = formWizard.txtYearStart
Set otxtYearEnd = formWizard.txtYearEnd
With Application
.ScreenUpdating = False
.StatusBar = strStatusIntro
End With
Set objActiveRange = ActiveDocument.Content
objActiveRange.Collapse wdCollapseEnd
If (formWizard.optPortrait) Then
iOrientation = iORTN_PORTRAIT
Else
iOrientation = iORTN_LANDSCAPE
End If
iNoPicture = Abs(formWizard.optPictureNo.Value)
'the margins have to be changed if papersize was changed in Common
If (fChangeToA4 Or fChangeToLetter) Then
Set objFps = ActiveDocument.PageSetup
If iOrientation = iORTN_LANDSCAPE Then
objFps.Orientation = wdOrientLandscape 'setting paper size in common
'resets orientation to Portrait
If fChangeToA4 Then
sShortMargin = sA4_SHORT_MARGIN
sLongMargin = sA4_LONG_MARGIN
Else
sShortMargin = sLETTER_SHORT_MARGIN
sLongMargin = sLETTER_LONG_MARGIN
End If
Else
If fChangeToA4 Then
sShortMargin = sA4_LONG_MARGIN
sLongMargin = sA4_SHORT_MARGIN
Else
sShortMargin = sLETTER_LONG_MARGIN
sLongMargin = sLETTER_SHORT_MARGIN
End If
End If
With objFps
.TopMargin = sShortMargin
.BottomMargin = sShortMargin
.LeftMargin = sLongMargin
.RightMargin = sLongMargin
End With
End If
strAutoTextName = StrBuildAutoTextName(True)
objWizTemplate.AutoTextEntries(strAutoTextName).Insert objActiveRange, True
If iCalendarStyle <> wzJAZZY Then
Set objActiveRange = ActiveDocument.Bookmarks(strBkMkDays).Range
Else
Set objActiveRange = ActiveDocument.Bookmarks(strBkMkDayNames).Range
End If
strJazzyDayNames = ""
For iCnt = iWeekStartDay To 6
strJazzyDayNames = strJazzyDayNames & rgstrDayName(iCnt) & vbTab
Next
For iCnt = 0 To (iWeekStartDay - 1)
strJazzyDayNames = strJazzyDayNames & rgstrDayName(iCnt) & vbTab
Next
'Strip trailing Tab
strJazzyDayNames = Left$(strJazzyDayNames, Len(strJazzyDayNames) - 1)
objActiveRange.Text = strJazzyDayNames
If iCalendarStyle <> wzJAZZY Then
If (iCalendarStyle = wzBANNER) And (iOrientation = iORTN_LANDSCAPE) And (iNoPicture = 0) Then
objActiveRange.Style = strSTY_BANNER_HDG3
Else
objActiveRange.Style = rgstrMonthNamesStyle(iCalendarStyle)
End If
objActiveRange.Select
Selection.ConvertToTable wdSeparateByTabs, 1, 7
End If
Set objActiveRange = ActiveDocument.Content
objActiveRange.Copy
iMonthCurr = CInt(ocboMonthStart.ListIndex) + 1
iYearCurr = CInt(otxtYearStart.Text)
lYearMonthCurr = (CLng(iYearCurr) * 100) + CLng(iMonthCurr)
lYearMonthEnd = (CLng(otxtYearEnd.Text) * 100) + (CLng(ocboMonthEnd.ListIndex) + 1)
'Create each month of the calendar
Do Until lYearMonthCurr > lYearMonthEnd
Application.StatusBar = strStatusPart1 & rgstrMonthName(iMonthCurr - 1) & strStatusPart2 & CStr(iYearCurr) & strStatusPart3
'Set month
If iCalendarStyle = wzJAZZY Then
ActiveDocument.Bookmarks(strBkMkMonth).Range.Text = CStr(iMonthCurr)
Else
ActiveDocument.Bookmarks(strBkMkMonth).Range.Text = rgstrMonthName(iMonthCurr - 1)
End If
'Set year
ActiveDocument.Bookmarks(strBkMkYear).Range.Text = CStr(iYearCurr)
'Determine number of days in month
If iMonthCurr = 2 Then
iDaysInMonth = DateSerial(iYearCurr, 3, 1) - DateSerial(iYearCurr, 2, 1)
Else
iDaysInMonth = rgiDaysInMonth(iMonthCurr - 1)
End If
'Set Column of First Day Of Month by using Weekday function. The 8th
'is used (to start with) instead of the 1st to allow for offsetting (via
'iWeekStartDay) for localization since the 8th will always fall on the
'same day (of the week) as the 1st.
iCol = WeekDay(DateSerial(iYearCurr, iMonthCurr, 8 - iWeekStartDay))
ActiveDocument.Bookmarks(strBkMkDays).Select
If iCalendarStyle <> wzJAZZY Then _
Selection.MoveDown wdLine 'the bookmark is now in the first cell of the table
strDays = ""
For i = 1 To iCol - 1
strDays = strDays & vbTab
Next i
strDays = strDays & str1_TO_28
For i = 29 To iDaysInMonth
strDays = strDays & vbTab & CStr(i)
Next i
'to get a 6 * 7 table always
For i = iDaysInMonth + iCol - 1 To 41
strDays = strDays & vbTab
Next i
Set objActiveRange = Selection.Range
objActiveRange.Text = strDays
objActiveRange.Style = rgstrDaysStyle(iCalendarStyle) & iOrientation & iNoPicture
objActiveRange.Select
Selection.ConvertToTable wdSeparateByTabs, 6, 7
Selection.Cells.Height = rgsDaysHeight(iCalendarStyle, iOrientation, iNoPicture)
Selection.Tables(1).Rows(1).Height = rgsMonthNamesHeight(iCalendarStyle, iOrientation, iNoPicture)
'================================================================================================================================
' Tu.Mar.11.2015; 17h56 - MVPEdits/MyEdits
' SATURDAY and SUNDAY cells get shaded in the table (no matter where they fall).
' Doug Robbins - Word MVP; https://social.msdn.microsoft.com/Forums/office/en-US/6ab55be0-adc0-4e37-9565-8cdff089d20a/shading-certain-columns-depending-on-start-day-of-week?forum=worddev
Dim j As Long
With Selection.Tables(1)
If iWeekStartDay = 1 Then
For i = 6 To 7
With .Columns(i)
' For j = 1 To .Cells.Count ' 1 = Cells with SAT and SUN text are shaded
For j = 2 To .Cells.Count ' 2 = Cells with SAT and SUN text are _ NOT_ shaded
With .Cells(j).Range
If Len(.Text) > 2 Then
.Shading.BackgroundPatternColor = wdColorGray20 'wdColorGray_ _ _ (the number following gives the shade of gray, i.e., wdColorGray20 vs. wdColorGray50)
End If
End With
Next j
End With
Next i
Else
For i = 1 To 7 Step 6
With .Columns(i)
' For j = 1 To .Cells.Count ' 1 = Cells with SAT and SUN text are shaded
For j = 2 To .Cells.Count ' 2 = Cells with SAT and SUN text are _ NOT_ shaded
With .Cells(j).Range
If Len(.Text) > 2 Then
.Shading.BackgroundPatternColor = wdColorGray20 'wdColorGray_ _ _ (the number following gives the shade of gray, i.e., wdColorGray20 vs. wdColorGray50)
End If
End With
Next j
End With
Next i
End If
End With
'================================================================================================================================
'================================================================================================================================
' Mn.Sept.01.2014; 08h21 - MVPEdits/MyEdits
' TABLE GRIDLINES CODE: Automatically creates printable gridlines in the table.
With Selection.Tables(1).Borders
.InsideLineStyle = wdLineStyleSingle
.InsideLineWidth = wdLineWidth100pt
.InsideColorIndex = wdAuto
.OutsideLineStyle = wdLineStyleSingle
.OutsideLineWidth = wdLineWidth100pt
End With
'================================================================================================================================
ActiveDocument.Bookmarks(strBkMkDays).Delete
'Advance the current month
If iMonthCurr = 12 Then
iMonthCurr = 1
iYearCurr = iYearCurr + 1
Else
iMonthCurr = iMonthCurr + 1
End If
lYearMonthCurr = (CLng(iYearCurr) * 100) + CLng(iMonthCurr)
If lYearMonthCurr <= lYearMonthEnd Then
Set objActiveRange = ActiveDocument.Content
objActiveRange.Collapse wdCollapseEnd
'Insert Page Break
objActiveRange.InsertBreak wdPageBreak
Set objActiveRange = ActiveDocument.Content
objActiveRange.Collapse wdCollapseEnd
objActiveRange.Paste
End If
Loop
Application.StatusBar = ""
strCaptionTxt = ""
'Set Application caption
strCaptionTxt = " - " & strAppCaptionPart1 & strAppCaptionPart1b & ocboMonthStart.Text & strAppCaptionPart2 & otxtYearStart.Text & strAppCaptionPart3 & ocboMonthEnd.Text & strAppCaptionPart4 & otxtYearEnd.Text
ActiveDocument.UndoClear
With ActiveWindow
.Caption = .Caption & strCaptionTxt
With .View
.TableGridlines = False
.ShowDrawings = True
End With
End With
'Position cursor at the top
Selection.HomeKey wdStory
CreateNewDoc_Exit:
Exit Sub
CreateNewDoc_Error:
ReportError Err
GoTo CreateNewDoc_Exit
End Sub ' CreateNewDoc
Public Sub InitCallBack(fDummy As Boolean)
Dim i As Integer
Dim objCallBackLabels As BalloonLabels
On Error GoTo ErrorCallBack
If Not (fBlnInitialized) Then
Set objPostWizBln = Assistant.NewBalloon
fBlnInitialized = True
With objPostWizBln
.Heading = strCallBackHeading
.Mode = msoModeModeless
.Button = msoButtonSetCancel
.BalloonType = msoBalloonTypeButtons
.Callback = "Calendar.fnCallBack"
End With
Set objCallBackLabels = objPostWizBln.Labels
objCallBackLabels.Count = iCALL_BACK_COUNT
For i = 1 To iCALL_BACK_COUNT
objCallBackLabels.Item(i).Text = rgstrCallBackMsg(i - 1)
Next i
End If
objPostWizBln.Show
If (Assistant.BalloonError) Then GoTo ErrorCallBack
fPostWizBlnOpen = True
Set objDocBln = ActiveDocument
Set clsBln.app = Application
ActiveDocument.Variables.Add strPOST_WIZ_BLN, "1"
Exit Sub
ErrorCallBack:
DisplayErrorMsg strERR_INIT_CALL_BACK
fPostWizBlnOpen = False
Set objDocBln = ActiveDocument
Set clsBln.app = Application
ActiveDocument.Variables.Add strPOST_WIZ_BLN, "0"
End Sub
Public Function fnCallBack(objBln As Balloon, iBtn As Integer, lPrivate As Long)
On Error GoTo ErrorCallBack
Select Case iBtn
Case Is < 1 'Exit
objBln.Close
fPostWizBlnOpen = False
ActiveDocument.Variables(strPOST_WIZ_BLN).Value = "0"
RestoreAssistant (True)
Case 1 'Remove existing picture
DisplayTip rgstrCallBackTip(0)
Case 2 'Enter information into calendar
DisplayTip rgstrCallBackTip(1)
Case 3 ' Get help
Assistant.Help
End Select
Exit Function
ErrorCallBack:
DisplayErrorMsg Err.Description
End Function
Private Function StrBuildAutoTextName(fDummy As Boolean) As String
Dim strATName As String
On Error GoTo BuildAutoTextName_Error
'Select base AutoText Name NOTE: DO NOT LOCALIZE
Select Case iCalendarStyle
Case wzBOXES
strATName = "Boxes"
Case wzBANNER
strATName = "Banner"
Case wzJAZZY
strATName = "Jazzy"
End Select
strATName = strATName & CStr(Abs(formWizard.optLandscape.Value))
strATName = strATName & CStr(Abs(formWizard.optPictureNo.Value))
StrBuildAutoTextName = strATName
BuildAutoTextName_Exit:
Exit Function
BuildAutoTextName_Error:
StrBuildAutoTextName = ""
Resume BuildAutoTextName_Exit
End Function
'displays a tip during post-wizard options
'assumes that Assistant is present since it is called from post-wizard balloon
Private Sub DisplayTip(strTip As String)
Dim objBlnTip As Balloon
On Error GoTo FatalError
Set objBlnTip = Assistant.NewBalloon
With objBlnTip
.Mode = msoModeModal
.Heading = strWizName
.Text = strTip
.Button = msoButtonSetOK
End With
objBlnTip.Show
If Assistant.BalloonError <> msoBalloonErrorNone Then GoTo FatalError
Exit Sub
FatalError:
Err.Clear
End Sub
Thank you once again for all your help!! Very much appreciated. :D -
How to make column range based on a column in Oracle BI 11g
Hello everyone!
I want to know, how to make column range from a column in oracle bi 11g.
for example!
I have a column amounts and I want to build on this with other values of quantity, other column range 1-9,10-49,50-99,100-249, 249 o more.
regards!
when I try to make the range I have error.
Syntax error [nQSError: 26012] . (HY000)
SQL Issued: SELECT CASE WHEN "CUBO_DEEE_TAB"."CANTIDAD" BETWEEN 1 AND 9 THEN 1 a 9 ELSE "CUBO_DEEE_TAB"."CANTIDAD" END FROM "DM_DEEE"
Edited by: 964157 on 09-oct-2012 11:50You cannot add columns dynamically. But you can define a maximum number of numbers and then hide unused columns in your form useing SET_ITEM_PROPERTY(..,VISIBLE, PROPERTY_FALSE);
-
How to select all columns in a trigger?
I add a "before delete" trigger on a table, in order to insert the records to a backup table before they are deleted.
but I cannot write like this : insert into t_backup select * from :old;
The table has more than 30 columns so I don't want to select them one by one, how can I select all columns?Yes, it is possible by writing something like this :
where col1 = :old.col1; But it is not directly supported. First, we need a package to remember all the OLD records:.... and please see below link for complete code in action :
http://www.dbforums.com/oracle/925729-trigger-back-up-data.html
What I am doing here, just copying the code and replacing "emp" with "test" (The table name on which I am going to apply this using notepad find and replace):
SQL> select * from test_backup;
no rows selected
SQL> select * from test;
A
1
2
4
5
SQL> select * from test_backup;
no rows selected
SQL>
create or replace package test_trg_pkg as
type test_type is table of test%ROWTYPE index by binary_integer;
test_tab test_type;
end;
create or replace trigger test_bds before delete on test
begin
test_trg_pkg.test_tab.delete;
end;
create or replace trigger test_adr after delete on test
for each row
declare
-- To allow us to select the old values
pragma autonomous_transaction;
begin
select *
into test_trg_pkg.test_tab(test_trg_pkg.test_tab.COUNT+1)
from test
where a = :old.a; <----- Here you have to give your column name.
end;
create or replace trigger test_ads after delete on test
begin
for i in 1..test_trg_pkg.test_tab.COUNT loop
insert into test_backup values test_trg_pkg.test_tab(i);
end loop;
end;
SQL> delete from test where a=1;
1 row deleted.
SQL> select * from test_backup;
A
1
SQL> delete from test where a=2;
1 row deleted.
SQL> select * from test_backup;
A
1
2
SQL>Regards
Girish Sharma -
What is the difference betwwen SELECT ALL Column and Select Speceific Colum
Hi All,
If the block size of the database is 8K and average row length is 2K and if we select all column of the table the I/O show that it had read more blocks then compare to
specific column of the same table. Why is this?
Secondly if Oracle brings a complete block is the db buffer cache, while reading block from disk, they why there is a difference of block count in two queries.
This difference reveals to me when I check the EXPLAIN PLAN for two different queries against the same table but one select all columns and the other one select specific column.
Kindly help me in clearing this confusion.
Regards,
Kamranuser1514587 wrote:
>
Usually, indexes are smaller (contain fewer blocks) than the table - ergo, select empno from emp could be satisfied by reading fewer blocks.
what if there is a composite Index on a table containing 3 to 4 columns and the size of table is in 100 of GB and Index size itself is vey large then I think Oracle will go for FTS and small Index scan will be expensive. Kindly Share your thoughts.
Regards,
KamranHandle: user1514587
Status Level: Newbie (5)
Registered: May 9, 2011
Total Posts: 21
Total Questions: 13 (12 unresolved)
I think you wastes everyone's time here since you rarely get answer to any posted question -
Restict read only users to certain columns
Hi guys ,
I want to restrict read-only users to read only certain columns on the table.How do I go about restricting?Always include the following information when asking a question:
<ul>
<li>Full APEX version</li>
<li>Full DB/version/edition/host OS</li>
<li>Web server architecture (EPG, OHS or APEX listener/host OS)</li>
<li>Browser(s) and version(s) used</li>
<li>Theme</li>
<li>Template(s)</li>
<li>Region/item type(s)</li>
</ul>
935462 wrote:
Hi guys ,
I want to restrict read-only users to read only certain columns on the table.How do I go about restricting?Who are readonly users? How are they determined?
What exactly are you talking about?
Is it a report, If then which report Interactive or Classic?
In either of them you can do conditional display of column using the same login
Look at this for options http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21674/bldapp_rpt_att.htm#BCEBDIFA -
Selecting all columns from table in a model query
I have written a model query which joins 4 tables, applies some rules and returns updated rows by selecting 4 columns out of this. Currently it works fine because all 4 columns are from MODEL aliases. Now I need to select 16 more columns in the same query but none of these columns is added in MODEL aliases. When I tried selecting these columns I got oracle error ORA - 32614. Can someone please guide me to include these columns in the same model query?
I tried couple of options but no luck. Here are those options for ready reference:
1. I cannot nest existing model query into another select because there are no columns avaiable to join in output of current query to map with other records.
2. I cannot include all 16 columns in MODEL aliases because some of these columns are actually output of user defined functions.
I am using Oracle database version 11g Release 11.2.0.1.0.
Edited by: Anirudha Dhopate on Jan 23, 2011 5:43 PMThank you Avijit for your reply. There is a syntax error on the ON in this part of the statement which I don't know how to fix - I tried messing around with another INNER JOIN but am not confident that I'm doing the right thing:
SENAlertType.SENAlertTypeIDONClassMember.ClassMemberStudentID
Thanks for your help! I will need to do some more bedtime reading on joins.
Daniel -
Deleting duplicate rows based on three columns in Oracle 8i
Hi all,
The database we use is Oracle 8i.
The query below raises the too_many_rows exception when I launch an application. So I want to delete the duplicated rows :
select polarisation_1, polarisation_2
into v_pol1_tech, v_pol2_tech
from v_cfh_lien_element
where nom_lien = p_nom_lien
AND num_canal_1 = p_num_canal_1
AND freq_emise_1 = p_freq_emise_1;
Notice that with many possible values of the parameters p_nom_lien, p_num_canal_1 and p_freq_emise_1 then the exception is raised.
So how to delete generally the duplicated rows based on the three columns "nom_lien" , "num_canal_1" and "freq_emise_1" ?
Thank you very much indeed.Check the other thread with same question deleting duplicate rows based on three columns in Oracle 8i
-
How to update html file in clob column in oracle
hi,
please help me how to update html file in clob column in oracle
ThanksThis is your main query as i am able to understand and you want to update your html file into terms columns based on conditions :
SELECT b.terms As terms
FROM chklst_item_x_enrlmnt_type a, prvdr_enrlmnt_agreement b
WHERE a.enrlmnt_type_cid = 1
AND a.chklst_item_cid = b.chklst_item_cid
AND a.chklst_item_cid = 79
AND a.oprtnl_flag = 'A'
AND b.oprtnl_flag = 'A'
AND TRUNC (SYSDATE) BETWEEN b.from_date AND b.TO_DATE;So i suggest below one but you need to create a directory where you can store your html file and then you can update .. And remaining consult Experts suggestions too as your
question is improperly posted . . .
DECLARE
vclob CLOB;
v_bfile BFILE := BFILENAME ('YOUR_DIR', 'filename.html');
BEGIN
SELECT b.terms
INTO vclob
FROM chklst_item_x_enrlmnt_type a, prvdr_enrlmnt_agreement b
WHERE a.enrlmnt_type_cid = 1
AND a.chklst_item_cid = b.chklst_item_cid
AND a.chklst_item_cid = 79
AND a.oprtnl_flag = 'A'
AND b.oprtnl_flag = 'A'
AND TRUNC (SYSDATE) BETWEEN b.from_date AND b.TO_DATE
FOR UPDATE;
DBMS_LOB.fileopen (v_bfile);
DBMS_LOB.loadfromfile (vclob, v_bfile, DBMS_LOB.getlength (v_bfile));
DBMS_LOB.fileclose (v_bfile);
END;
/ Regards.. -
Case INSENSITIVE Columns on Oracle
Hello Friends,
Good Monday for everyone....
I would like to ask you guys if there is a way to create a case INSENSITIVE Columns on Oracle. I used on Sqlserver before the COLLATE sintax, and I was able to make a columns (just that one) INSENSITIVE.
I'm using oracle 10gr2 on Windows plataform and herte is my nls_parameters. My ideia is to search on this column without the need of performing a function UPPER and LOWER and etc...
NLS_LANGUAGE BRAZILIAN PORTUGUESE
NLS_TERRITORY BRAZIL
NLS_CURRENCY Cr$
NLS_ISO_CURRENCY BRAZIL
NLS_NUMERIC_CHARACTERS ,.
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DD/MM/RR
NLS_DATE_LANGUAGE BRAZILIAN PORTUGUESE
NLS_CHARACTERSET WE8MSWIN1252
NLS_SORT WEST_EUROPEAN
NLS_TIME_FORMAT HH24:MI:SSXFF
NLS_TIMESTAMP_FORMAT DD/MM/RR HH24:MI:SSXFF
NLS_TIME_TZ_FORMAT HH24:MI:SSXFF TZR
NLS_TIMESTAMP_TZ_FORMAT DD/MM/RR HH24:MI:SSXFF TZR
NLS_DUAL_CURRENCY Cr$
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_COMP BINARY
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSE
tks a lot
KeenAPC wrote:
No, they mean a setting which makes "APC" or "apc" match "Apc".
There is nothing to be done on 10g, other than building a function based index on the column in question, so that any UPPER() searches are optimized.
Well, as Kamran Agayev already noted CI is available in 10g too. It also worth mentioning FBI creates a hidden column. Also, your statement
In 11g we have the option to set the NLS_SORT parameter so that any searches are case-insensitive (or indeed accent insensitive). Find out more.
is incomplete. NLS_SORT affects nothing but sort:
SQL> connect scott
Enter password: *****
Connected.
SQL> select * from v$version
2 /
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
SQL> with t as (
2 select 'Max' name from dual union all
3 select 'sam' name from dual union all
4 select 'Joe' name from dual union all
5 select 'max' name from dual union all
6 select 'joe' name from dual union all
7 select 'Sam' name from dual
8 )
9 select name
10 from t
11 order by name
12 /
NAM
Joe
Max
Sam
joe
max
sam
6 rows selected.
SQL> with t as (
2 select 'Max' name from dual union all
3 select 'sam' name from dual union all
4 select 'Joe' name from dual union all
5 select 'max' name from dual union all
6 select 'joe' name from dual union all
7 select 'Sam' name from dual
8 )
9 select name
10 from t
11 where name = 'max'
12 /
NAM
max
SQL> alter session set nls_sort = binary_ci
2 /
Session altered.
SQL> with t as (
2 select 'Max' name from dual union all
3 select 'sam' name from dual union all
4 select 'Joe' name from dual union all
5 select 'max' name from dual union all
6 select 'joe' name from dual union all
7 select 'Sam' name from dual
8 )
9 select name
10 from t
11 order by name
12 /
NAM
Joe
joe
max
Max
Sam
sam
6 rows selected.
SQL> with t as (
2 select 'Max' name from dual union all
3 select 'sam' name from dual union all
4 select 'Joe' name from dual union all
5 select 'max' name from dual union all
6 select 'joe' name from dual union all
7 select 'Sam' name from dual
8 )
9 select name
10 from t
11 where name = 'max'
12 /
NAM
max
SQL> with t as (
2 select 'Max' name from dual union all
3 select 'sam' name from dual union all
4 select 'Joe' name from dual union all
5 select 'max' name from dual union all
6 select 'joe' name from dual union all
7 select 'Sam' name from dual
8 )
9 select name
10 from t
11 where name like 'm%'
12 /
NAM
max
SQL> select 'Max' name from dual union
2 select 'max' name from dual
3 /
NAM
Max
max
SQL> with t as (
2 select 'Max' name from dual union all
3 select 'sam' name from dual union all
4 select 'Joe' name from dual union all
5 select 'max' name from dual union all
6 select 'joe' name from dual union all
7 select 'Sam' name from dual
8 )
9 select distinct name
10 from t
11 /
NAM
sam
Joe
joe
max
Sam
Max
6 rows selected.
SQL> As you can see, NLS_SORT alone works on sort but not on "searches". We also need to set NLS_COMP, which by default is BINARY. Prior to 10g R2 (I am not 100% sure, it could be prior 10g), the only NLS_COMP choice, besides BINARY, was ANSI. However, ANSI does not work with all comparison operators (e.g. does not work for LIKE, UNION, DISTINCT):
SQL> alter session set nls_sort = binary_ci
2 /
Session altered.
SQL> alter session set nls_comp=ansi
2 /
Session altered.
SQL> with t as (
2 select 'Max' name from dual union all
3 select 'sam' name from dual union all
4 select 'Joe' name from dual union all
5 select 'max' name from dual union all
6 select 'joe' name from dual union all
7 select 'Sam' name from dual
8 )
9 select name
10 from t
11 order by name
12 /
NAM
Joe
joe
max
Max
Sam
sam
6 rows selected.
SQL> with t as (
2 select 'Max' name from dual union all
3 select 'sam' name from dual union all
4 select 'Joe' name from dual union all
5 select 'max' name from dual union all
6 select 'joe' name from dual union all
7 select 'Sam' name from dual
8 )
9 select name
10 from t
11 where name = 'max'
12 /
NAM
Max
max
SQL> with t as (
2 select 'Max' name from dual union all
3 select 'sam' name from dual union all
4 select 'Joe' name from dual union all
5 select 'max' name from dual union all
6 select 'joe' name from dual union all
7 select 'Sam' name from dual
8 )
9 select name
10 from t
11 where name like 'm%'
12 /
NAM
max
SQL> select 'Max' name from dual union
2 select 'max' name from dual
3 /
NAM
Max
max
SQL> with t as (
2 select 'Max' name from dual union all
3 select 'sam' name from dual union all
4 select 'Joe' name from dual union all
5 select 'max' name from dual union all
6 select 'joe' name from dual union all
7 select 'Sam' name from dual
8 )
9 select distinct name
10 from t
11 /
NAM
sam
Joe
joe
max
Sam
Max
6 rows selected.
SQL> Starting 10g R2 NLS_COMP can be set to LINGUISTIC, which will also work for LIKE and UNION but not for DISTINCT:
SQL> alter session set nls_sort = binary_ci
2 /
Session altered.
SQL> alter session set nls_comp=linguistic
2 /
Session altered.
SQL> with t as (
2 select 'Max' name from dual union all
3 select 'sam' name from dual union all
4 select 'Joe' name from dual union all
5 select 'max' name from dual union all
6 select 'joe' name from dual union all
7 select 'Sam' name from dual
8 )
9 select name
10 from t
11 order by name
12 /
NAM
Joe
joe
max
Max
Sam
sam
6 rows selected.
SQL> with t as (
2 select 'Max' name from dual union all
3 select 'sam' name from dual union all
4 select 'Joe' name from dual union all
5 select 'max' name from dual union all
6 select 'joe' name from dual union all
7 select 'Sam' name from dual
8 )
9 select name
10 from t
11 where name = 'max'
12 /
NAM
Max
max
SQL> with t as (
2 select 'Max' name from dual union all
3 select 'sam' name from dual union all
4 select 'Joe' name from dual union all
5 select 'max' name from dual union all
6 select 'joe' name from dual union all
7 select 'Sam' name from dual
8 )
9 select name
10 from t
11 where name like 'm%'
12 /
NAM
Max
max
SQL> select 'Max' name from dual union
2 select 'max' name from dual
3 /
NAM
Max
SQL> with t as (
2 select 'Max' name from dual union all
3 select 'sam' name from dual union all
4 select 'Joe' name from dual union all
5 select 'max' name from dual union all
6 select 'joe' name from dual union all
7 select 'Sam' name from dual
8 )
9 select distinct name
10 from t
11 /
NAM
sam
Joe
joe
max
Sam
Max
6 rows selected.
SQL> However even LINGUISTIC does not work with:
• CLOB or NCLOB data types
• Object data types
• Table partitions
• Index-organized tables
SY. -
Format for certain columns in list view control
I have a list view control and I would like to format the alignment for certain columns. I heard that the only way you can do this is by formatting the cells in excel. I tried this with no success. Can someone please give me step by step instructions on how to achieve this. I am currently allowing Xcelsius to handle my formatting for money. Is it possible to have Xcelsius handle the money formatting and have excel handle the alignment formatting. I am open to whatever works at this point. Also I am using Xcelsius 2008 (Build Number 12,2,1,66).
Much ThxHi,
In list view control you can format the entire row only, not a certain column.
Go to property>Appearance>Text Tab>select Header>Format selected text->select the format.
For width change: Property> Layout Tab>check custom column width the click the icon and enter width in pixel.
Regards,
Senthil K -
How to find encrypted columns in oracle 10g database
Hi,
How to find encrypted columns in oracle 10g database? We can see using view dba_encrypted_columns or all_encrypted_columns .
my question is apart from this is there anyother views or tables?
Thanks..user602872 wrote:
Hi,
How to find encrypted columns in oracle 10g database? We can see using view dba_encrypted_columns or all_encrypted_columns .
my question is apart from this is there anyother views or tables?Hmm not which I could find,
SQL> select * from dict where lower(table_name) like '%encrypted%';
TABLE_NAME
COMMENTS
DBA_ENCRYPTED_COLUMNS
Encryption information on columns in the database
ALL_ENCRYPTED_COLUMNS
Encryption information on all accessible columns
USER_ENCRYPTED_COLUMNS
Encryption information on columns of tables owned by the user
SQL>HTH
Aman....
Maybe you are looking for
-
Mac Book Air shuts down completely if I close the cover and leave email running. Is n't it supposed to just sleep and awaken whe the cover is reopened? Instead, I have to boot it. Any idea what the problem is? I am unaware of any problem, just cl
-
Problem in WEB-UI field (Not Bound)
Hi Experts, I am new to CRM Technical, I have added new standard field (Date Of Birth) thourgh component work bench 'BSP_WD_CMPWB' in 'Z_IC_AGENT' business role. after execution this business roles i could able to see this DOB field but its showi
-
ITunes podcast feed not updating
My podcast feed was broken in January. It is now working again, but iTunes is not picking it up. Do I have to do something to re-start it and get it working again? When I go to iTunes and find my podcast, it shows all the most recent podcasts up unti
-
I am working on a Mac OS X Server, version 10.6.8 I use my Adobe applications - Indesign, PhotoShop, Illustrator, and a couple of others - primarily for school work (graphic design). I download the applications from my Adobe Application Man
-
We have downloaded the movie and it shows the full time in the status at the top. It shows that we are at the begining, but when we hit play it says "Accessing the iTunes Store" the candy stripes run a little, then we are right back where we started