Yuav ua li cas thaum nyob hauv PostgreSQL?
Yuav ua li cas thaum nyob hauv PostgreSQL?

Video: Yuav ua li cas thaum nyob hauv PostgreSQL?

Video: Yuav ua li cas thaum nyob hauv PostgreSQL?
Video: thaum nyob nruab hlis yuav ua li ca tsev me nyuam thiaj tsis poob qi 2024, Kaum ib hlis
Anonim

Cov THAUM loop statement executes ib block ntawm nqe lus mus txog thaum ib yam kev ntsuas ntsuas rau cuav. Hauv THAUM lus teb, PostgreSQL ntsuas qhov xwm txheej ua ntej ua tiav qhov thaiv cov lus. Yog tias qhov xwm txheej muaj tseeb, qhov thaiv ntawm cov lus tau raug tua mus txog thaum nws yog ntsuas rau qhov tsis tseeb.

Cov lus nug tseem yog, ua dab tsi hauv PostgreSQL?

Nws yog teem los ntawm txhua yam ntawm cov nqe lus hauv qab no: A SELECT INTO nqe lus teev pom tseeb yog tias ib kab raug muab, cuav yog tsis muaj kab rov qab. A Ua haujlwm nqe lus teev pom tseeb yog tias nws tsim (thiab muab pov tseg) ib lossis ntau kab, cuav yog tsis muaj kab tsim.

ua thaiv Postgres? DO executes anonymous code thaiv , los yog nyob rau hauv lwm yam lus ib ntus tsis qhia npe ua haujlwm nyob rau hauv lus txheej txheem. Cov cai thaiv yog kho raws li nws yog lub cev ntawm ib tug muaj nuj nqi uas tsis muaj parameters, rov qab void. Nws yog parsed thiab tua ib zaug.

Tsis tas li ntawd, kuv yuav sau li cas yog cov nqe lus hauv PostgreSQL?

Cov IF nqe lus yog ib feem ntawm cov txheej txheem txheej txheem PL/pgSQL. Koj yuav tsum tsim kom muaj nuj nqi lossis ua tiav qhov ad-hoc nqe lus nrog cov lus txib DO. Koj xav tau ib tug; thaum kawg ntawm txhua nqe lus hauv plpgsql (tshwj tsis yog qhov kawg END). Koj xav tau END IF ; thaum kawg ntawm IF nqe lus.

Kuv yuav ua haujlwm li cas hauv Greenplum?

Kev siv cov haujlwm thiab SELECT nqe lus rau ua haujlwm yog tus qauv hauv PL / pgSQL ib vim tag nrho kev ua haujlwm hauv a PostgreSQL database yuav tsum xa rov qab tus nqi ntawm qee hom. Siv PERFORM lo lus tseem ceeb rau hu a muaj nuj nqi thiab tsis quav ntsej nws cov ntaub ntawv rov qab. Piv txwv 11-50 qhia cov syntax ntawm PERFORM lo lus tseem ceeb.

Pom zoo: