Home » SQL & PL/SQL » SQL & PL/SQL » HELP TO FORM DYNAMIC INSERT QUERY IN PL/SQL
HELP TO FORM DYNAMIC INSERT QUERY IN PL/SQL [message #650679] Fri, 29 April 2016 07:15 Go to next message
ibnelyas
Messages: 5
Registered: October 2015
Junior Member
hi all..

currently am trying to read a file and insert data into a table..

Am attaching the my pl/sql which is working fine..
i would like to simplify my code as mentioned in the commented line as shown below.. pls help

-- values (AUTOID.NEXTVAL , v_newline ,SYSDATE ) -- CAN THIS CODE WORK

bear with my question if meaningless or so simple..
Re: HELP TO FORM DYNAMIC INSERT QUERY IN PL/SQL [message #650681 is a reply to message #650679] Fri, 29 April 2016 07:21 Go to previous messageGo to next message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
I don't understand what you are asking. Does your code work? It looks OK to me.
Re: HELP TO FORM DYNAMIC INSERT QUERY IN PL/SQL [message #650682 is a reply to message #650681] Fri, 29 April 2016 07:38 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
So to be clear you want to know if this insert:
      INSERT INTO temp_sap_charges
                  (auto_chrg_seq, chrg_code, chrg_description, gl_code,
                   created_date
                  )
           VALUES (auto_id.NEXTVAL, chrgcode, chrgdesc, glcode,
                   SYSDATE
                  );

Can be changed to this:
      INSERT INTO temp_sap_charges
                  (auto_chrg_seq, chrg_code, chrg_description, gl_code,
                   created_date
                  )
           values (AUTOID.NEXTVAL , v_newline  ,SYSDATE );

Where v_newline holds the comma seperated values for chrg_code, chrg_description and gl_code.

No, you can't, unless you make the insert an actual dynamic sql statement. And I see no benefit to doing that what so ever.
Your code is fine as it is.

[Updated on: Fri, 29 April 2016 08:06]

Report message to a moderator

Re: HELP TO FORM DYNAMIC INSERT QUERY IN PL/SQL [message #650683 is a reply to message #650679] Fri, 29 April 2016 07:44 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
SQL statement must be static, known & fixed at compile time.
Re: HELP TO FORM DYNAMIC INSERT QUERY IN PL/SQL [message #650751 is a reply to message #650683] Tue, 03 May 2016 01:53 Go to previous message
muhammadadnan198@gmail.co
Messages: 2
Registered: May 2016
Location: Pakistan
Junior Member

hi dear
where you want to put this values in Temporary Combo Box or Table
(values (AUTOID.NEXTVAL , v_newline ,SYSDATE ) -- CAN THIS CODE WORK)

muhammadadnan198@gmail.com
Previous Topic: Unable to get values from associative arrays into a different procedure
Next Topic: SQL Query to fetch not matching records
Goto Forum:
  


Current Time: Thu Apr 25 04:19:16 CDT 2024