473,385 Members | 1,661 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problem with a query

I have the following query :

DECLARE
tmp INTEGER;

BEGIN
tmp := 1;
DBMS_OUTPUT.PUT_LINE(tmp);
INSERT INTO WT_PTFMGT
(SESSION_ID,TYPE,L, R, C,GBL_INSTRUMENT_ID,COM,L_HOLDING, R_HOLDING, C_HOLDING)
SELECT
tmp,
'BO' TYPE,
DECODE(L_INSTRUMENT_ID,NULL,'N','Y') L,
DECODE(R_INSTRUMENT_ID,NULL,'N','Y') R,
DECODE(C_INSTRUMENT_ID,NULL,'N','Y') C,
NVL(L_INSTRUMENT_ID, NVL(R_INSTRUMENT_ID,C_INSTRUMENT_ID)) GBL_INSTRUMENT_ID,
(DECODE(L_COMMENTS,NULL,0,1) + DECODE(R_COMMENTS,NULL,0,1) + DECODE (C_COMMENTS,NULL,0,1)) COM,
L_QUANTITY L_HOLDING,
R_QUANTITY R_HOLDING,
C_QUANTITY C_HOLDING
FROM
(SELECT * FROM
(SELECT INSTRUMENT_ID C_INSTRUMENT_ID, QUANTITY C_QUANTITY, COMMENTS C_COMMENTS,
TYPE C_TYPE, HOLDING_ID C_HOLDING_ID FROM WT_HOLDINGFUSION WHERE TYPE = 'C' AND SESSION_ID = tmp)
FULL OUTER JOIN
(SELECT INSTRUMENT_ID R_INSTRUMENT_ID, QUANTITY R_QUANTITY, COMMENTS R_COMMENTS,
TYPE R_TYPE, HOLDING_ID R_HOLDING_ID FROM WT_HOLDINGFUSION WHERE TYPE = 'R' AND SESSION_ID = tmp)
ON R_INSTRUMENT_ID = C_INSTRUMENT_ID
FULL OUTER JOIN
(SELECT INSTRUMENT_ID L_INSTRUMENT_ID, QUANTITY L_QUANTITY, COMMENTS L_COMMENTS,
TYPE L_TYPE, HOLDING_ID L_HOLDING_ID FROM WT_HOLDINGFUSION WHERE TYPE = 'L' AND SESSION_ID = tmp)
ON L_INSTRUMENT_ID = C_INSTRUMENT_ID OR L_INSTRUMENT_ID = R_INSTRUMENT_ID);
END;

If I execute it, I get the error 'INVALID NUMBER'.
If I change the tmp into 1, it works fine.
The problem is that I do need the tmp, as the number can vary.
I've tried to use the TO_NUMBER, but then i get 'Missing right parenthesis'

Can anyone help me?
Thanks.
May 10 '06 #1
0 1049

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Brian Oster | last post by:
After applying security patch MS03-031 (Sql server ver 8.00.818) a query that used to execute in under 2 seconds, now takes over 8 Minutes to complete. Any ideas on what the heck might be going...
8
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
4
by: Apple | last post by:
1. I want to create an autonumber, my requirement is : 2005/0001 (Year/autonumber), which year & autonumber no. both can auto run. 2. I had create a query by making relation to a table & query,...
6
by: lenny | last post by:
Hi, I've been trying to use a Sub or Function in VBA to connect to a database, make a query and return the recordset that results from the query. The connection to the database and the query...
3
by: StBond | last post by:
Hi everyone, I am new to Access and Visual Basic so things my be getting across a bit cloudy. I only started using VB for one week. I am having a little problem with the database that I am...
3
by: Andy_Khosravi | last post by:
I have been trying to build a user friendly search engine for a small database I have created. I'm having some particular problems with one of my date fields. Here's the setup: I'm using...
20
by: Development - multi.art.studio | last post by:
Hello everyone, i just upgraded my old postgres-database from version 7.1 to 7.4.2. i dumped out my 7.1 database (with pg_dump from 7.1) as an sql-file with copy-commands and to one file using...
0
by: mjsterz | last post by:
I've been working with VB .NET for less than a year and this is the first time I've posted on one of these groups, so let me apologize beforehand if I'm being unclear, not posting my issue...
3
by: Juan Antonio Villa | last post by:
Hello, I'm having a problem replicating a simple database using the binary log replication, here is the problem: When the master sends an update to the slave, an example update reads as follows:...
9
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.