Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all 13329 articles
Browse latest View live

Query Error (Rolling 7 days)

$
0
0
Hi All,

I am writing the following query inorder to return rolling 7 days.

SELECT
day
FROM
dates
WHERE (date(day) between current date-7 days and current date)

But the following error occurs,

>[Error] Script lines: 1-5 --------------------------
Incorrect syntax near the keyword 'current'.
Msg: 156, Level: 15, State: 2
Server: SYD, Line: 5

Can some one please advice? Appreciate your help in Advance!

Thank you,

John

ER Design help

$
0
0
Hi All,

New to the forum, new to database creation. I am looking to create an ER diagram for the following scenario but am running into a lot of trouble:

Vacation of Your Dreams, LLC runs an outdoor adventure vacation company. Clients may select one of the vacations offered which include 1) Kick-Back Adventure, 2) Run Bike Swim Adventure, 3) Under-Sea Shark Adventure, 4) Category -5 River Adventure. The Client must sign waivers and must have had a current physical(within the last 2 months). Each Client must submit a resume which will be used to qualify or disqualify them from participation in a particular vacation adventure. If a client does not qualify they will be offered a spot on a vacation adventure for which they qualify. Each Client will sign a contract promising to participate fully in the adventure and subject themselves to the authority of the Adventure Guide(s) in charge of their vacation adventure.

Each vacation has its own set of specialized equipment which must be assembled, inspected, cleaned and assigned to a participant or group of participants. All specialized equipment must be signed out of the inventory shack before the participants arrive for their adventure by the Adventure Guide. The Kick Back vacation is available to all ages and no limit on participants. Equipment consists of a mug, lawn chair, regular meals prepared in the kitchen, assigned quarters in the Dude Ranch Hotel, binoculars, and notebook. The Run Bike Swim Adventure is limited to 10 persons from 21-40 years of age. Equipment consists of running shorts, trail running shoes, swimming suits, towels, mountain bike, 4 water bottles, high energy food rations for 4 days, and backpack with complete cooking sleeping gear. 4 Guides assigned one of which is qualified as Emergency Medical Technician. The Under-Sea Shark Adventure is limited to 12 certified SCUBA divers of any age. All participants will have a buddy or be assigned a buddy for safety. Participants may bring their own dive gear or they may rent gear in the inventory shack. Each participant and their buddy will be assigned quarters on a live-on dive boat. Food, water, and other supplies will be available for the 6-day dive adventure. 4 Adventure Guides assigned 2 of which are qualified Dive Masters. The Category-5 River Adventure is for 6 teams of 4 people with 6 Senior Adventure Guides. Each team is assigned a 4 man raft, 4 man tent, sleeping gear, and food supplies for 4 days on the river.

Vacation of Your Dreams wants to create brochures with schedules of Adventures to be emailed to Clients as well as conduct other marketing from their database. Permanent records of the contracts must be kept. Contracts will show all client demographic information as well as details of the adventure. The Senior Adventure Guide is responsible to enter the Adventure log which is to be identified by course number, date, and clients attending the Adventure Vacation. Accurate inventory records must be kept in order to supply all vacations. Employees are employed for each adventure season beginning May 1st and ending Sept 30th of each year. There are 5 full-time employees who schedule, plan, and do other logistical duties year-round. The management consisting of a the owner-partners wish to add more vacations in the future.


My previous ER diagram didn't look so hot and i can't quite get it right. Any help would be much appreciated.

Delineating/Parsing Values- Plain Text w/simple formatting

$
0
0
First and foremost, thanks for taking the time to look at my thread. I've been at this for a few hours now- googling, searching threads, etc- and I'm at my wits end.

What I have is a "volunteers database", which stores info on individuals and organizations who volunteer at the local homeless shelter. In the past, the shelter has been gathering this information via forms on it's webpage. Unfortunately, this website is hosted through Weebly, which doesn't support server side scripting. Instead, Weebly emails this information to the shelter via an MHTML form:

Code:

<div style='background: #ddd; text-align: center; font-family: helvetica, arial, verdana, sans-serif; font-size: 16px; line-height: 22px; color: #222;'>
    <div style='padding: 30px;'>
               
        <div style='margin: 0 auto; width: 540px; background: white; text-align: left; padding: 25px; border-radius: 8px; -moz-border-radius: 8px; -webkit-border-radius: 8px;'>
            <p>You've just received a new submission to your <a href='http://www.organizationswebsite.com/volunteer.html'>VOLUNTEER FORM</a>.</p><br /><h2 style='font-size: 16px; border-bottom: 1px solid #ccc; color: black; margin: 10px 0; padding: 0 0 5px 0;'><b>Submitted Information:</b></h2><b>Name</b><br />John Doe<br /><br /><b>Phone Number</b><br />555-555-5555<br /><br /><b>Address</b><br />6037 E. East Way<br />Dirty Myrtle, SC  29588<br /><br /><b>Email</b><br />VolunteersEmail@netzero.com<br /><br /><b>Church Or Organization Affiliation</b><br />No Affiliation<br /><br /><b>How would you like to volunteer? (choose all that apply).Kitchen/Food Prep</b><br />1<br /><br /><b>How would you like to volunteer? (choose all that apply).Construction</b><br />1<br /><br /><b>How would you like to volunteer? (choose all that apply).Gardening</b><br />1<br /><br /><b>How would you like to volunteer? (choose all that apply).Prayer Warrior</b><br />1<br /><br /><b>How would you like to volunteer? (choose all that apply).Maintenance</b><br />1<br /><br /><b>How would you like to volunteer? (choose all that apply).Mentoring</b><br />1<br /><br /><b>How would you like to volunteer? (choose all that apply).Job Skills</b><br />1<br /><br /><b>How would you like to volunteer? (choose all that apply).Transportation</b><br />1<br /><br /><b>How would you like to volunteer? (choose all that apply).Front Desk Receptionist</b><br />1<br /><br /><b>How would you like to volunteer? (choose all that apply).Painting</b><br />1<br /><br />
        </div>
    </div>
</div>

Looking at this, I realize all the information I want to import into the database is delineated by <br /> tags. I'm not interested in parsing these values, using these tags, because I'm under the impression that they would have to somehow archive these messages in order to run any sort of script against them. We're a ragtag bunch and that seems too complicated to be practical.

I'm simply mentioning this angle because I think you might know better...

So, what I've done is this:

-Setup rules in Outlook 2013 to move these emails to a folder in the Inbox.
-Linked MS Access 2013 to said folder.
-Queried pertinent data.
-Created form and set the query as it's data source:


Code:

You've just received a new submission to your VOLUNTEER FORM <http://www.myorganizations.com/volunteer.html> .



Submitted Information:

Name
John Doe

Phone Number
555 - 555 - 5555

Address
1510 Lovely LN, Apt 206
Dirty Myrtle, SC United States 29577

Email
volunteersemail@gmail.com

Church Or Organization Affiliation
Not Affiliated

How would you like to volunteer? (choose all that apply).Kitchen/Food Prep
1

How would you like to volunteer? (choose all that apply).Maintenance
1

How would you like to volunteer? (choose all that apply).Mentoring
1

How would you like to volunteer? (choose all that apply).Job Skills
1

How would you like to volunteer? (choose all that apply).Front Desk Receptionist
1

How would you like to volunteer? (choose all that apply).Painting
1

And there it sits, in a form-- teasing me... :eek:

My question is this: Am I going about this in the most efficient manner? If so, how do I go about parsing this data so that I can append it to the table?

New Software Development Tool Released

$
0
0
Ardeal Soft is proud to announce the release of XtraBuild Designer (v. 1.3.1.1), a new software development tool designed for developers to assist them in creating and building database driven applications.

• Build more applications in less time
• Save on development costs
• Save on additional tool purchases
• Reduce your support costs
• Increase end-user satisfaction

Create professional applications 50 times faster than with traditional methods. With one click you can include in your applications features that otherwise require hundreds of hours of work. Build flexible database solutions for rapid deployment on Windows, from XP to Windows 8, and add licensing rules to the created applications.

With the help of XtraBuild Designer, users have the possibility to create and customize layouts and controls for various applications. Moreover, the application works perfectly with Access, SQL Server, MySQL and SQLite.

· Supports over 20 editors
· Layout management and customization
· Ribbon interface designer
· Advanced Charting and Reporting editors included
· Strong security management


Requirements:
· Microsoft .NET Framework 4

DB2 related issue when I take LDAP backup

$
0
0
Hi,

I have a job which take backup of ldap(ldf format). It was running properly without any issues. Recently, it creates backup file with 0kb. When I run the job manually I have got the error message “GLPRDB001E Error code -1 from function:" SQLConnect " <DBName> .”. When I have checked the db2diag.log file I have got the below messages.

db2diag.log:
============
************************************************** ************************************************** ***********
2013-03-04-05.36.20.591000-300 E34198451H363 LEVEL: Error (OS)
PID : 2416 TID : 2832 PROC : db2syscs.exe
INSTANCE: DB2 NODE : 000
FUNCTION: DB2 UDB, oper system services, sqloImpersonateLocalSystem, probe:10
MESSAGE : ZRC=0x83000005=-2097151995
CALLED : OS, -, OpenProcess
OSERR : 5 "Access is denied."

2013-03-04-05.36.20.591000-300 I34198816H282 LEVEL: Severe
PID : 2416 TID : 2832 PROC : db2syscs.exe
INSTANCE: DB2 NODE : 000
FUNCTION: DB2 UDB, common communication, sqlccGetIPCs, probe:20
RETCODE : ZRC=0x83000005=-2097151995

2013-03-04-05.36.20.606000-300 I34199100H350 LEVEL: Severe
PID : 2416 TID : 2832 PROC : db2syscs.exe
INSTANCE: DB2 NODE : 000
FUNCTION: DB2 UDB, trace services, sqlt_logerr_data, probe:0
MESSAGE : User ID
DATA #1 : Hexdump, 4 bytes
0x02B7FAC0 : 0000 0000 ....

2013-03-04-05.36.20.606000-300 I34199452H466 LEVEL: Severe
PID : 2856 TID : 3032 PROC : db2fmp.exe
INSTANCE: DB2 NODE : 000
FUNCTION: DB2 UDB, DRDA Communication Manager, sqljcCommConnect, probe:10
MESSAGE : ZRC=0x82360001=-2110390271=SQLJC_ERROR_ICE "SYSTEM ERROR"
DIA8532C An internal processing error has occurred.
DATA #1 : String, 11 bytes
CCI Error:
DATA #2 : unsigned integer, 4 bytes
81
************************************************** ************************************************** ***********

When I have tried to connect to the respective database from db2control center am gettting the below error.

************************************************** ************************************************** ***********
A system error (reason code = "") occurred. Subsequent SQL
statements cannot be processed. SQLSTATE=58005

Explanation:

A system error occurred.

User Response:

Record the message number (SQLCODE) and reason code in the
message.

If trace was active, invoke the Independent Trace Facility at
the operating system command prompt. Then contact your technical
service representative with the following information:

o Problem description

o SQLCODE and embedded reason code

o SQLCA contents if possible

o Trace file if possible.

Federated system users: isolate the problem to the data source
failing the request (refer to the problem determination guide to
determine which data source is failing to process the SQL
statement) and take the necessary diagnostic steps for that data
source. The problem determination procedures for data sources
vary, so refer to the applicable data source manuals.

sqlcode : -902

sqlstate : 58005
************************************************** ************************************************** ***********

What could be the issue. Pls help on this.


Thanks in Advance.

[HeLP] Movie Ticket Booking System

$
0
0
I have been assigned a project (Movie ticket booking system) in ASP.NET.
I have designed the front end in visual studio as it was quite easy.
I am stuck with the database.
If anyone of you over here is having the database for this particular project or any database of ticket booking system .. please give it to me . As i am need for this.
Thanks. :-)
Your help will change my grades in college :-) :beer:

Do we have a dedicated part of Forum for DB2 on zOS?

$
0
0
Hi,

I'm quite new to this site, though registered quite a while back but could not surf here much -- I'm from zoS background and mainly look for the zOS (mainframes) related thread for DB2. However, I think, there is no dedicated section for zOS on DB2 here. Did I miss something very obvious. Please assist.

SQL Code for QUERY on DataBase

$
0
0
Dear all,


I have build a stand alone application using Java that processes text of my interest in some way that for now is irelevant.

What I want to do know is the following, when I have a new string of text to be processed I first need to search whether this string exists in my Database. If it does then no processing will have to be made to that string. If it does not exist then my application will have to process the string and add a new entry to the data base table.

This SQL code then will be implemented in Eclipse and my java app to manage.

An example in order to make things more clear.

Lets say that we have the string "dog"

I need to search for this string in the table of the database (all columns).
- If there is no "dog" entry then do some processing and store the string in the DB.
- If there is a "dog" found in the DB then proceed to the next string, for example "cat" and do the same for all the new entries that I have to check on whether or not are present in my DB.

I am using DBVisualizer pro to make some tests of my own but this are not so promising for now :)


Any help appreciated!

cheers

Vertical lines on a report not growing

$
0
0
Thanks for viewing my post!
I adapted the code below from MS Support to create 4 vertical lines in the detail section of my report. I need these 4 lines to extend the length of detail section.

The bottom is report footer section, which I need to sum - not a page footer. The lines need to meet the report footer.........which has a set position from the top of the page.

This code creates the 4 lines, but height is only as high as the records. Detail section is set to Can Grow.
Need some help with another set of eyes on this to see what I am missing.....appreciate whatever input you can provide!

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Me.ScaleMode = 1
Me.ForeColor = 0
Me.Line (1.5417 * 1440, 0)-(1.5417 * 1440, 14400), vbRed
Me.Line (4.6667 * 1440, 0)-(4.6667 * 1440, 14400), vbRed
Me.Line (6.4583 * 1440, 0)-(6.4583 * 1440, 14400), vbRed
Me.Line (8.25 * 1440, 0)-(8.25 * 1440, 14400), vbRed


End Sub

Private Sub Report_Open(Cancel As Integer)

DoCmd.Maximize

End Sub

Private Sub Report_Page()

If Me.Page <> 1 Then

Me.ScaleMode = 1
Me.ForeColor = 0
Me.Line (1.5417 * 1440, 0)-(1.5417 * 1440, 14400), vbRed
Me.Line (4.6667 * 1440, 0)-(4.6667 * 1440, 14400), vbRed
Me.Line (6.4583 * 1440, 0)-(6.4583 * 1440, 14400), vbRed
Me.Line (8.25 * 1440, 0)-(8.25 * 1440, 14400), vbRed
End If

End Sub

Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
Call SetGrpFtrLoc(Me.Report, 6) 'Display report footer at least
'6 inches from the top of the page
Me!Label90.Visible = Not IsNull(Me!CITAX)
Me!Label92.Visible = Not IsNull(Me!CIFRT)
End Sub

Private Sub Report_Close()
DoCmd.Restore
End Sub

DB2 Streamline Import Process

$
0
0
New to the forum and DB2 first and foremost.

I'm looking for some advice on how to streamline CSV imports into a DB2 10 DB. We have buckets of data coming to us in the form of CSV or XLS and we convert them, strip out the formatting and import them into DB2. The problem is we have a couple people doing this and the fields in the CSV file need to be formatted just right for it to work. We've had issues where the file will corrupt the table and we need to restore.

We also have run into an issue where the import that was done needs to be additive instead of a replacement of data and the person forgot to uncheck the replace data icon.

I'm far from an expert with DB2 but is there a common practice for dealing with data the way we're receiving it and process it into our DB?

Thanks in advance.

Macro to Find Data in Another Sheet

$
0
0
I have Sheet1 with Column A being a list of all US ZipCodes.

Sheet2 has Column A listing out only the zipcodes where we have sales and Column B has the amount of sales in that zip code.

Ideally, here's what I want it to do:
I want it to select A2 on Sheet1
Search for that term on Sheet2
If it doesn't exist on Sheet2, place a "0" in B2, then automatically move on to A3 and continue the process
If it does exist in Column A on Sheet 2 - select the cell to the right of the result (Column B)
Then paste that cell's contents in B2 on Sheet 1
Then continue until ALL of column A on Sheet1 has been searched for on Sheet2.


I have tried tons of macros, but they don't seem to work because not all of the zip codes in Column A Sheet1 exist in Sheet2...

Here's one the one I've been using... it only works for about 5 lines before it comes up with an error... ANY HELP would be greatly appreciated. It's frustrating not being able to figure it out :/ I really don't want the MsgBox to pop up at all...



Sub abc()
'
' abc Macro
'
'Keyboard Shortcut: Ctrl+b

Do Until IsEmpty(ActiveCell)
Dim MyString As String
MyString = ActiveCell
Sheets("Sheet2").Select
Set RangeObj = Cells.Find(What:=MyString, After:=ActiveCell, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
If RangeObj Is Nothing Then MsgBox "Not Found" Else: RangeObj.Select
ActiveCell.Offset(0, 1).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1").Select
ActiveCell.Offset(0, 1).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(-1, -1).Select
Loop
End Sub

Please let me know what I'm doing wrong

Question about Best Practice - Table/Column Relations

$
0
0
I’m building a new fairly complex project and I want to ensure the infrastructure I'm putting together follows the "best practice" for the type of solution I’m designing.

My quandary revolves around the design of a system that utilizes time stamp / event / source of data entries.

For example (keeping things simple), I have Table A, which is designed to keep track of "Comments". Traditionally, I would store the AccountID, DateTime, and other common columns within this table; however, my project is log-intensive. All key events (of taking an action) are properly logged, and those events have the AccountID, DateTime, etc. embedded in them; so if I have a log system that stores that information (e.g. AccountID, DateTime, EventType, etc.). As such, the same details in Table A (AccountID, etc) become redundant/duplicate.

I figured omitting the AccountID and DateTime, etc. from the Comments table was the way to go as I could JOIN any queries of the comments to the logs that match to obtain the AccountID.

But am I overanalyzing this? Should I store AccountID, DataTime, etc. in the comment table itself in the event there’s data degradation and treat the event table as a separate thing? Or is the act of needing to JOIN an event table (which will be very large) in order to obtain standard query information too burdensome?

Keeping in mind adjustments and history changes are a part of this as well. What if the person updates the comment 3 times? The event system tracks that.

What are the best practice techniques for something like this? Granted I can make it work either way; the question is once a system like this is being hit by thousands of users at a time (if not more), what system is the best route to go considering the duplicate/time issues?

Thanks!

Need help with modifying VBA Select statement

$
0
0
I have the following code (behind a form tab) to locate records that match 1 or more of the parameters in the AddToWhere lines. I need to modify the AddToWhere [Look for CR] to be able to include a range of values instead of just a single value. Any help is greatly appreciated. I have enclosed the code.

Thanks

Attached Files
File Type: txt find match.txt (2.2 KB)

Is This Code Correct?

$
0
0
What im Trying to do is This

a) The form shall prompt the user to enter LanID
b) Check the T_EMPLOYEE table to see if the LanID already exist

table field= LanID
form field=UserID


Private Sub Form_Load()

Dim rst As DAO.Recordset
Dim rst1 As DAO.Recordset
Dim rst2 As DAO.Recordset
Dim rst3 As DAO.Recordset

' Set the variables to the current database in use and tables
Set db = CurrentDb()
Set rst = db.OpenRecordset("NRCEmployees")
Set rst1 = db.OpenRecordset("T_EMPLOYEE")
Set rst2 = db.OpenRecordset("T_EMPLOYEE_INFO")

Dim strMsg As String
Dim strLANID As String
Dim strSQL As String

strMsg = "Enter Employee's LanID"
strLANID = InputBox(Prompt:=strMsg)
Debug.Print strLANID
With rst1
strSQL = "Select * From rst1 where LanID = " & Me!UserID
Debug.Print strSQL
DoCmd****nSQL strSQL
If Not .NoMatch Then 'we found the record
MsgBox "We found the record"
!Me.UserID = LanID
End If
End With


rst.Close
rst1.Close
rst2.Close
End Sub




If not How Should i write The strSQL statement

Cardinals from around

$
0
0

The Vatican says the

$
0
0

first day of the conclave

$
0
0
On the first day of the conclave, one voting session will be held: on other days the cardinals will vote twice in the morning and twice in the afternoon. If a second ballot must be taken immediately, the first bundle of ballots and any private notes are burned with the second. The cardinals chosen to be scrutineers are responsible for burning the ballots, with help from the secretary of the College of Cardinals and masters of ceremonies, who are allowed to enter the chapel after voting has concluded.

Watch Oz The Great And Powerful Movie | Watch Jack the Giant Slayer Movie | Watch Django Unchained Movie | Watch 21 and Over Movie | Watch A Good Day to Die Hard Movie | Watch Breaking Dawn Part 2 Online | Watch Identity Thief Movie | Watch Snitch Movie | Watch Dead Man Down Movie | Watch The Last Exorcism Part 2 Movie | Watch Warm Bodies Movie | Watch Silver Linings Playbook Movie | Watch Side Effects Movie | Download Oz The Great And Powerful Movie | Download Jack the Giant Slayer Movie | Download The Last Exorcism 2 Movie | Download Warm Bodies Movie | Download Dead Man Down Movie | Download Identity Thief Movie | Download Safe Haven Movie | Download A Good Day to Die Hard Movie | Pretty Little Liars Season 3 Episode 23 | Pretty Little Liars Season 3 Episode 23 | Walking Dead Season 3 Episode 13 | Walking Dead Season 3 Episode 13 | Psych Season 7 Episode 3 | Workaholics Season 3 Episode 19
_____

Query to run against Date Columns

$
0
0
What are some good querys to run against a sample table of dates and items where the results can be used for charts?

Here is the sample table.


Code:

CREATE TABLE [dbo].[TestDates](
        [ItemId] [int] IDENTITY(1,1) NOT NULL,
        [AssignmentName] [nvarchar](max) NULL,
        [AssignedDate] [date] NULL,
        [DueDate] [date] NULL,
        [PId] [int] NULL,
        [FullName] [nvarchar](max) NULL,
        [OpenDate] [date] NULL,
        [CloseDate] [date] NULL,
        [Status] [nvarchar](max) NULL,
 CONSTRAINT [PK_TestDates] PRIMARY KEY CLUSTERED
(
        [ItemId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO




Code:

INSERT INTO [TestDates]([AssignmentName], [AssignedDate], [DueDate], [PId], [FullName], [OpenDate], [CloseDate], [Status])
        VALUES('Finish Reports', '2013-02-18 00:00:00', '2013-02-19 00:00:00', 1, 'Jeff Hunter      ', '2013-02-18 00:00:00', '2013-02-19 00:00:00', 'Closed');

INSERT INTO [TestDates]([AssignmentName], [AssignedDate], [DueDate], [PId], [FullName], [OpenDate], [CloseDate], [Status])
        VALUES('Error Reports', '2013-02-15 00:00:00', '2013-03-29 00:00:00', 2, 'Henry Hanks', '2013-02-19 00:00:00', NULL, 'InProgress');

INSERT INTO [TestDates]([AssignmentName], [AssignedDate], [DueDate], [PId], [FullName], [OpenDate], [CloseDate], [Status])
        VALUES('Check Dates', '2013-02-15 00:00:00', '2013-02-28 00:00:00', 3, 'Pat Franks', '2013-02-25 00:00:00', NULL, 'Done');

INSERT INTO [TestDates]([AssignmentName], [AssignedDate], [DueDate], [PId], [FullName], [OpenDate], [CloseDate], [Status])
        VALUES('Read Drafts', '2013-03-08 00:00:00', '2013-03-30 00:00:00', 4, 'Nancy Belkin', '2013-03-09 00:00:00', NULL, 'Open');

INSERT INTO [TestDates]([AssignmentName], [AssignedDate], [DueDate], [PId], [FullName], [OpenDate], [CloseDate], [Status])
        VALUES('Finish Reports', '2013-02-18 00:00:00', '2013-02-19 00:00:00', 2, 'Henry Hanks', '2013-02-18 00:00:00', '2013-02-19 00:00:00', 'Closed');

INSERT INTO [TestDates]([AssignmentName], [AssignedDate], [DueDate], [PId], [FullName], [OpenDate], [CloseDate], [Status])
        VALUES('Error Reports', '2013-02-15 00:00:00', '2013-03-29 00:00:00', 3, 'Pat Franks', '2013-03-02 00:00:00', NULL, 'InProgress');

INSERT INTO [TestDates]([AssignmentName], [AssignedDate], [DueDate], [PId], [FullName], [OpenDate], [CloseDate], [Status])
        VALUES('Check Dates', '2013-02-15 00:00:00', '2013-02-28 00:00:00', 4, 'Nancy Belkin', '2013-02-15 00:00:00', NULL, 'Done');

INSERT INTO [TestDates]([AssignmentName], [AssignedDate], [DueDate], [PId], [FullName], [OpenDate], [CloseDate], [Status])
        VALUES('Read Drafts', '2013-03-08 00:00:00', '2013-03-30 00:00:00', 1, 'Jeff Hunter      ', '2013-03-12 00:00:00', NULL, 'Open');

INSERT INTO [TestDates]([AssignmentName], [AssignedDate], [DueDate], [PId], [FullName], [OpenDate], [CloseDate], [Status])
        VALUES('Check Dates', '2013-02-15 00:00:00', '2013-02-28 00:00:00', 1, 'Jeff Hunter      ', '2013-02-15 00:00:00', NULL, 'Done');

INSERT INTO [TestDates]([AssignmentName], [AssignedDate], [DueDate], [PId], [FullName], [OpenDate], [CloseDate], [Status])
        VALUES('Read Drafts', '2013-03-08 00:00:00', '2013-03-30 00:00:00', 2, 'Henry Hanks', '2013-03-08 00:00:00', NULL, 'Open');

INSERT INTO [TestDates]([AssignmentName], [AssignedDate], [DueDate], [PId], [FullName], [OpenDate], [CloseDate], [Status])
        VALUES('Finish Reports', '2013-02-18 00:00:00', '2013-02-19 00:00:00', 3, 'Pat Franks', '2013-02-18 00:00:00', '2013-02-19 00:00:00', 'Closed');

I have some results where I am using the datediff

like

Code:

select
DATEDIFF(DD,[AssignedDate],[OpenDate]) As Days,
DATEDIFF(wk,[AssignedDate],[OpenDate]) As Weeks,
DATEDIFF(MM,[AssignedDate],[OpenDate]) As Months

,[ItemId]
,[AssignmentName]
,[PId]
,[FullName]
,[Status]


From TestDates

DB2 encrypt function/java preparedStatement error

$
0
0
I'm trying to use the DB2 encrypt function with a java preparedStatement and receive the error "[FMWGEN][DB2 JDBC Driver][DB2]Character data, right truncation occurred; for example, an update or insert value is a string that is too long for the column ..."

DB2 Table :
column1 varchar(24000)

DB2 driver used : db2jcc4.jar

SQL statement is in the form of :
String sqlStr = "update tableName set column1 = encrypt(?, ?) where column2 = ?"

ps = con.preparedStatement(sqlStr);
ps.setString(1, inputStr);
ps.setString(2, password);
ps.setString(3, varName);
ps.executeUpdate();

This only works when the inputStr is 250 chars or less, even though the DB column length is 24000.
The query also works if I just use the sqlStr as : (a concatination string)
String sqlStr = "update tableName set column1 = encrypt('"+inputStr+"', '"+password+"') where column2 = '" + varName "'"
without the use of setString, but this can allow sql injection and don't really see a reason why setString should not work.
Any help would be appreciated.
thanks.

INSERT INTO SELECT issue

$
0
0
I have a scenario where in i should achieve the below.

if (bonusflag=FALSE)
insert into emp_sal select emp_no , no_of_hours*60 as emp_sal from emp
where no_of_hours = 4

IF(bonusflag=TRUE)
insert into emp_sal select emp_no , (no_of_hours*60) + 5000 as emp_sal from emp where emp_no >100 and no_of_hours > 6

Now, while doing the same thru pl/sql can you help me how to write the code as we can not use execute immediate because the above queries will return more than 1 row.

Thanks..
Viewing all 13329 articles
Browse latest View live


Latest Images