|
So have you tried different date formats, I would try 'yyyy-mm-dd' as the second most unambiguous format, you have tried the first, Oracle may not like characters in the data and spits the dummy.
Note this is not a solution, just another avenue to try. I have not used Oracle in a decade or more.Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks for the comments.
A little more to understand the problem, I'v found that the error message was because of the returned type boolean (@RetVal).
-- oracle implementation
--======================
CREATE OR REPLACE FUNCTION TEST_ERP_INSERT (
P_SOURCE_CODE IN VARCHAR2
, P_SOURCE_LINE_ID IN NUMBER
, P_TRANSACTION_NUMBER IN VARCHAR2
, P_FEEDER_ITEM_CODE IN VARCHAR2
, P_SALES_PRICE IN NUMBER
, P_FEEDER_ORGANIZATION_CODE IN VARCHAR2
, P_FEEDER_SUBINVENTORY_CODE IN VARCHAR2
, P_TRANSACTION_QUANTITY IN NUMBER
, P_TRANSACTION_DATE IN VARCHAR2
, P_FEEDER_TRANSACTION_TYPE IN VARCHAR2
, P_FEEDER_TRANSFER_SUBINV_CODE IN VARCHAR2
, p_errmesg OUT VARCHAR2
)
RETURN BOOLEAN
IS
BEGIN
RETURN 1;
--
EXCEPTION
--
WHEN OTHERS
THEN
--
p_errmesg := 'Error:'
|| SQLERRM;
--
RETURN 0;
END;
-- calling from sql server
--========================
DECLARE @ErrMsg VARCHAR(1000)
DECLARE @RetVal SMALLINT
EXEC ('BEGIN ? := TEST_ERP_INSERT(?,?,?,?,?,?,?,?,?,?,?,?);END;', @RetVal,'SSP-SALES', 8728, '15059', 'SSP1032', 12,'S', 'S-SALES', 1, '13/MAR/2010', 'S-SALES_ISSUE', '', @ErrMsg OUTPUT) AT ERPUSTG;
Any idea? I can't change the returned type because its a different system.The Phantom.
|
|
|
|
|
Sample datamodel for marketing promotion
|
|
|
|
|
And your question is?
I will take mercy on you and supply this link [^]to a message on this page.Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Look Here[^] I don't speak Idiot - please talk slowly and clearly
'This space for rent'
Driven to the arms of Heineken by the wife
|
|
|
|
|
Hi,
I Wonder if it possible to retrieve from an SQL server a recored plus its 5 recored before anf after.
for example: When I search a product with serial-number "100" i would like to retrieve 11 recorods from serial-number "095" until "105", of course after a "ORDER BY" statement of the serial-number field
|
|
|
|
|
???
WHERE ID BETWEEN 95 AND 105
depending on the database the limit values will or will not be included (then change to 94 AND 106)
|
|
|
|
|
where serial-number between (100-5) and (100+5)
order by seriual-number
Does that do the trick? Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
|
|
|
|
|
Thanks.
But this could be a good solution when querying a numeric field , my main problem is when querying a varchar field like product descriptions
|
|
|
|
|
Assuming that your description field is unique:
SELECT table.*
FROM table,(
SELECT id
FROM table
WHERE description = 'whatever'
) temp
WHERE table.id BETWEEN (temp.id - 5) AND (temp.id + 5) "When did ignorance become a point of view" - Dilbert
|
|
|
|
|
thanks.
this is an excelent solutions but when a few descriptions are 'whatever' is will appear a few times....
|
|
|
|
|
Oh come on! Do you want someone to right it for you? You have more than enough to figure out the rest on your own. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
ok, i am just climbing down the tree...
|
|
|
|
|
Wheres that spoon icon? Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I have three primary tables:
CustomerMaster
ContactMaster
AddressList
Each customer master has a one to many relationship with contacts.
Each contact has a possible 1:1 relationship with the AddressList. (ie. null addresses ok)
Each address in the AddressList has a 1:1 relationship with CityEnumerators and StateEnumerators.
I'm trying to get a view working that shows all contacts that are active whose CustomerMaster record is active. Unfortunately I only get the contacts that have addresses and not the ones without addresses. I thought the following query would do it....but no go. (BTW also tried RIGHT OUTER JOIN with no luck also)
Any help would be appreciated as to what I'm doing that is screwing the pooch.
SELECT TOP (100) PERCENT dbo.CustomerMaster.BSACustomerKey, dbo.ContactMaster.ContactName, dbo.ContactMaster.BusinessPhone, dbo.ContactMaster.MobilePhone,
dbo.ContactMaster.Email, dbo.ContactMaster.FirstName, dbo.ContactMaster.LastName, dbo.ContactMaster.EmergencyMaintenance,
dbo.ContactMaster.NormalMaintenance, dbo.ContactMaster.NetworkAbuse, dbo.ContactMaster.IssuedSwipeCard, dbo.ContactMaster.CardNumber,
dbo.AddressList.CustomerAddressLine1, dbo.AddressList.CustomerAddressLine2, dbo.AddressList.CustomerAddressLine3, dbo.AddressList.CustomerPostBox,
dbo.CityEnumerator.City, dbo.StateEnumerator.State, dbo.AddressList.CustomerCounty, dbo.AddressList.CustomerCountry, dbo.AddressList.CustomerZipcode,
dbo.ContactMaster.BmcCustKey
FROM dbo.ContactMaster INNER JOIN
dbo.CustomerMaster ON dbo.ContactMaster.CompanyID = dbo.CustomerMaster.CustomerIdentity LEFT OUTER JOIN
dbo.AddressList ON dbo.ContactMaster.ContactAddress = dbo.AddressList.AddressIdentity INNER JOIN
dbo.CityEnumerator ON dbo.AddressList.CustomerCity = dbo.CityEnumerator.CityIdentity INNER JOIN
dbo.StateEnumerator ON dbo.AddressList.CustomerStateorProvince = dbo.StateEnumerator.StateIdentity
WHERE (dbo.CustomerMaster.CustomerStatus = 1) AND (dbo.ContactMaster.Status = 1)
ORDER BY dbo.CustomerMaster.BSACustomerKey
|
|
|
|
|
Try changing the 2 inner joins after the left join to outer joins.
Remove the order by to your calling method, this gets rid of the top 100% as well.Never underestimate the power of human stupidity
RAH
|
|
|
|
|
This is my latest attempt and I still am not getting contacts who do not have addresses:
SELECT TOP (100) PERCENT dbo.CustomerMaster.BSACustomerKey, dbo.ContactMaster.ContactName, dbo.ContactMaster.BusinessPhone, dbo.ContactMaster.MobilePhone,
dbo.ContactMaster.Email, dbo.ContactMaster.FirstName, dbo.ContactMaster.LastName, dbo.ContactMaster.EmergencyMaintenance,
dbo.ContactMaster.NormalMaintenance, dbo.ContactMaster.NetworkAbuse, dbo.ContactMaster.IssuedSwipeCard, dbo.ContactMaster.CardNumber,
dbo.AddressList.CustomerAddressLine1, dbo.AddressList.CustomerAddressLine2, dbo.AddressList.CustomerAddressLine3, dbo.AddressList.CustomerPostBox,
dbo.CityEnumerator.City, dbo.StateEnumerator.State, dbo.AddressList.CustomerCounty, dbo.AddressList.CustomerCountry, dbo.AddressList.CustomerZipcode,
dbo.ContactMaster.BmcCustKey
FROM dbo.ContactMaster INNER JOIN
dbo.CustomerMaster ON dbo.ContactMaster.CompanyID = dbo.CustomerMaster.CustomerIdentity RIGHT OUTER JOIN
dbo.AddressList ON dbo.ContactMaster.ContactAddress = dbo.AddressList.AddressIdentity LEFT OUTER JOIN
dbo.CityEnumerator ON dbo.AddressList.CustomerCity = dbo.CityEnumerator.CityIdentity LEFT OUTER JOIN
dbo.StateEnumerator ON dbo.AddressList.CustomerStateorProvince = dbo.StateEnumerator.StateIdentity
WHERE (dbo.CustomerMaster.CustomerStatus = 1) AND (dbo.ContactMaster.Status = 1)
ORDER BY dbo.CustomerMaster.BSACustomerKey
|
|
|
|
|
Did you even bother to read the previous answer from Mycroft?
SELECT dbo.CustomerMaster.BSACustomerKey,
dbo.ContactMaster.ContactName,
dbo.ContactMaster.BusinessPhone,
dbo.ContactMaster.MobilePhone,
dbo.ContactMaster.Email,
dbo.ContactMaster.FirstName,
dbo.ContactMaster.LastName,
dbo.ContactMaster.EmergencyMaintenance,
dbo.ContactMaster.NormalMaintenance,
dbo.ContactMaster.NetworkAbuse,
dbo.ContactMaster.IssuedSwipeCard,
dbo.ContactMaster.CardNumber,
dbo.AddressList.CustomerAddressLine1,
dbo.AddressList.CustomerAddressLine2,
dbo.AddressList.CustomerAddressLine3,
dbo.AddressList.CustomerPostBox,
dbo.CityEnumerator.City,
dbo.StateEnumerator.State,
dbo.AddressList.CustomerCounty,
dbo.AddressList.CustomerCountry,
dbo.AddressList.CustomerZipcode,
dbo.ContactMaster.BmcCustKey
FROM dbo.ContactMaster
INNER JOIN dbo.CustomerMaster
ON dbo.ContactMaster.CompanyID = dbo.CustomerMaster.CustomerIdentity
LEFT OUTER JOIN dbo.AddressList
ON dbo.ContactMaster.ContactAddress = dbo.AddressList.AddressIdentity
LEFT OUTER JOIN dbo.CityEnumerator
ON dbo.AddressList.CustomerCity = dbo.CityEnumerator.CityIdentity
LEFT OUTER JOIN dbo.StateEnumerator
ON dbo.AddressList.CustomerStateorProvince = dbo.StateEnumerator.StateIdentity
WHERE dbo.CustomerMaster.CustomerStatus = 1
AND dbo.ContactMaster.Status = 1
ORDER BY dbo.CustomerMaster.BSACustomerKey ASC
|
|
|
|
|
I have a stored procedure that is used with a Search form we have. Search form has about 15 parameters it can take, all optional.
The database is a mess and im stuck working around it so bare with me while I try to explain my issue. There are more issues but want to focus on the Buyer/Seller issue for now.
The long and short of my problem is this - the data entry form has fields for { Buyer First Name, Buyer Last Name, Seller First Name, Seller Last Name}
These will be inserted into table BuyerSeller (for instance)
The schema for this:
BuyerSellerID | FirstName | LastName
this table is holds both Buyer and Seller information. So what we end up with is:
<br />
BuyerSellerID | FirstName | LastName<br><br />
100 | BuyerFirst | BuyerLast<br><br />
101 | SellerFirst | SellerLast<br />
But now the issue comes into play when he created an index lookup table called BuyerSellerInfo that includes:
<br />
BuyerorSellerInfoID (primary key) | MortgageID | BuyerID | SellerID<br />
What the original developer did was put the Buyer information as one record, and the Seller information in another record, each for the same data entry.
so we end up with:
<br />
BuyerorSellerInfoID (primary key) | MortgageID | BuyerID | SellerID <Br><br />
1 | 10 | 1 | NULL<br><br />
2 | 10 | NULL | 2<br />
So now with my question - how can I create a stored procedure that will produce results in the same row. I am getting duplicates for each row (which I know the way it is setup I would). But is there a way in my Stored Procedure to have the output look like:
<br />
BuyerorSellerInfoID (primary key) | MortgageID | BuyerID | SellerID<br><br />
1 | 10 | 1 | 2<br />
Hope this made sense, question me if it does not. The formatting on my code tags didn't go so well the "|" is seperator for columns.
The database is SQL 2000 as well.
Thanks.modified on Friday, March 12, 2010 4:02 PM
|
|
|
|
|
I'm no DB expert, however I would search along these lines:
SELECT * FROM BuyersSellers AS b JOIN BuyersSellers AS s WHERE b.MortgageID=s.MortgageID AND b.BuyerID IS NOT NULL AND s.SellerID IS NOT NULL
|
|
|
|
|
Thank you for the quick reply. I will give it a test and give feedback or mark as answer.
|
|
|
|
|
Swelborn wrote: so bare with me while I try to explain
Have you been reading The Nudist On The Nightshift? Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
hehe can't say that I have.
|
|
|
|
|
I want to select all values from @table1 that doesn't exist in @table2 , for that see the below scenario and the query, although i get the correct result but i doesn't understand how query is evaluated , I know the concept of left join but how where is evaluated , i can't understand ?
Is query is evaluating like this
1 from @table1 & 1 from @table2
then , 1=1 and t2.id is null = 1=1 and false= no rows.
now , suppose
2 from @table1 and 1 from @table2
then , 2=1 and t2.id is null = 2=1 and false = no rows , according to me but here it is giving 2,
IS Where condition applies only to those rows that are equal in both table.
Please help me ?
DECLARE @Table1 TABLE
(
ID INT
)
INSERT @Table1
SELECT 1 UNION ALL
SELECT 2 UNION ALL
SELECT 3 UNION ALL
SELECT 4 UNION ALL
SELECT 5 UNION ALL
SELECT 6 UNION ALL
SELECT 7
DECLARE @Table2 TABLE
(
ID INT
)
INSERT @Table2
SELECT 1 UNION ALL
SELECT 3 UNION ALL
SELECT 4 UNION ALL
SELECT 5 UNION ALL
SELECT 7 UNION ALL
SELECT NULL
SELECT t1.ID
FROM @Table1 AS t1
LEFT JOIN @Table2 AS t2
ON t1.ID = t2.ID
WHERE t2.ID is null
|
|
|
|
|
From SQL Server books online, you may want to spend some time looking through it;
Inner joins (the typical join operation, which uses some comparison operator like = or <>). These include equi-joins and natural joins.
Inner joins use a comparison operator to match rows from two tables based on the values in common columns from each table. For example, retrieving all rows where the student identification number is the same in both the students and courses tables.
Outer joins are specified with one of the following sets of keywords when they are specified in the FROM clause:
LEFT JOIN or LEFT OUTER JOIN
The result set of a left outer join includes all the rows from the left table specified in the LEFT OUTER clause, not just the ones in which the joined columns match. When a row in the left table has no matching rows in the right table, the associated result set row contains null values for all select list columns coming from the right table.
RIGHT JOIN or RIGHT OUTER JOIN
A right outer join is the reverse of a left outer join. All rows from the right table are returned. Null values are returned for the left table any time a right table row has no matching row in the left table.
FULL JOIN or FULL OUTER JOIN
A full outer join returns all rows in both the left and right tables. Any time a row has no match in the other table, the select list columns from the other table contain null values. When there is a match between the tables, the entire result set row contains data values from the base tables.
|
|
|
|
|