Dab tsi yog ua tiav tam sim hauv PL SQL?
Dab tsi yog ua tiav tam sim hauv PL SQL?

Video: Dab tsi yog ua tiav tam sim hauv PL SQL?

Video: Dab tsi yog ua tiav tam sim hauv PL SQL?
Video: Data Science with Python! Analyzing File Types from Avro to Stata 2024, Kaum ib hlis
Anonim

EXECUTE IMMEDIATE Nqe lus. Cov EXECUTE IMMEDIATE nqe lus executes dynamic SQL ntawv nqe lus los yog tsis qhia npe PL / SQL ntawv thaiv. Koj tuaj yeem siv nws los teeb tsa SQL ntawv nqe lus uas tsis tuaj yeem sawv cev ncaj qha rau hauv PL / SQL ntawv , los yog tsim cov nqe lus uas koj tsis paub tag nrho cov npe ntawm lub rooj, WHERE clauses, thiab lwm yam ua ntej.

Tsis tas li lo lus nug yog, dab tsi yog ua tiav tam sim hauv SQL?

Cov EXECUTE IMMEDIATE nqe lus npaj (parses) thiab tam sim ntawd executes ib tug dynamic SQL ntawv nqe lus los yog tsis qhia npe PL/ SQL ntawv thaiv. Lub ntsiab lus sib cav rau EXECUTE IMMEDIATE yog txoj hlua uas muaj cov SQL ntawv nqe lus rau ua . Koj tuaj yeem tsim txoj hlua siv concatenation, lossis siv txoj hlua uas tau hais tseg.

Tsis tas li ntawd, peb puas xav tau kev cog lus tom qab ua tiav tam sim? cog lus tsis tas yuav tom qab txhua EXECUTE IMMEDIATE . Tej lus hais ua TSIS TAU xav tau a cog lus ; piv, if koj truncate lub rooj nrog TRUNCATE. Tag nrho cov haujlwm uas tsis tau ua tiav hauv qhov kev hloov pauv tam sim no tau cog lus los yog dov rov qab - tsis yog nqe lus xwb raug tua los ntawm EXECUTE IMMEDIATE.

Tsis tas li cov lus nug yog, vim li cas peb thiaj li siv tau tam sim ntawd hauv Oracle?

EXECUTE IMMEDIATE pab kev ua tiav ntawm DML lossis DDL nqe lus uas yog tuav raws li txoj hlua thiab tsuas yog ntsuas ntawm lub sijhawm ua haujlwm. Qhov no ua rau ib tus tuaj yeem tsim cov lus hais raws li kev ua haujlwm logic. EXECUTE IMMEDIATE kuj yog tib txoj kev uas koj ua tau ua DDL hauv ib PL / SQL thaiv.

Yuav ua li cas tsim lub rooj siv ua tiav tam sim hauv Oracle?

  1. Kauj Ruam 1: Npaj koj DDL ua ntej.
  2. Kauj ruam 2: Khiav koj DDL los ntawm PL / SQL program siv Execute tam sim.
  3. Ua ntej: Ib txwm kaw koj cov lus SQL rau hauv ib khub ntawm Ib Leeg Quotes.
  4. Thib ob: Saib xyuas Semi-colon.

Pom zoo: