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

need help linking SQL server and oracle databases

$
0
0
I have a some SQL and Oracle databases that I need to be able to join and query across. I need a tool that will facilitate this easily and preferably free. For example database 1 has multiple sql 2008 tables but I want Cust_info table and the field meter and then in the oracle database I need the meteraccts table and the meternumber field...which are the joiner fields. I am having trouble find something that will do this easily...I have down loaded..dbvisualizer, anysqlmaestro, oracle developer..etc These will let me see the different databases but not query both...or at least I can't see how. Any help with a tool or with a sql syntax would be appreciated. I have tried to link the databases and join them but I'm missing something. Thanks

need help linking SQL server and oracle databases

$
0
0
I have a some SQL and Oracle databases that I need to be able to join and query across. I need a tool that will facilitate this easily and preferably free. For example database 1 has multiple sql 2008 tables but I want Cust_info table and the field meter and then in the oracle database I need the meteraccts table and the meternumber field...which are the joiner fields. I am having trouble find something that will do this easily...I have down loaded..dbvisualizer, anysqlmaestro, oracle developer..etc These will let me see the different databases but not query both...or at least I can't see how. Any help with a tool or with a sql syntax would be appreciated. I have tried to link the databases and join them but I'm missing something. Thanks

Dealing with addresses

$
0
0
Creating a database where the customer can have a home and a site address but these are mostly the same. How do I go about copying the home address into the site address fields? Have looked everywhere and find nothing. Look forward to the discussion. Cheers

better way rewrite this Update statement?

$
0
0
There are million records that match following 3 updates. I was wondering if there is a better way to re-write the following 3?

----------------------------------
-----Update statement # 1
----------------------------------

MERGE INTO SCHEMA.Table T
USING (SELECT
S1.CUSTNO
,S1.SURR_KEY
FROM SCHEMA.SOURCE1 S1
INNER JOIN
SCHEMA.SOURCE2 S2
ON S2.SURR_KEY_2 = S1.SURR_KEY_2
WHERE S2.AREA_CD = 967
AND S1.STATUS = 'ACTIVE'
) s
ON (T.CUST_NO = s.CUST_NO)
AND T.LOCATION IN ('NA','EUR','ASIA')

WHEN MATCHED THEN
UPDATE SET
T.C1 = S1.SURR_KEY

WITH UR;

----------------------------------
-----Update statement # 2
----------------------------------

MERGE INTO SCHEMA.Table T
USING (SELECT
S1.CUSTNO
,S1.SURR_KEY
FROM SCHEMA.SOURCE1 S1
INNER JOIN
SCHEMA.SOURCE2 S2
ON S2.SURR_KEY_2 = S1.SURR_KEY_2
WHERE S2.AREA_CD = 967
AND S1.LAST_LOGIN_LOCTN = 'NEW YORK' -- Difference is here from above select query
) s
ON (T.CUST_NO = s.CUST_NO)
AND T.LOCATION IN ('NA','EUR','ASIA')

WHEN MATCHED THEN
UPDATE SET
T.C2 = S1.SURR_KEY --target table is same but different target column is updated here with same source Key becasue source key may have different value

WITH UR;

--------------------------------
-----Update statement # 3
-- Before Update#1 all T.C1, T.C2 are 0. LAST Update statement to set all the remaining values that did not match in #1 and #2 to 9999.
----------------------------------



UPDATE SCHEMA.Table T
SET T.C1 = 9999
,T.C2 = 9999
WHERE
T.C1 = 0
AND T.C2 = 0 ;

Need help converting the following PL SQL code to T SQL code

$
0
0
Hi , Can someone please help me convert the PL SQL code below into a MSSQL code? Thanks in advance.

create or replace
FUNCTION JULIAN_TO_DATE ("JULIAN_DATE" IN NUMBER, "TIME_OF_DAY" IN NUMBER DEFAULT null) RETURN DATE DETERMINISTIC IS
--initialize variables here
l_date_ch varchar2(6) := null;
l_date_time varchar2(13) := null;

l_century number := 0;
l_year number := 0;
l_days number := 0;
l_time_hours number := 0;
l_time_minutes number := 0;
l_time_seconds number := 0;

-- main body
BEGIN

IF julian_date = 0 or julian_date is null
THEN
return null;
END IF;

l_date_ch := lpad(nvl(to_char(julian_date), '0'), 6, '0');

IF substr(l_date_ch, 1, 1) = '1'
THEN

l_century := 20;

ELSIF substr(l_date_ch, 1, 1) = '0'
THEN

l_century := 19;

ELSE
l_century := 21;

END IF;

l_year := to_number(substr(l_date_ch, 2, 2));

l_days := to_number(substr(l_date_ch, 4, 3));

l_time_hours := to_number(substr(lpad(nvl(to_char(time_of_day), '0'), 6, '0'), 1, 2));
l_time_minutes := to_number(substr(lpad(nvl(to_char(time_of_day), '0'), 6, '0'), 3, 2));
l_time_seconds := to_number(substr(lpad(nvl(to_char(time_of_day), '0'), 6, '0'), 5, 2));

-- Check values of the time parameter and re-set as necessary. JDE sends crap sometimes.

IF l_time_seconds >= 60
THEN

l_time_seconds := mod(l_time_seconds, 60);
l_time_minutes := l_time_minutes + 1; -- increment the minute if over 60 seconds

END IF;

IF l_time_minutes >= 60
THEN

l_time_minutes := mod(l_time_minutes, 60);
l_time_hours := l_time_hours + 1; -- increment the hour if over 60 minutes

END IF;

IF l_time_hours >= 24
THEN

l_time_hours := 0;
l_days := l_days + 1; -- increment the days if over 24 hours

END IF;

IF l_days > 366
THEN

l_days := '001';
l_year := l_year + 1;

ELSIF (l_days > 365) and (mod(l_year, 4) > 0)
THEN

l_days := 001;
l_year := l_year + 1;

END IF;

l_date_time := to_char(l_century) ||
lpad(to_char(l_year), 2, '0') ||
lpad(to_char(l_days), 3, '0') ||
lpad(to_char(l_time_hours), 2, '0') ||
lpad(to_char(l_time_minutes), 2, '0') ||
lpad(to_char(l_time_seconds), 2, '0');

return to_date(l_date_time, 'rrrrdddhh24miss');

EXCEPTION
WHEN OTHERS THEN
NULL; -- enter any exception code here
RETURN NULL;
END;

hellloooo!!

$
0
0
Hey friends! I dont know how i came here but forums looks really nice and vibrant. Having good time here and hope to have the same everyday. :)

Need Help:Basic Inventory System

$
0
0
Hello
I am using MS Access 2007 to develop inventory system .I created 3 tables details are given below
table 01: Products: (s.no , keyboard,mouse,agp,lcd)
table 02 Purchase_Order (S.no , date, supplier ,product,quantity,rate,amount)
table 03 Suppliers : (s.no , sup01 ,sup 02 , sup 03)
Purchase order form created via table (purchase_order)
i need help to select product which i purchased while entering data in form . how can i do it ?

fetching multilanguage data by stored procedure

$
0
0
Can we fetch the the data of chinese or some other language using stored procedure in db2??? please help me out

The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries

$
0
0
Hi everyone

I am trying to use order by but I am getting the error in the title.

The data I am pulling is correct I just cant figure out how to order by the last 8 numbers that is my NUMBER column. I tried adding FOR XML AUTO to my last line in my query :

From AP_DETAIL_REG where AP_BATCH_ID = 1212 and NUMBER is not null order by NUMBER FOR XML AUTO) as Temp(DATA) where DATA is not null

but no change same error.
Output:
1234567890000043321092513 00050020

Select DATA from(
select '12345678'+
left( '0', 10-len(cast ( CONVERT(int,( INV_AMT *100)) as varchar))) +
cast (CONVERT(int,(INV_AMT*100)) as varchar) +
left('0',2-len(CAST (MONTH(DATE) as varchar(2))))+
CAST (MONTH(DATE) as varchar(2)) +
left('0',2-len(CAST (day(CHECK_DATE) as varchar(2)))) +
CAST (day(DATE) as varchar(2))+right(cast
(year(DATE)
as nvarchar(4)),2)+' 0'+cast (NUMBER as varchar) +
right(SPACE(37),37-LEN(cast (NUMBER as varchar) )) as 'DATA'
From AP_DETAIL_REG where AP_ID = 1212 and NUMBER is not null

UNION ALL
select '12345678'+left( '0', 10-len(cast (convert(varchar, COUNT(*)) as varchar))) +
cast (convert(varchar, COUNT(*)) as varchar)+left( '0', 10-len(cast ( CONVERT(int,(sum(INV_AM)*100)) as varchar))) +
cast (CONVERT(int,(sum(INV_AM)*100)) as varchar) as 'DATA'
From AP_DETAIL_REG where AP_ID = 1212 and NUMBER is not null ) as Temp where DATA is not null


Thank you for your help!

HOLDING SHIFT key to open Access 2000 appl vs 2010?

$
0
0
Hello All,

I wrote a small application (DB) for a friend many years ago and they would like me to migrate it to 2010 and make changes. I was able to convert it to 2010, but I don't know how to open it in edit mode?

Like I said, it has been YEARS since i looked at it and I know when I want to edit it, i hold the SHIFT key to get into the area where I can edit the report and code, etc. But in 2010, the SHIFT key does nothing. How do I open the application in Edit mode in 2010?

Also, how do I find that place where you set the up to call a Form upon open? I am only slightly familiar with 2010 so there is a learning curve here to make these modifications.

Thanks for any help!
Jennifer

Help with Entity Relationship Diagram for museum

$
0
0
Hello, I am a student and I was assigned to create my first entity relationship diagram and I'm kind of lost. The professor hints the paintings should be broken into a generalization hierarchy since they have so many attributes but I can only break them into two sub(entities) based on my understanding of G.H.(using the "is a" rule)

Anyway I'm struggling with that and finding the weak entity(professor also hinted that there is a week entity)

I attached what I have so far as ERD1.pdf (didn't establish relationship type/participation constraints yet)

Am I even on the right track/have the right idea?

The prompt is below:

The BestArt museum, which owns several millions artifacts, has asked you to do the conceptual design of a database for the following information requirements.

The only artifacts of the museum in its database will be paintings. Each painting is uniquely identified by an artifact number. Data about each painting include a name, year completed, year acquired by the museum, estimated value, and a “school” (e.g. Cubism). Each painting was created by one painter, although the painters of some paintings are unknown. Due to shortage of exhibit rooms, the least valuable paintings are kept for long period of time in storage rooms, whereas the most valuable ones are shown in exhibit rooms. A room is identified by a unique room number and has a size (in square feet).

Some of the BestArt paintings may be on loan to allied museums, typically for several months. BestArt may also have temporary possession of paintings loaned to it by allied museums. They are shown in exhibit rooms alongside BestArt paintings, typically for several months. Each allied museum has a unique name, a city, a state, and a curator (with whom BestArt negotiates loans). Paintings loaned to BestArt or by BestArt will also be in the database and will have the same attributes as the paintings owned by BestArt, plus a return date

Customers of BestArt consist of members and non-members. Members may be VIP or regular members. VIP may be benefactors and/or docents. Benefactors have a level (e.g., silver, gold, …). There is an expiration date for regular members. A docent may have one or several specialties, such as cubism and impressionism. A docent may volunteer to be present at certain dates and times in a specific room to explain the room paintings to visitors. In honor of a painting loaned to BestArt, there may be one or several gala-nights at different dates, with invitations to some benefactors. BestArt also organizes art-nights. An art-night will involve a discussion about one painter by one docent. A date and time is specified. Non-members who wish to attend art-nights are required to register in advance. A museum room may or may not be specified for an art-night.

The following data is assumed for all persons in the database: a unique id, a name, sex, year of birth, year of death (when applies), country of birth.

what I consider to be his hints
2. As discussed in class concerning the qualities of an ERD, completeness is more important than simplicity. For example, if the information requirements describe in some length different categories of PAINTINGs, with different relationships to other entities, maybe that tells you if your ERD should have a single entity or a Generalization Hierarchy.

3. Do not spend too much time in trying to identify early on a weak entity and an associative entity, if you have trouble with them. Good GH and relationships come first. (you can still get an A, albeit with a slightly lower score, without the correct weak entity and associative entity).

Thanks in advance to anyone who can help!

Attached Files
File Type: pdf ERD2.pdf (106.4 KB)

DB2 Index Hell - 140 Million rows

$
0
0
Hi, I have spent all day coming up with an index strategy to this problem. We have a table of about 140 million rows - each row has a CREATE_TS and STATUS. The STATUS is NULL initially but it will change as we process records. There are about 4 different statuses.

I want to be able to get to documents based on timestamp and status. Here are the 4 scenarios. All queries are run with OPTIMIZE FOR 1000 ROWS
1. WHERE STATUS IS NULL ORDER BY CREATED_TS ASC
2. WHERE STATUS IS NULL AND CREATED_TS > timestamp(...) ORDER BY CREATED_TS ASC
3. WHERE STATUS = 'XXX' AND CREATED_TS < timestamp(...) ORDER BY CREATED_TS ASC
4. WHERE STATUS = 'XXX' AND CREATED_TS < timestamp(...) AND CREATED_TS > timestamp(...) ORDER BY CREATED_TS ASC


Attempt 1: Composite Index (STATUS, CREATED_TS)
DB2 refused to use this index atleast initially (maybe because STATUS column has low cardinality?)

Attempt 2: Composite Index (CREATED_TS, STATUS)
This index is being user by all queries - Query 1 performs well, Query 3 performs very slow even though there are no rows returned. Is this because it is sorting by CREATED_TS and then scanning all the rows until it found the records with a particular STATUS? I feel like this can get worse once the statuses change and we are looking for a particular STATUS.

Attempt 3: Two separate indexes one on STATUS and one on CREATED_TS
Surprisingly, Query 1 took forever to return.

Any suggestions appreciated.
Thanks

Which tools to use? All have problems I can't resolve (yet)

$
0
0
I am building a Product Management system, well trying...

Tools Available:
- 2010 SharePoint Online: I'm pretty good with forms and list setup
- MS Access: I'm ok with form and query basics. Relationship setup.
- MySQL Workbench: It's available to house data, but I am totally clueless

Tool Requirements:
Accessible worldwide to on-network employees using SharePoint or some kind of web interface (PHP?)

Allow over 5000 part numbers
- SP Online 2010 has 5000 row limit which I can't adjust.

Allow Parent-Child relationships (many to many)
- For any given part number (Column-1) I may need to assign numerous Part Numbers to a "Where Used" Column-C (SP need diff list, Access can query same table).

Allow query & submit with various tables/lists
- SharePoint/InfoPath only submits to one list
- MS Access can submit to multiple, but user access/aesthetics/Coding are issues.


What combination of tools should I pursue as a newb?
Store Data: SQL, MS Access, or SP List? I don't think batch updates will work for this project.

The Connections: SP list "Lookup", InfoPath, MS Access, or other?

To Access/Submit changes: InfoPath form, MS Access Form, PHP, other?

Client Application Performance

$
0
0
I'm a C# programmer writing an app for work. It's a client app(not web) that will connect to an AWS server via ADO.NET. The server is a large RDS and as I do some testing on my own it works well 1 second or less response time for 1M rows. My concern is the performance if 100 users get connected.

If any one has any experience with this let me know what you think.

Thanks
Randy.

How do I create a query that populates a combo box?

$
0
0
I am new to Access and have been tasked with creating a simple database for work.

Using Access 2007.

Searched the forums and seem to have found complicated details for combo boxes that are out of the scope of what my simple database will need.

I have a table with 3 fields, Badge#, Last, and First name.

--on the form...

I want to be able to select the last name of a person entering a server room.

Saving combo box selections after a form is closed

$
0
0
Hi all,

I have exhausted my efforts to no avail. I would really appreciate your guys help on this one!

I have a main form called frmAF54. In this main form I have a subform named frmPassdown. The subform record source is from a table called tblCards. This table contains many different cards. I have a combobox called lstOpCard in the main form as well. The combobox lists all of the different cards in "tblCards". I have a button called "buttonFilter".

A user opens the form and clicks (or selects) the different cards in the combo box "lstOpCard" that they want to filter for. Once their selections are made, they can click the "buttonFilter" button and the subform "frmPassdown" will be filtered based off of their selections.

The filter is applied using the IN() function as shown below:
Me.AF54PassDown.Form.Filter = "[OpCardID] IN ( " & sTemp & " )" --sTemp is a string containing the keyIDs of the cards selected.

My problem is that people will be opening and closing the form throughout the day / week. When the form closes, it loses the applied filter. How can I have my filter on the subform be saved after the form is closed and the filter is still applied when the form is opened later?

Your help is very much appreciated!! If you need any additional information, please let me know. Providing code will be a huge help to me as well as I am new to access.

Thank you,

I m having some confusion in connecting oralce 11g Xe

$
0
0
what is the concept of the following , and why it si used

1. $ system / nolog
2. sys as sysdba
3. / as sysdba
4. connect system

What is best way to recover deleted SQL files from Windows PC hard disk?

$
0
0
I accidentally deleted MSSQL database record of my project from Windows PC hard disk. It’s very important for me. Without that record i can't start my project. I need help to recover my project database which was stored on Windows computer system.
Guys,
Suggest me any solution...:(

select query result set

$
0
0
Hi,
I just want the common rows(FIRST_NO) which are in

PL_PLA ='BBB' AND PL_PLA='CCC'

which should not in other PL_PLA rows

DB2 9.1 Z/OS

Code:


SELECT
 T1.PL_PLA
,T1.FIRST_NO
,T1.FLT_SHT

FROM BASE_TABLE T1

WHERE

T1.PL_PLA in ('BBB','CCC')




BASE TABLE

PL_PLA FIRST_NO FLT_SHT
R23    322      IEMC
1EE    444      FDDD 
AAA    111      QQQQ
AAA    222      WWWW
BBB    111      REEE
BBB    222      WSQQ
BBB    333      EWDG
CCC    111      EEDD
CCC    222      EWDQ
CCC    444      UKCL
DDD    111      DDDD
DDD    222      VVVV
EEE    111      EWEW
 
ACTUAL RESULT SET GETTING

PL_PLA FIRST_NO FLT_SHT
BBB    111      REEE
BBB    222      WSQQ
BBB    333      EWDG
CCC    111      EEDD
CCC    222      EWDQ
CCC    444      UKCL
EXPECTED RESULT SET

PL_PLA FIRST_NO FLT_SHT

BBB    111      REEE
BBB    222      WSQQ
CCC    111      EEDD
CCC    222      EWDQ


Thanks,

Subselect in a query with like hint

$
0
0
Hi,
I´m a spanish oracle developer, my question is..
¿Is possible to use like hint with subselect? , i mean i want to find all rows in table A that contains a word in a field(CALLED CONTENT) in table B, concretely in a field called content too, i show you the idea although the syntax is incorrect.

select
' + char (39) + @country + char (39) + ' as PAIS,
A.ID,
A.IDUSUARIO MSISDN,
NULL AS MSISDN_COD,
convert(char(19),A.FECHA_ALVENTO, 121) AS FECHA_MO_LOCAL,
NULL AS FECHA_MO_LOCAL_D,
NULL AS FECHA_MO,
NULL AS FECHA_MO_D
from ' + @bdhist + '..ZED_MO_HIST as A
where (A.FECHA_ALVENTO >= '+ char(39) + @last_load_date + char(39) + ' and
A.FECHA_ALVENTO < dateadd(dd,+6,'+ char(39) + @last_load_date + char(39) + '))
and a.CODE=41
AND A.CONTENT LIKE (SELECT %CONTENT_FIELD_FROM_TABLE_B%)'

¿Could you please help me with that?
Regards.
Eloy.
Viewing all 13329 articles
Browse latest View live