Doubt: consultation with the insertion, and updated? eh possible?

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
  

Poston Mon, 06 Feb 2006 2:07 pm

Eae guys, good ... was giving a peek at the forum and thought muito bom ... hehe and I took advantage to post a question to you guys ...

Here's the deal.
For example I have the table of employees and another of dependetes..
I want to get the dependents that has the name \"Jacob\" and insert them as staff in the staff ... has as!?!??!
how you could do that?

vlw ... If it was a little confusing, eheh posta again I explain a little better?
xShinmi
Location: Presidente Prudente

Poston Mon, 06 Feb 2006 2:23 pm

How is the table of Employee and dependents?

Gives a DESC for guys:-)
dr_gori
Location: Portland, OR USA

Thomas F. G

Você já respondeu a dúvida de alguém hoje?
http://glufke.net/oracle/search.php?search_id=unanswered

Poston Mon, 06 Feb 2006 2:30 pm

good:).. It was actually an analogy ... porque é actually far more complex than that hehe!!!

Good so here goes ... I'll explain the way está ... here in the company has a bank agent where are registered the \"lots\" that would be the land of the houses ... and in each batch logically ta joined 1 or more address!!! That's why I wanted to get the lots that are registered with more than one address, create a new batch, and play this address in this batch. do in my hand one by one I can do it, but what I wanted to do a function, é to find all batches that have + 1 address create a batch automatically and play to address this new batch ... thus leaving all lots with only 1 address ... There goes the desc of tables: where lot_face would be the batch and address the address
Code: Select all
lot_face:
Name                                      Null?    Type
----------------------------------------- -------- ----------------------------
FEAT_NUM                                  NOT NULL NUMBER(10)
G_VERSION                                 NOT NULL NUMBER(10)
G_NEXT_VERSION                                     NUMBER(10)
G_GENERATION                                       NUMBER(10)
CENTER_LINE_FNUM                          NOT NULL NUMBER(10)
LOT_ID                                             NUMBER(10)
LOT_TYPE                                  NOT NULL NUMBER(1)
NUM                                                VARCHAR2(35)
NUM_QTY                                            NUMBER(3)
FEEDER_POINT                              NOT NULL NUMBER(1)
ZIP                                                VARCHAR2(10)
ATTENDANCE                                         NUMBER(1)
REFERENCE_NAME                                     VARCHAR2(60)
REFERENCE_TYPE                                     NUMBER(10)

address:
Name                                      Null?    Type
----------------------------------------- -------- ----------------------------
ID                                        NOT NULL NUMBER(10)
LOT_FACE_FNUM                                      NUMBER(10)
STREET_ID                                 NOT NULL NUMBER(10)
SPECIAL_ADR_FNUM                                   NUMBER(10)
ADDR_TYPE                                          NUMBER(1)
NUM                                       NOT NULL VARCHAR2(35)
COMPL                                              VARCHAR2(35)
DEDICATED                                          NUMBER(1)
ROW_LOCK                                           NUMBER(10)
ROW_LOCK_TYPE                                      VARCHAR2(1)
G_VERSION                                 NOT NULL NUMBER(10)
G_NEXT_VERSION                                     NUMBER(10)
G_GENERATION                                       NUMBER(10)
heheheh é that aí ... If you need d + something tamoe aí!
xShinmi
Location: Presidente Prudente

Poston Mon, 13 Feb 2006 3:00 pm

Dae galera ...
Well, for the record só I can do what I want ... I don't know if you guys understood qualquer I was wanting but ... I thank I can still doing this ... I made a function in it I declared a cursor, the query that I wanted after I was giving an insert according to the information I had at the cursor ... fuizzz vlwww
xShinmi
Location: Presidente Prudente

Poston Mon, 13 Feb 2006 4:13 pm

I think you can do the INSERT straight: see, for example:
Code: Select all
INSERT
INTO TABELA1
( CAMPO1
, CAMPO2
, CAMPO3
)
(SELECT
  X.CAMPOX1
, X.CAMPOX2
, X.NOME
FROM OUTRA_TABELA X
WHERE NOME LIKE 'JOAO%'
)
/
thus he makes first the select, and inserts all in Table1. Without having to do a routine to it. (Sorry, didn't get it right your doubt...)


You can also use the MERGE, for INSERT and UPDATE at the same time. (if there is, make update, if does not exist, INSERT). See this thread: http://www.glufke.net/oracle/viewtopic.php?t=305:-
dr_gori
Location: Portland, OR USA

Thomas F. G

Você já respondeu a dúvida de alguém hoje?
http://glufke.net/oracle/search.php?search_id=unanswered

Poston Tue, 14 Feb 2006 10:58 pm

our dr_gori this information was valiosissima ...!!!
Hey now that I started messing with sql in oracle ... There's a lot of to do ... muito bomm!!!
Vlw EEAA!!!
more tips are always welcome!!
xShinmi
Location: Presidente Prudente


  • See also
    Replies
    Views
    Last Post


    Return to SQL

    Who is online

    Users browsing this forum: No registered users and 3 guests