how can i unit 3 sql query to one query? [message #323453] |
Wed, 28 May 2008 09:00 |
lioracle
Messages: 68 Registered: February 2008 Location: Israel
|
Member |
|
|
this is the querys:
INSERT INTO SAPR3.ZMOBLOG (id,CardName, InDateTime, CLI, SqlId, UserId)
VALUES ((SELECT max(ID)+1 FROM SAPR3.ZMOBLOG ) ,'Tech',
(select to_char (sysdate, 'DD-MM-YYYY HH24:MI:SS') as "Current Time" from dual), #SubscriberID ,146, 0)
SELECT VORNA AS Name, PERNR AS ID, TO_NUMBER(PERNR) AS sID, LGORT AS Whs FROM SAPR3.ZTECH WHERE SUBSTR(TELNR,-7,7) = SUBSTR('#SubscriberID',-7,7) AND MANDT = '$vClient'
UPDATE SAPR3.ZMOBLOG SET SAPR3.ZMOBLOG.OutDateTime = (select to_char (sysdate, 'DD-MM-YYYY HH24:MI:SS') as "Current Time" from dual)
WHERE (ID = (SELECT max(ID) FROM SAPR3.ZMOBLOG WHERE (cli ='#SubscriberID' AND cardname = 'Tech' )))
instead of runing them one after one
i want to run all of them in once.
thanks
|
|
|
|
|
|
Re: how can i unit 3 sql query to one query? [message #323461 is a reply to message #323453] |
Wed, 28 May 2008 09:08 |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
lioracle wrote on Wed, 28 May 2008 10:00 |
INSERT INTO SAPR3.ZMOBLOG (id,CardName, InDateTime, CLI, SqlId, UserId)
VALUES ((SELECT max(ID)+1 FROM SAPR3.ZMOBLOG ) ,'Tech',
(select to_char (sysdate, 'DD-MM-YYYY HH24:MI:SS') as "Current Time" from dual), #SubscriberID ,146, 0)
|
Are you really storing DATEs as a VARCHAR2?
Quote: |
SELECT VORNA AS Name, PERNR AS ID, TO_NUMBER(PERNR) AS sID, LGORT AS Whs FROM SAPR3.ZTECH WHERE SUBSTR(TELNR,-7,7) = SUBSTR('#SubscriberID',-7,7) AND MANDT = '$vClient'
|
SUBSTR('#SubscriberID',-7,7) cann be replaced by hardcoded 'riberID'
|
|
|
|
|
|
|
|
|
Re: how can i unit 3 sql query to one query? [message #323490 is a reply to message #323488] |
Wed, 28 May 2008 10:31 |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
What are you trying to achieve?
You want to be able to run these three SQL at once.
- Do you need to do this from SQL*Plus
- Do you need to do this from some sort of GUI front end (Forms, VB etc)
- Do you need to be able to do this from another process running in the database?
Tell us more about what you're trying to d, and we may be able to help you.
|
|
|
|
Re: how can i unit 3 sql query to one query? [message #323493 is a reply to message #323491] |
Wed, 28 May 2008 10:35 |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
Create a file called (eg) my_code.sql.
Copy and paste all three queries into that file, making sure that there is a trailing ';' after each query.
Save the file.
for the sake of argument, we'll assume you've saved it in the directory c:\sql
From SQL*Plus, you can run the contents of this file by typeing the command:
|
|
|