Advertisement
alvinfnaldi

Database PostgreSQL

Sep 21st, 2023
1,367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --database eproduct
  2.  
  3. create table users (
  4.     id serial primary key,
  5.     username varchar(100),
  6.     password text,
  7.     createdAt timestamp not null default current_timestamp,
  8.     updatedAt timestamp not null default current_timestamp
  9. )
  10.  
  11. create table customer (
  12.     id serial primary key,
  13.     first_name varchar(100),
  14.     last_name varchar(100),
  15.     user_id int references users(id),
  16.     createdAt timestamp not null default current_timestamp,
  17.     updatedAt timestamp not null default current_timestamp
  18. )
  19.  
  20. create table orders (
  21.     id serial primary key,
  22.     user_id int references users(id),
  23.     total_product int,
  24.     total_price numeric,
  25.     createdAt timestamp not null default current_timestamp,
  26.     updatedAt timestamp not null default current_timestamp
  27. )
  28.  
  29. create table product_category (
  30.     id serial primary key,
  31.     name varchar(100),
  32.     description varchar(200),
  33.     createdAt timestamp not null default current_timestamp,
  34.     updatedAt timestamp not null default current_timestamp
  35. )
  36.  
  37. create table products (
  38.     id serial primary key,
  39.     nama varchar(100),
  40.     description varchar(200),
  41.     category_id int references product_category(id),
  42.     price numeric,
  43.     image varchar(200),
  44.     createdAt timestamp not null default current_timestamp,
  45.     updatedAt timestamp not null default current_timestamp
  46. )
  47.  
  48. create table order_detail (
  49.     id serial primary key,
  50.     order_id int references orders(id),
  51.     product_id int references products(id),
  52.     quantity int,
  53.     createdAt timestamp not null default current_timestamp,
  54.     updatedAt timestamp not null default current_timestamp
  55. );
  56.  
  57.  
  58. --database rentaldvd
  59.  
  60. --1
  61. create table category (
  62.     category_id serial primary key,
  63.     name varchar(100),
  64.     last_update timestamp not null default current_timestamp
  65. )
  66.  
  67. --2
  68. create table actor (
  69.     actor_id serial primary key,
  70.     first_name varchar(100),
  71.     last_name varchar(100),
  72.     last_update timestamp not null default current_timestamp
  73. )
  74.  
  75. --3
  76. create table country (
  77.     country_id serial primary key,
  78.     country varchar(100),
  79.     last_update timestamp not null default current_timestamp
  80. )
  81.  
  82. --4
  83. create table language (
  84.     language_id serial primary key,
  85.     name varchar(100),
  86.     last_update timestamp not null default current_timestamp
  87. )
  88.  
  89. --5
  90. create table film (
  91.     film_id serial primary key,
  92.     title varchar(255),
  93.     description text,
  94.     release_year int,
  95.     language_id int references language,
  96.     rental_duration int,
  97.     rental_rate int,
  98.     length int,
  99.     replacement_cost numeric,
  100.     rating numeric,
  101.     last_update timestamp not null default current_timestamp,
  102.     special_features varchar(100),
  103.     fulltext text
  104. )
  105.  
  106. --6
  107. create table film_actor (
  108.     actor_id int references actor,
  109.     film_id int references film,
  110.     last_update timestamp not null default current_timestamp,
  111.     primary key(actor_id, film_id)
  112. )
  113.  
  114. --7
  115. create table film_category (
  116.     film_id int references film,
  117.     category_id int references category,
  118.     last_update timestamp not null default current_timestamp,
  119.     primary key(film_id, category_id)
  120. )
  121.  
  122. --8
  123. create table city (
  124.     city_id serial primary key,
  125.     city varchar(100),
  126.     country_id int references country,
  127.     last_update timestamp not null default current_timestamp
  128. )
  129.  
  130. --9
  131. create table address (
  132.     address_id serial primary key,
  133.     address varchar(255),
  134.     address2 varchar(255),
  135.     district varchar(255),
  136.     city_id int references city,
  137.     postal_code varchar(50),
  138.     phone varchar(50),
  139.     last_update timestamp not null default current_timestamp
  140. )
  141.  
  142. --10
  143. create table customer (
  144.     customer_id serial primary key,
  145.     store_id int,
  146.     first_name varchar(100),
  147.     last_name varchar(100),
  148.     email varchar(100),
  149.     address_id int references address,
  150.     activebool boolean,
  151.     create_date timestamp not null default current_timestamp,
  152.     last_update timestamp not null default current_timestamp,
  153.     active boolean
  154. )
  155.  
  156. --11
  157. create table inventory (
  158.     inventory_id serial primary key,
  159.     film_id int references film,
  160.     store_id int,
  161.     last_update timestamp not null default current_timestamp
  162. )
  163.  
  164. --12
  165. create table staff (
  166.     staff_id serial primary key,
  167.     first_name varchar(100),
  168.     last_name varchar(100),
  169.     address_id int references address,
  170.     email varchar(100),
  171.     store_id int,
  172.     active boolean,
  173.     username varchar(100),
  174.     password text,
  175.     last_update timestamp not null default current_timestamp,
  176.     picture text
  177. )
  178.  
  179. --13
  180. create table store (
  181.     store_id serial primary key,
  182.     manager_staff_id int references staff(staff_id),
  183.     address_id int references address,
  184.     last_update timestamp not null default current_timestamp
  185. )
  186.  
  187. --alter table store drop constraint store_address_id_fkey
  188. --alter table store add constraint store_address_id_fkey
  189. --foreign key (address_id) references address(address_id)
  190.  
  191. --14
  192. create table rental (
  193.     rental_id serial primary key,
  194.     rental_date date,
  195.     inventory_id int references inventory,
  196.     customer_id int references customer,
  197.     return_date date,
  198.     staff_id int references staff,
  199.     last_update timestamp not null default current_timestamp
  200. )
  201.  
  202. --15
  203. create table payment (
  204.     payment_id serial primary key,
  205.     customer_id int references customer,
  206.     staff_id int references staff,
  207.     rental_id int references rental,
  208.     amount numeric,
  209.     payment_date date
  210. )
  211.  
  212.  
  213. --database eproduct
  214.  
  215. insert into users (username, password) values
  216. ('user1', 'user1'),
  217. ('user2', 'user2'),
  218. ('user3', 'user3'),
  219. ('user4', 'user4'),
  220. ('user5', 'user5');
  221.  
  222. select * from users
  223.  
  224. insert into users (username, password)
  225. values ('user6', 'user6')
  226. returning *
  227.  
  228. insert into customer (first_name, last_name, user_id) values
  229. ('helis', 'cokro', 1),
  230. ('alvin', 'faiz', 2)
  231. returning *
  232.  
  233. select customer.first_name, customer.last_name, users.username
  234. from customer join users
  235. on users.id = customer.user_id
  236.  
  237. insert into product_category (name, description) values
  238. ('elektronik', 'barang murah'),
  239. ('makanan', 'makanan kering')
  240.  
  241. insert into product_category (name, description) values
  242. ('furniture', 'perlengkapan furniture')
  243. returning id
  244.  
  245. select * from product_category
  246.  
  247. insert into products (nama, description, category_id, price, image) values
  248. ('televisi', 'televisi samsung', 1, 2000, 'tv-img.jpg'),
  249. ('kulkas', 'kulkas 2 pintu', 1, 6000, 'kulkas-img.jpg'),
  250. ('meja', 'meja persegi panjang', 3, 4000, 'meja-img.jpg')
  251. returning *
  252.  
  253. select * from products
  254.  
  255. select name, nama, price
  256. from product_category
  257. join products
  258. on product_category.id = products.category_id
  259.  
  260. select * from orders
  261.  
  262. insert into orders (user_id, total_product, total_price) values
  263. (1, 4, 16000)
  264. delete from orders where id = 3
  265.  
  266. select * from order_detail
  267.  
  268. insert into order_detail (order_id, product_id, quantity) values
  269. (4, 1, 2),
  270. (4, 2, 2)
  271.  
  272. select customer.user_id, username, first_name, last_name, product_category.name, products.nama, quantity, price
  273. from users
  274. join customer on customer.user_id = users.id
  275. join orders on orders.user_id = users.id
  276. join order_detail on order_detail.order_id = orders.id
  277. join products on products.id = order_detail.product_id
  278. join product_category on product_category.id = products.category_id
  279. where customer.user_id = 1
  280.  
  281.  
  282. --database eproduct
  283.  
  284. --1. Menampilkan informasi customer dan accountnya (username, password) = fullname, username, password
  285. select first_name || ' ' || last_name as fullname, username, password
  286. from users
  287. join customer
  288. on customer.id = users.id
  289.  
  290. --2. Menampilkan informasi customer dan detail ordernya
  291. select first_name, last_name, p.nama, pc.name, quantity as jumlah, price from order_detail od
  292. join products p on p.id = od.product_id
  293. join product_category pc on pc.id = p.category_id
  294. join orders o on o.id = od.order_id
  295. join users u on u.id = o.user_id
  296. join customer c on c.user_id = u.id
  297.  
  298. create view customer_orders as
  299. select first_name, last_name, p.nama nama_produk, pc.name nama_kategori, quantity as jumlah, price from order_detail od
  300. join products p on p.id = od.product_id
  301. join product_category pc on pc.id = p.category_id
  302. join orders o on o.id = od.order_id
  303. join users u on u.id = o.user_id
  304. join customer c on c.user_id = u.id
  305.  
  306. select * from customer_orders
  307. drop view customer_orders
  308.  
  309. --3. Menampilkan informasi produk per category = nama category, nama produk
  310. select p.nama, pc.name
  311. from products p
  312. join product_category pc
  313. on pc.id = p.category_id
  314.  
  315. create view informasi_produk as
  316. select p.nama, pc.name
  317. from products p
  318. join product_category pc
  319. on pc.id = p.category_id
  320.  
  321. select * from informasi_produk
  322. drop view informasi_produk
  323.  
  324.  
  325. --database adventureworks
  326.  
  327. --1. Menampilkan harga dan discount setiap item product
  328. select name, listprice, discountpct
  329. from production.product
  330. join sales.specialofferproduct
  331. on sales.specialofferproduct.productid = production.product.productid
  332. join sales.specialoffer
  333. on sales.specialoffer.specialofferid = sales.specialofferproduct.specialofferid
  334.  
  335. --2. Menampilkan warna dan quantity setiap item product
  336. select color, count(name) as quantity from production.product
  337. where color is not null
  338. group by color
  339.  
  340. --3. Menampilkan harga dan discount setiap item product yang harganya di atas 120
  341. select name, listprice, discountpct
  342. from production.product
  343. join sales.specialofferproduct
  344. on sales.specialofferproduct.productid = production.product.productid
  345. join sales.specialoffer
  346. on sales.specialoffer.specialofferid = sales.specialofferproduct.specialofferid
  347. where listprice > 120
  348. order by listprice asc
  349.  
  350.  
  351. --function
  352.  
  353. --returns varchar
  354. create or replace function getUsername(userId int)
  355. returns varchar
  356. language plpgsql
  357. as
  358. $$
  359. declare
  360.     infouser varchar;
  361. begin
  362.     select username into infouser
  363.     from users
  364.     where id = userId;
  365.    
  366.     return infouser;
  367. end;
  368. $$;
  369.  
  370. drop function getUsername(int)
  371. drop function getUsername()
  372. select getUsername(4)
  373.  
  374. --
  375. create or replace function getUsername(userid int)
  376. returns users
  377. language plpgsql
  378. as
  379. $$
  380. declare
  381.     infouser users
  382. begin
  383.     select * into infouser
  384.     from users
  385.     join customer
  386.     on customer.user_id = users.id
  387.     where users.id = userid;
  388.    
  389.     if not found then
  390.         raise 'Data % tidak ditemukan', userid;
  391.         end if;
  392.    
  393.     return infouser;
  394. end;
  395. $$;
  396.  
  397. select getUsername(8)
  398.  
  399. select *
  400.     from users
  401.     join customer
  402.     on customer.user_id = users.id
  403.     where users.id = customer.id;
  404.  
  405. --
  406. create or replace function getUsername()
  407. returns table(
  408.     user_name varchar,
  409.     firstname varchar,
  410.     lastname varchar
  411. )
  412. language plpgsql
  413. as
  414. $$
  415. declare
  416.    
  417. begin
  418. return query
  419.     select username, first_name, last_name
  420.     from users join customer
  421.     on customer.user_id = users.id;
  422.    
  423.     if not found then
  424.         raise 'Data % tidak ditemukan', userid;
  425.         end if;
  426.    
  427. end;
  428. $$;
  429.  
  430. select * from getUsername()
  431. drop function getUsername()
  432.  
  433. --
  434. create or replace function getUsername()
  435. returns table(
  436.     user_name users.username%type,
  437.     firstname customer.first_name%type,
  438.     lastname customer.last_name%type
  439. )
  440. language plpgsql
  441. as
  442. $$
  443. declare
  444.     user_r record;
  445. begin
  446.     for user_r in(
  447.     select username, first_name, last_name
  448.     from users join customer
  449.     on customer.user_id = users.id
  450.     ) loop
  451.     user_name := user_r.username;
  452.     firstname := upper(user_r.first_name);
  453.     lastname := upper(user_r.last_name);
  454.     return next;
  455.     end loop;
  456.    
  457. end;
  458. $$;
  459.  
  460. select * from getUsername()
  461.  
  462.  
  463. --tanpa return
  464. create or replace function getUsername(
  465.     in username int,
  466.     out firstname varchar,
  467.     out lastname varchar
  468. )
  469.  
  470. language plpgsql
  471. as
  472. $$
  473.  
  474. begin
  475.     select firstname, lastname
  476.     into firstname, lastname
  477.     from customer
  478.     where user_id = username;
  479. end;
  480. $$;
  481.  
  482. drop function getUsername(int)
  483. select getUsername(1)
  484.  
  485.  
  486. --
  487. create or replace function getMinMax(
  488.     out min_len int,
  489.     out max_len int
  490.     )
  491. language plpgsql
  492. as
  493. $$
  494.  
  495. begin
  496.     select
  497.         min(id),
  498.         max(id)
  499.     into
  500.         min_len, max_len
  501.     from
  502.         customer;
  503. end;
  504. $$;
  505.  
  506. select * from getMinMax()
  507.  
  508. --
  509. create or replace function getUsernameCursor()
  510. returns table(
  511.     user_name varchar,
  512.     firstname varchar,
  513.     lastname varchar
  514. )
  515. language plpgsql
  516. as
  517. $$
  518. declare
  519.     cust_cursor cursor for
  520.         select username, first_name, last_name
  521.         from users join customer
  522.         on customer.user_id = users.id;
  523. begin
  524.     open cust_cursor;
  525.     return query
  526.     fetch all cust_cursor;
  527.     close cust_cursor;
  528.    
  529. end;
  530. $$;
  531.  
  532. select * from getUsernameCursor()
  533.  
  534.  
  535. --database adventureworks
  536.  
  537. --1. Paging
  538. --with cursor
  539. create or replace function person.getPersonPaginationCursor(lim int, page int)
  540. returns setof person.person
  541. language plpgsql
  542. as
  543. $$
  544. declare
  545.     offsetCustom int := lim * (page-1);
  546.     cursorPerson cursor(lim int, page int)
  547.     for select * from person.person
  548.     limit lim offset offsetCustom;
  549.     recordPerson person.person;
  550. begin
  551.     open cursorPerson(lim int, page int);
  552.         loop
  553.             fetch next from cursorPerson into recordPerson;
  554.             exit when not found;
  555.             return next recordPerson;
  556.         end loop;
  557.     close cursorPerson;
  558. end;
  559. $$;
  560.  
  561. select * from person.getPersonPaginationCursor(10, 3);
  562.  
  563. --without cursor
  564. create or replace function person.GetPersonPagination (lim int, page int)
  565. returns setof person.person
  566. language plpgsql
  567. as
  568. $$
  569. declare
  570.     offsetCustom int := lim * (page-1);
  571. begin
  572. return query
  573.     select * from person.person
  574.     limit lim offset offsetCustom;
  575. end;
  576. $$;
  577.  
  578. select * from person.getPersonPagination(5, 15)
  579.  
  580.  
  581. --2. Search firstname, middlename or lastname
  582. create or replace function getName(nama varchar)
  583. returns setof person.person
  584. language plpgsql
  585. as
  586. $$
  587. begin
  588.     return query
  589.     select * from person.person
  590.     where firstname ilike concat('%', nama, '%')
  591.     or middlename ilike concat('%', nama, '%')
  592.     or lastname ilike concat('%', nama, '%');
  593.    
  594.     if not found then
  595.         raise 'Data % tidak ditemukan', nama;
  596.     end if;
  597. end;
  598. $$;
  599.  
  600. select * from getName('Alvin')
  601.  
  602.  
  603. --3. Function person dashboard persontype+totalperson, region+totalperson
  604. create or replace function personDashboard()
  605. returns table (
  606.     person_type varchar,
  607.     total_person int
  608. )
  609. language plpgsql
  610. as
  611. $$
  612. declare
  613.     person_cursor cursor for
  614.     select persontype, cast (count(*)as int)
  615.     from person.person
  616.     group by persontype;
  617. begin
  618.     open person_cursor;
  619.     loop
  620.         fetch next from person_cursor into person_type, total_person;
  621.         exit when not found;
  622.         return next;
  623.     end loop;
  624.     close person_cursor;
  625. end;
  626. $$;
  627.  
  628. select * from personDashboard()
  629.  
  630.  
  631. create or replace function person_region_dashboard()
  632. returns table (
  633.     stateprovince varchar,
  634.     total_person int
  635. )
  636. language plpgsql
  637. as
  638. $$
  639. declare
  640.     personRegion_cursor cursor for
  641.     select stateprovince.countryregioncode, count(person.businessentityid)::int
  642.     from person.person
  643.     join person.businessentityaddress using(businessentityid)
  644.     join person.address using(addressid)
  645.     join person.stateprovince using(stateprovinceid)
  646.     group by countryregioncode;
  647. begin
  648.     open personRegion_cursor;
  649.     loop
  650.         fetch next from personRegion_cursor into stateprovince, total_person;
  651.         exit when not found;
  652.         return next;
  653.     end loop;
  654.     close personRegion_cursor;
  655. end;
  656. $$;
  657.  
  658. select * from person_region_dashboard()
  659.  
  660.  
  661. --procedure
  662.  
  663. create or replace procedure insertdata(in datauser json,in datacust json)
  664. language plpgsql
  665. as
  666. $$
  667. declare
  668.    rowid int;
  669.    rowidcust int;
  670. begin
  671. --  begin
  672.     insert into users(username,password)  
  673.     select x.username, x.password from json_to_recordset(datauser) x(username varchar,password text)
  674.      returning id into rowid;    
  675.      
  676.      insert into customer(firstname,lastname,user_id)  
  677.      select x.firstname, x.lastname,rowid from json_to_recordset(datacust) x(firstname varchar,lastname varchar)
  678.      returning id into rowidcust;
  679.      
  680. --   if rowidcust is null then
  681. --     rollback;
  682. --        raise 'Gagal insert data';
  683. --   else
  684. --     commit;
  685. --  end if;
  686. --  end;
  687. end;
  688. $$;
  689.  
  690. call insertdata('[{"username":"alvin","password":"bootcampcodex"}]','[{"firstname":"faiz","lastname":"rinaldi"}]')
  691.  
  692.  
  693. --
  694. create or replace procedure person.insertSignUp(in dataperson json)
  695. language plpgsql
  696. as
  697. $$
  698. declare
  699.     beid int;
  700. begin
  701.     insert into person.businessentity(rowguid)
  702.     values(default)
  703.     returning businessentityid into beid;
  704.    
  705.     insert into person.person (
  706.         businessentityid,
  707.         persontype,
  708.         firstname,
  709.         middlename,
  710.         lastname,
  711.         suffix,
  712.         emailpromotion
  713.     )
  714.     select beid, x.persontype, x.firstname, x.middlename, x.lastname, x.suffix, x.emailpromotion
  715.     from json_to_recordset(dataperson) x(persontype varchar, firstname varchar, middlename varchar, lastname varchar,
  716.     suffix varchar, emailpromotion int);
  717.    
  718.     insert into person.personphone(
  719.         businessentityid,
  720.         phonenumber,
  721.         phonenumbertypeid
  722.     )
  723.     select beid, x.phonenumber, x.phonenumbertypeid
  724.     from json_to_recordset(dataperson) x(phonenumber varchar, phonenumbertypeid int);
  725.    
  726.     end;
  727. $$;
  728.    
  729. call person.insertSignUp('[{"persontype":"EM", "firstname":"alvin", "middlename":"faiz", "lastname":"rinaldi",
  730.                   "suffix":"junior", "emailpromotion":1, "phonenumber":"089508955565", "phonenumbertypeid":1}]')
  731.    
  732.     select max(businessentityid) from person.businessentity
  733.    
  734.     select * from person.personphone
  735. --  where businessentityid=20777
  736.     order by businessentityid desc
  737.    
  738. --
  739. create or replace procedure purchasing.addtocart(in dt_pur json, in dt_detail json)
  740. language plpgsql
  741. as
  742. $$
  743. declare
  744.     idpur int;
  745.     iddetail int;
  746.     pur_rec record;
  747.     de_rec record;
  748. begin
  749.     select * from json_to_recordset(dt_pur)
  750.     x(purchaseorderid int, revisionnumber int,
  751.       status int,employeeid int, vendorid int,
  752.       shipmethodid int, subtotal numeric,
  753.       taxamt numeric, freight numeric)into pur_rec;
  754.     update purchasing.purchaseorderheader set subtotal = pur_rec.subtotal
  755.     where purchasing.purchaseorderheader.purchaseorderid = pur_rec.purchaseorderid
  756.     and purchasing.purchaseorderheader.employeeid = pur_rec.employeeid
  757.     and purchasing.purchaseorderheader.status = 1;
  758.    
  759.     if not found then
  760.    
  761.     insert into purchasing.purchaseorderheader(
  762.         revisionnumber,
  763.         status,
  764.         employeeid,
  765.         vendorid,
  766.         shipmethodid,
  767.         orderdate,shipdate,
  768.         subtotal,
  769.         taxamt,
  770.         freight)
  771.     select x.revisionnumber, x.status, x.employeeid,
  772.     x.vendorid, x.shipmethodid, x.orderdate,
  773.     x.shipdate, x.subtotal, x.taxamt, x.freight
  774.     from json_to_recordset(dt_pur)
  775.     x(purchaseorderid int, revisionnumber smallint, status smallint,
  776.       employeeid int, vendorid int, shipmethodid int,
  777.       orderdate timestamp, shipdate timestamp, subtotal numeric,
  778.       taxamt numeric, freight numeric)
  779.     returning purchaseorderid into idpur;
  780.    
  781.     insert into purchasing.purchaseorderdetail(
  782.         purchaseorderid,
  783.         duedate,
  784.         orderqty,
  785.         productid,
  786.         unitprice,
  787.         receivedqty,
  788.         rejectedqty)
  789.     select idpur, y.duedate, y.orderqty,
  790.     y.productid, y.unitprice, y.receivedqty, y.rejectedqty
  791.     from json_to_recordset(dt_detail)
  792.     y(duedate timestamp, orderqty int, productid int,
  793.       unitprice numeric, receivedqty int, rejectedqty int)
  794.     returning purchaseorderdetailid into iddetail;
  795.    
  796.     else
  797.     for de_rec in select * from json_to_recordset(dt_detail) as
  798.     y(purchaseorderid int, purchaseorderdetailid int, duedate timestamp,
  799.       orderqty int,productid int, unitprice numeric,receivedqty int,rejectedqty int)
  800.     loop
  801.         update purchasing.purchaseorderdetail
  802.         set orderqty = de_rec.orderqty
  803.         where purchasing.purchaseorderdetail.purchaseorderdetailid =  de_rec.purchaseorderdetailid;
  804.     end loop;
  805.         delete from purchasing.purchaseorderdetail
  806.         where purchasing.purchaseorderdetail.purchaseorderid = pur_rec.purchaseorderid
  807.         and purchasing.purchaseorderdetail.purchaseorderdetailid
  808.         not in (select y.purchaseorderdetailid from json_to_recordset(dt_detail) as
  809.                 y(purchaseorderdetailid int, duedate timestamp, orderqty int,
  810.                   productid int, unitprice numeric,receivedqty int,rejectedqty int));
  811.         end if;
  812. end;
  813. $$;
  814.  
  815. drop procedure addtocart(in dt_pur json, dt_detail json)
  816.  
  817. select * from purchasing.purchaseorderdetail
  818. where purchasing.purchaseorderdetail.purchaseorderid = 4028
  819. order by purchasing.purchaseorderdetail.purchaseorderid;
  820.  
  821. select * from purchasing.purchaseorderheader
  822. order by purchasing.purchaseorderheader.purchaseorderid desc;
  823.    
  824. update purchasing.purchaseorderheader set shipmethodid = 3
  825. where purchasing.purchaseorderheader.purchaseorderid = 2
  826. --  and purchasing.purchaseorderheader.employeeid = 253
  827. --  and purchasing.purchaseorderheader.status = 4;
  828.  
  829. call purchasing.addtocart ('[{"purchaseorderid":7, "revisionnumber":4,"status":4,"employeeid":258,"vendorid": 1580,"shipmethodid":3,"orderdate":"2011-04-16 00:00:00","shipdate":"2011-04-25 00:00:00","subtotal":201.04,"taxamt":16.0832,"freight": 16.0832}]',
  830. '[{"duedate":"2011-04-30 00:00:00","orderqty":4,"productid":4,"unitprice":50.26,"receivedqty":3,"rejectedqty":0}]')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement